WIP(time-travel): Time Travel pets/mounts

Also begins process of adding tests for Mystic Hourglass purchases.
This commit is contained in:
Sabe Jones 2015-09-01 17:17:50 -04:00
parent 68fef118e1
commit 5274fd236a
3 changed files with 23 additions and 8 deletions

View file

@ -64,5 +64,6 @@
"mysticHourglassPopover": "Mystic Hourglass allow you to purchase previous months' subscriber sets.",
"subUpdateCard": "Update Card",
"subUpdateTitle": "Update",
"subUpdateDescription": "Update the card to be charged."
"subUpdateDescription": "Update the card to be charged.",
"notEnoughHourglasses": "You don't have enough Mystic Hourglasses."
}

View file

@ -538,12 +538,18 @@ _.each gearTypes, (type) ->
Time Traveler Store, mystery sets need their items mapped in
###
_.each api.mystery, (v,k)-> v.items = _.where api.gear.flat, {mystery:k}
api.timeTravelerStore = (owned) ->
api.timeTravelerStore = (owned, category) ->
ownedKeys = _.keys owned.toObject?() or owned # mongoose workaround
_.reduce api.mystery, (m,v,k)->
return m if k=='wondercon' or ~ownedKeys.indexOf(v.items[0].key) # skip wondercon and already-owned sets
m[k] = v;m
, {}
if not category or category is "mystery"
_.reduce api.mystery, (m,v,k)->
return m if k=='wondercon' or ~ownedKeys.indexOf(v.items[0].key) # skip wondercon and already-owned sets
m[k] = v;m
, {}
else
_.reduce api.timeTravelStable[category], (m,v,i)->
returm m if ~ownedKeys.indexOf(v)
m[i] = v;m
, []
###
---------------------------------------------------------------
@ -1130,6 +1136,10 @@ api.specialMounts =
'Orca-Base': 'orca'
'Gryphon-RoyalPurple': 'royalPurpleGryphon'
api.timeTravelStable =
pets: ['Mammoth-Base','MantisShrimp-Base']
mounts: ['Mammoth-Base','MantisShrimp-Base']
api.hatchingPotions =
Base: value: 2, text: t('hatchingPotionBase')
White: value: 2, text: t('hatchingPotionWhite')

View file

@ -999,10 +999,10 @@ api.wrap = (user, main=true) ->
cb? {code:200, message}, user.items.quests
buyMysterySet: (req, cb, analytics)->
return cb?({code:401, message:"You don't have enough Mystic Hourglasses"}) unless user.purchased.plan.consecutive.trinkets>0
return cb?({code:401, message:i18n.t('notEnoughHourglasses', req.language)}) unless user.purchased.plan.consecutive.trinkets > 0
mysterySet = content.timeTravelerStore(user.items.gear.owned)?[req.params.key]
if window?.confirm?
return unless window.confirm("Buy this full set of items for 1 Mystic Hourglass?")
return unless window.confirm(i18n.t('hourglassBuyEquipSetConfirm'))
return cb?({code:404, message:"Mystery set not found, or set already owned"}) unless mysterySet
_.each mysterySet.items, (i)->
user.items.gear.owned[i.key]=true
@ -1018,6 +1018,10 @@ api.wrap = (user, main=true) ->
user.purchased.plan.consecutive.trinkets--
cb? null, _.pick(user,$w 'items purchased.plan.consecutive')
hourglassPurchase: (req, cb, analytics)->
return cb?({code:401, message:i18n.t('notEnoughHourglasses', req.language)}) unless user.purchased.plan.consecutive.trinkets > 0
sell: (req, cb) ->
{key, type} = req.params
return cb?({code:404,message:":type not found. Must bes in [eggs, hatchingPotions, food]"}) unless type in ['eggs','hatchingPotions', 'food']