move tnl to a view function instead of model function, beging adding

party stats visuals (hp & exp presently)
This commit is contained in:
Tyler Renelle
2013-03-15 12:00:47 -04:00
parent 565c9004ca
commit d2837afbd4
5 changed files with 23 additions and 20 deletions
-10
View File
@@ -4,16 +4,6 @@ moment = require 'moment'
restoreRefs = module.exports.restoreRefs = (model) ->
# tnl function
model.fn '_tnl', '_user.stats.lvl', (lvl) ->
# see https://github.com/lefnire/habitrpg/issues/4
# also update in scoring.coffee. TODO create a function accessible in both locations
#TODO find a method of calling algos.tnl()
if lvl==100
0
else
Math.round(((Math.pow(lvl,2)*0.25)+(10 * lvl) + 139.75)/10)*10
#refLists
_.each ['habit', 'daily', 'todo', 'reward'], (type) ->
model.refList "_#{type}List", "_user.tasks", "_user.#{type}Ids"
+4
View File
@@ -1,6 +1,7 @@
character = require './character'
browser = require './browser'
items = require './items'
algos = require './algos'
moment = require 'moment'
_ = require 'underscore'
@@ -21,6 +22,9 @@ module.exports.username = username = (auth) ->
module.exports.view = (view) ->
view.fn "username", (auth) -> username(auth)
view.fn "tnl", (level) -> algos.tnl(level)
module.exports.app = (appExports, model) ->
user = model.at '_user'
+2 -1
View File
@@ -1,4 +1,5 @@
moment = require 'moment'
algos = require './algos'
module.exports.app = (appExports, model) ->
user = model.at('_user')
@@ -14,7 +15,7 @@ module.exports.app = (appExports, model) ->
window.location.reload()
appExports.cheat = ->
user.incr 'stats.exp', model.get '_tnl'
user.incr 'stats.exp', algos.tnl(user.get('stats.lvl'))
user.incr 'stats.gp', 1000
appExports.reset = ->
+1 -1
View File
@@ -136,7 +136,7 @@ updateStats = (model, newStats, batch) ->
obj.stats.hp = newStats.hp
if newStats.exp?
tnl = model.get '_tnl'
tnl = algos.tnl(obj.stats.lvl)
#silent = false
# if we're at level 100, turn xp to gold
if obj.stats.lvl >= 100