mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Removed unneede catiline lib. Trying speedups for updating HUD property values and Lank Thang inventory.
This commit is contained in:
parent
17f2d76512
commit
155ead86cf
4 changed files with 15 additions and 5 deletions
|
@ -130,3 +130,13 @@ module.exports.kindaEqual = compare = (l, r) ->
|
|||
return true
|
||||
else
|
||||
return false
|
||||
|
||||
# Fast, basic way to replace text in an element when you don't need much.
|
||||
# http://stackoverflow.com/a/4962398/540620
|
||||
if document?
|
||||
dummy = document.createElement 'div'
|
||||
dummy.innerHTML = 'text'
|
||||
TEXT = if dummy.textContent is 'text' then 'textContent' else 'innerText'
|
||||
module.exports.replaceText = (elems, text) ->
|
||||
elem[TEXT] = text for elem in elems
|
||||
null
|
||||
|
|
|
@ -192,7 +192,7 @@ module.exports = class LankBoss extends CocoClass
|
|||
updatedObstacles = []
|
||||
itemsJustEquipped = []
|
||||
for thang in @world.thangs when thang.exists and thang.pos
|
||||
itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang
|
||||
itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang if thang.equip
|
||||
if lank = @lanks[thang.id]
|
||||
lank.setThang thang # make sure Lank has latest Thang
|
||||
else
|
||||
|
|
|
@ -2,6 +2,7 @@ CocoView = require 'views/core/CocoView'
|
|||
template = require 'templates/play/level/hud'
|
||||
prop_template = require 'templates/play/level/hud_prop'
|
||||
LevelOptions = require 'lib/LevelOptions'
|
||||
utils = require 'core/utils'
|
||||
|
||||
module.exports = class LevelHUDView extends CocoView
|
||||
id: 'thang-hud'
|
||||
|
@ -104,7 +105,7 @@ module.exports = class LevelHUDView extends CocoView
|
|||
name = {knight: 'Tharin', captain: 'Anya', librarian: 'Hushbaum', sorcerer: 'Pender', 'potion-master': 'Omarn', samurai: 'Hattori', ninja: 'Amara'}[@thang.type] ? 'Hero'
|
||||
else
|
||||
name = if @thang.type then "#{@thang.id} - #{@thang.type}" else @thang.id
|
||||
@$el.find('.thang-name').text name
|
||||
utils.replaceText @$el.find('.thang-name'), name
|
||||
props = @$el.find('.thang-props')
|
||||
props.find('.prop').remove()
|
||||
#propNames = _.without @thang.hudProperties ? [], 'action'
|
||||
|
@ -145,7 +146,7 @@ module.exports = class LevelHUDView extends CocoView
|
|||
labelText = prop + ': ' + @formatValue(prop, val) + ' / ' + @formatValue(prop, max)
|
||||
if regen
|
||||
labelText += ' (+' + @formatValue(prop, regen) + '/s)'
|
||||
pel.find('.bar-prop-value').text(Math.round(max)) if max
|
||||
utils.replaceText pel.find('.bar-prop-value'), Math.round(val)
|
||||
else
|
||||
s = @formatValue(prop, val)
|
||||
labelText = "#{prop}: #{s}"
|
||||
|
@ -153,7 +154,7 @@ module.exports = class LevelHUDView extends CocoView
|
|||
cooldown = @thang.actions.attack.cooldown
|
||||
dps = @thang.attackDamage / cooldown
|
||||
labelText += " / #{cooldown.toFixed(2)}s (DPS: #{dps.toFixed(2)})"
|
||||
pel.find('.prop-value').text s
|
||||
utils.replaceText pel.find('.prop-value'), s
|
||||
pel.attr 'title', labelText
|
||||
pel
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
"aether": "~0.2.39",
|
||||
"underscore.string": "~2.3.3",
|
||||
"firebase": "~1.0.2",
|
||||
"catiline": "~2.9.3",
|
||||
"d3": "~3.4.4",
|
||||
"jsondiffpatch": "0.1.8",
|
||||
"nanoscroller": "~0.8.0",
|
||||
|
|
Loading…
Reference in a new issue