wrap up some "token" => "gem" conversions, code-style

This commit is contained in:
Tyler Renelle
2013-05-11 19:19:09 +01:00
parent 35342e8b71
commit 0ca67bef95
9 changed files with 31 additions and 31 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ module.exports.app = (appExports, model) ->
taskTypes = ['habit', 'daily', 'todo', 'reward']
batch.set 'tasks', {}
_.each taskTypes, (type) -> batch.set "#{type}Ids", []
batch.set 'balance', 1 if user.get('balance') < 1 #only if they haven't manually bought tokens
batch.set 'balance', 1 if user.get('balance') < 1 #only if they haven't manually bought gems
# Reset stats
batch.set 'stats.hp', 50
+1 -1
View File
@@ -58,7 +58,7 @@ viewHelpers = (view) ->
view.fn "truarr", (num) -> num-1
view.fn 'count', (arr) -> arr?.length or 0
view.fn "tokens", (gp) -> return gp/0.25
view.fn "gems", (gp) -> return gp/0.25
view.fn "encodeiCalLink", (uid, apiToken) ->
loc = window?.location.host or process.env.BASE_URL
+10 -10
View File
@@ -54,21 +54,21 @@ module.exports.app = (appExports, model) ->
appExports.buyHatchingPotion = (e, el) ->
name = $(el).attr 'data-hatchingPotion'
newHatchingPotion = _.findWhere hatchingPotions, name: name
tokens = user.get('balance') * 4
if tokens >= newHatchingPotion.value
if confirm "Buy this hatching potion with #{newHatchingPotion.value} of your #{tokens} Gems?"
gems = user.get('balance') * 4
if gems >= newHatchingPotion.value
if confirm "Buy this hatching potion with #{newHatchingPotion.value} of your #{gems} Gems?"
user.push 'items.hatchingPotions', newHatchingPotion.name
user.set 'balance', (tokens - newHatchingPotion.value) / 4
user.set 'balance', (gems - newHatchingPotion.value) / 4
else
$('#more-tokens-modal').modal 'show'
$('#more-gems-modal').modal 'show'
appExports.buyEgg = (e, el) ->
name = $(el).attr 'data-egg'
newEgg = _.findWhere pets, name: name
tokens = user.get('balance') * 4
if tokens >= newEgg.value
if confirm "Buy this egg with #{newEgg.value} of your #{tokens} Gems?"
gems = user.get('balance') * 4
if gems >= newEgg.value
if confirm "Buy this egg with #{newEgg.value} of your #{gems} Gems?"
user.push 'items.eggs', newEgg
user.set 'balance', (tokens - newEgg.value) / 4
user.set 'balance', (gems - newEgg.value) / 4
else
$('#more-tokens-modal').modal 'show'
$('#more-gems-modal').modal 'show'