fix(event): filter out past seasonal sets in Market

also block purchase of special spells outside their events
also remove hardcoded dates from seasonal shop intro text used on mobile
This commit is contained in:
Sabe Jones
2021-04-09 15:14:18 -05:00
parent c349719303
commit 46b8e7f725
3 changed files with 24 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import each from 'lodash/each';
import moment from 'moment';
import t from './translation';
import { NotAuthorized, BadRequest } from '../libs/errors';
import statsComputed from '../libs/statsComputed'; // eslint-disable-line import/no-cycle
@@ -287,6 +288,9 @@ spells.special = {
previousPurchase: true,
target: 'user',
notes: t('spellSpecialSnowballAuraNotes'),
canOwn () {
return false;
},
cast (user, target, req) {
if (!user.items.special.snowball) throw new NotAuthorized(t('spellNotOwned')(req.language));
target.stats.buffs.snowball = true;
@@ -320,6 +324,9 @@ spells.special = {
previousPurchase: true,
target: 'user',
notes: t('spellSpecialSpookySparklesNotes'),
canOwn () {
return false;
},
cast (user, target, req) {
if (!user.items.special.spookySparkles) throw new NotAuthorized(t('spellNotOwned')(req.language));
target.stats.buffs.snowball = false;
@@ -354,6 +361,9 @@ spells.special = {
target: 'user',
notes: t('spellSpecialShinySeedNotes'),
event: EVENTS.spring2021,
canOwn () {
return moment().isBetween('2021-04-06T08:00-05:00', EVENTS.spring2021.end);
},
cast (user, target, req) {
if (!user.items.special.shinySeed) throw new NotAuthorized(t('spellNotOwned')(req.language));
target.stats.buffs.snowball = false;
@@ -387,6 +397,9 @@ spells.special = {
previousPurchase: true,
target: 'user',
notes: t('spellSpecialSeafoamNotes'),
canOwn () {
return false;
},
cast (user, target, req) {
if (!user.items.special.seafoam) throw new NotAuthorized(t('spellNotOwned')(req.language));
target.stats.buffs.snowball = false;
@@ -421,6 +434,9 @@ spells.special = {
silent: true,
target: 'user',
notes: t('nyeCardNotes'),
canOwn () {
return false;
},
cast (user, target) {
if (user === target) {
if (!user.achievements.nye) user.achievements.nye = 0;
@@ -458,6 +474,9 @@ spells.special = {
silent: true,
target: 'user',
notes: t('valentineCardNotes'),
canOwn () {
return false;
},
cast (user, target) {
if (user === target) {
if (!user.achievements.valentine) user.achievements.valentine = 0;