mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 18:15:52 -05:00
26 lines
751 B
CoffeeScript
26 lines
751 B
CoffeeScript
View = require 'views/kinds/CocoView'
|
|
template = require 'templates/play/level/gold'
|
|
teamTemplate = require 'templates/play/level/team_gold'
|
|
|
|
module.exports = class GoldView extends View
|
|
id: "gold-view"
|
|
template: template
|
|
|
|
subscriptions:
|
|
'surface:gold-changed': 'onGoldChanged'
|
|
'level-set-letterbox': 'onSetLetterbox'
|
|
|
|
onGoldChanged: (e) ->
|
|
@$el.show()
|
|
goldEl = @$el.find('.gold-amount.team-' + e.team)
|
|
unless goldEl.length
|
|
teamEl = teamTemplate team: e.team
|
|
@$el.append(teamEl)
|
|
goldEl = $('.gold-amount.team-' + e.team, teamEl)
|
|
text = '' + e.gold
|
|
if e.goldEarned and e.goldEarned > e.gold
|
|
text += " (#{e.goldEarned})"
|
|
goldEl.text text
|
|
|
|
onSetLetterbox: (e) ->
|
|
@$el.toggle not e.on
|