wrap up some "token" => "gem" conversions, code-style
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user