From 5274fd236a3e50a1dc027685a35c5583c8a60a2b Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Tue, 1 Sep 2015 17:17:50 -0400 Subject: [PATCH] WIP(time-travel): Time Travel pets/mounts Also begins process of adding tests for Mystic Hourglass purchases. --- common/locales/en/subscriber.json | 3 ++- common/script/content.coffee | 20 +++++++++++++++----- common/script/index.coffee | 8 ++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/common/locales/en/subscriber.json b/common/locales/en/subscriber.json index c448afe75f..55cb801c26 100644 --- a/common/locales/en/subscriber.json +++ b/common/locales/en/subscriber.json @@ -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." } diff --git a/common/script/content.coffee b/common/script/content.coffee index 5a5905ef27..9aceec4823 100644 --- a/common/script/content.coffee +++ b/common/script/content.coffee @@ -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') diff --git a/common/script/index.coffee b/common/script/index.coffee index f0dd2536fa..f2750bf6a6 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -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']