Fixed cosmetic GoalManager destruction error.

This commit is contained in:
Nick Winter 2014-05-20 09:19:31 -07:00
parent 248cec1e6e
commit 022722a19f
2 changed files with 4 additions and 2 deletions

View file

@ -9,7 +9,7 @@ module.exports = class CocoClass
@nicksUsed: {}
@remainingNicks: []
@nextNick: ->
return "CocoClass " + classCount unless @nicks.length
return (@name or "CocoClass") + " " + classCount unless @nicks.length
@remainingNicks = if @remainingNicks.length then @remainingNicks else @nicks.slice()
baseNick = @remainingNicks.splice(Math.floor(Math.random() * @remainingNicks.length), 1)[0]
i = 0
@ -37,7 +37,7 @@ module.exports = class CocoClass
destroy: ->
# teardown subscriptions, prevent new ones
@stopListening?()
@off()
@off?()
@unsubscribeAll()
@stopListeningToShortcuts()
@constructor.nicksUsed[@nick] = false
@ -65,6 +65,7 @@ module.exports = class CocoClass
Backbone.Mediator.subscribe(channel, func, @)
unsubscribeAll: ->
return unless Backbone?.Mediator?
for channel, func of @subscriptions
func = utils.normalizeFunc(func, @)
Backbone.Mediator.unsubscribe(channel, func, @)

View file

@ -14,6 +14,7 @@ module.exports = class GoalManager extends CocoClass
# If you want weird goals or hybrid goals, make a custom goal.
nextGoalID: 0
nicks: ["GoalManager"]
constructor: (@world, @initialGoals, @team) ->
super()