feat(valentine): valentine event

This commit is contained in:
Tyler Renelle
2014-02-13 17:57:10 -07:00
parent 33fbc5716b
commit 608b829d7e
11 changed files with 1150 additions and 1072 deletions
+14
View File
@@ -468,6 +468,20 @@ api.spells =
user.stats.buffs.snowball = false
user.stats.gp -= 5
valentine:
text: "Valentine Card"
mana: 0
value: 10
target: 'user'
notes: "Send a valentines card to a friend."
cast: (user, target) ->
_.each [user,target], (t)->
t.achievements.valentine ?= 0
t.achievements.valentine++
(target.items.special.valentineReceived ?= []).push user.profile.name
target.markModified? 'items.special.valentineReceived'
user.stats.gp -= 10
# Intercept all spells to reduce user.stats.mp after casting the spell
_.each api.spells, (spellClass) ->
_.each spellClass, (spell, key) ->
+6
View File
@@ -612,6 +612,7 @@ api.wrap = (user, main=true) ->
# buy is for gear, purchase is for gem-purchaseables (i know, I know...)
buy: (req, cb) ->
{key} = req.params
item = if key is 'potion' then content.potion else content.gear.flat[key]
return cb?({code:404, message:"Item '#{key} not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.coffee)"}) unless item
return cb?({code:401, message:'Not enough gold.'}) if user.stats.gp < item.value
@@ -738,6 +739,11 @@ api.wrap = (user, main=true) ->
user.stats.mp++ if stat is 'int' #increase their MP along with their max MP
cb? null, _.pick(user,$w 'stats')
readValentine: (req,cb) ->
user.items.special.valentineReceived.shift()
user.markModified? 'items.special.valentineReceived'
cb? null, 'items.special'
# ------
# Score
# ------