feat(event): Implement Seasonal Shop

This commit is contained in:
Sabe Jones 2014-12-25 14:58:25 -06:00
parent aeceb70b54
commit 41f4ab7b8a
4 changed files with 32 additions and 9 deletions

View file

@ -1,4 +1,6 @@
{ {
"weapon": "weapon",
"weaponBase0Text": "No Weapon", "weaponBase0Text": "No Weapon",
"weaponBase0Notes": "No Weapon.", "weaponBase0Notes": "No Weapon.",
@ -123,6 +125,8 @@
"weaponMystery301404Text": "Steampunk Cane", "weaponMystery301404Text": "Steampunk Cane",
"weaponMystery301404Notes": "Excellent for taking a turn about town. March 3015 Subscriber Item. Confers no benefit.", "weaponMystery301404Notes": "Excellent for taking a turn about town. March 3015 Subscriber Item. Confers no benefit.",
"armor": "armor",
"armorBase0Text": "Plain Clothing", "armorBase0Text": "Plain Clothing",
"armorBase0Notes": "Ordinary clothing. Confers no benefit.", "armorBase0Notes": "Ordinary clothing. Confers no benefit.",
@ -246,6 +250,8 @@
"armorMystery301404Text": "Steampunk Suit", "armorMystery301404Text": "Steampunk Suit",
"armorMystery301404Notes": "Dapper and dashing, wot! Confers no benefit. February 3015 Subscriber Item.", "armorMystery301404Notes": "Dapper and dashing, wot! Confers no benefit. February 3015 Subscriber Item.",
"headgear": "headgear",
"headBase0Text": "No Helm", "headBase0Text": "No Helm",
"headBase0Notes": "No headgear.", "headBase0Notes": "No headgear.",
@ -367,6 +373,8 @@
"headMystery301405Text": "Basic Top Hat", "headMystery301405Text": "Basic Top Hat",
"headMystery301405Notes": "A basic top hat, just begging to be paired with some fancy head accessories. Confers no benefit. May 3015 Subscriber Item.", "headMystery301405Notes": "A basic top hat, just begging to be paired with some fancy head accessories. Confers no benefit. May 3015 Subscriber Item.",
"offhand": "off-hand item",
"shieldBase0Text": "No Off-Hand Equipment", "shieldBase0Text": "No Off-Hand Equipment",
"shieldBase0Notes": "No shield or second weapon.", "shieldBase0Notes": "No shield or second weapon.",

View file

@ -35,6 +35,7 @@
"neverMind": "Never mind", "neverMind": "Never mind",
"buyMoreGems": "Buy More Gems", "buyMoreGems": "Buy More Gems",
"notEnoughGems": "Not enough Gems", "notEnoughGems": "Not enough Gems",
"alreadyHave": "Whoops! You already have this item. No need to buy it again!",
"delete": "Delete", "delete": "Delete",
"gems": "Gems", "gems": "Gems",
"moreInfo": "More Info", "moreInfo": "More Info",

View file

@ -16,5 +16,11 @@
"jackolantern": "Jack-O-Lantern", "jackolantern": "Jack-O-Lantern",
"seasonalShop": "Seasonal Shop", "seasonalShop": "Seasonal Shop",
"seasonalShopClosedTitle": "<%= linkStart %>Siena Leslie<%= linkEnd %>", "seasonalShopClosedTitle": "<%= linkStart %>Siena Leslie<%= linkEnd %>",
"seasonalShopClosedText": "The Seasonal Shop is currently closed!! I don't know where the Seasonal Sorceress is now, but I bet she'll be back during the next <%= linkStart %>Grand Gala<%= linkEnd %>!" "seasonalShopTitle": "<%= linkStart %>Seasonal Sorceress<%= linkEnd %>",
} "seasonalShopClosedText": "The Seasonal Shop is currently closed!! I don't know where the Seasonal Sorceress is now, but I bet she'll be back during the next <%= linkStart %>Grand Gala<%= linkEnd %>!",
"seasonalShopText": "Welcome to the Seasonal Shop! From now until January 31st, we're stocking lots of seasonal edition winter goodies. After that, these items won't be back for another year, so get them while they're hot!! Or, er, cold.",
"candycaneSet": "Candy Cane (Mage)",
"skiSet": "Ski-sassin (Rogue)",
"snowflakeSet": "Snowflake (Healer)",
"yetiSet": "Yeti Tamer (Warrior)"
}

View file

@ -690,7 +690,7 @@ api.wrap = (user, main=true) ->
user.markModified? 'items.special' user.markModified? 'items.special'
cb? null, _.pick(user,$w 'items stats') cb? null, _.pick(user,$w 'items stats')
# buy is for gear, purchase is for gem-purchaseables (i know, I know...) # buy is for using Gold, purchase is for Gems (I know, I know...)
purchase: (req, cb, ga) -> purchase: (req, cb, ga) ->
{type,key} = req.params {type,key} = req.params
@ -705,13 +705,21 @@ api.wrap = (user, main=true) ->
user.stats.gp -= convRate user.stats.gp -= convRate
return cb? {code:200,message:"+1 Gems"}, _.pick(user,$w 'stats balance') return cb? {code:200,message:"+1 Gems"}, _.pick(user,$w 'stats balance')
return cb?({code:404,message:":type must be in [hatchingPotions,eggs,food,quests,special]"},req) unless type in ['eggs','hatchingPotions','food','quests','special'] return cb?({code:404,message:":type must be in [eggs,hatchingPotions,food,quests,gear]"},req) unless type in ['eggs','hatchingPotions','food','quests','gear']
item = content[type][key] if type is 'gear'
item = content.gear.flat[key]
return cb?({code:401, message: i18n.t('alreadyHave', req.language)}) if user.items.gear.owned[key]
price = (if item.twoHanded then 2 else 1) / 4
else
item = content[type][key]
price = item.value / 4
return cb?({code:404,message:":key not found for Content.#{type}"},req) unless item return cb?({code:404,message:":key not found for Content.#{type}"},req) unless item
return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if user.balance < (item.value / 4) return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if user.balance < price
user.items[type][key] = 0 unless user.items[type][key] > 0 user.balance -= price
user.items[type][key]++ if type is 'gear' then user.items.gear.owned[key] = true
user.balance -= (item.value / 4) else
user.items[type][key] = 0 unless user.items[type][key] > 0
user.items[type][key]++
cb? null, _.pick(user,$w 'items balance') cb? null, _.pick(user,$w 'items balance')
ga?.event('purchase', key).send() ga?.event('purchase', key).send()