Fixed problem with loading levels with no Programmable Thanags, and fixed infinite loops while simulating single games when swapping out Simulators.

This commit is contained in:
Nick Winter 2014-08-19 08:09:15 -07:00
parent 2c6fc67db2
commit 91db8397a0
2 changed files with 11 additions and 8 deletions

View file

@ -71,6 +71,7 @@ module.exports = class Simulator extends CocoClass
handleSingleSimulationError: (error) ->
console.error 'There was an error simulating a single game!', error
return if @destroyed
if @options.headlessClient and @options.simulateOnlyOneGame
console.log 'GAMERESULT:tie'
process.exit(0)
@ -78,6 +79,7 @@ module.exports = class Simulator extends CocoClass
handleSingleSimulationInfiniteLoop: ->
console.log 'There was an infinite loop in the single game!'
return if @destroyed
if @options.headlessClient and @options.simulateOnlyOneGame
console.log 'GAMERESULT:tie'
process.exit(0)

View file

@ -61,15 +61,16 @@ module.exports = class TomeView extends CocoView
super()
@worker = @createWorker()
programmableThangs = _.filter @options.thangs, 'isProgrammable'
if programmableThangs.length
@createSpells programmableThangs, programmableThangs[0].world # Do before spellList, thangList, and castButton
@spellList = @insertSubView new SpellListView spells: @spells, supermodel: @supermodel
@thangList = @insertSubView new ThangListView spells: @spells, thangs: @options.thangs, supermodel: @supermodel
@castButton = @insertSubView new CastButtonView spells: @spells, levelID: @options.levelID
@teamSpellMap = @generateTeamSpellMap(@spells)
else
@createSpells programmableThangs, programmableThangs[0]?.world # Do before spellList, thangList, and castButton
@spellList = @insertSubView new SpellListView spells: @spells, supermodel: @supermodel
@thangList = @insertSubView new ThangListView spells: @spells, thangs: @options.thangs, supermodel: @supermodel
@castButton = @insertSubView new CastButtonView spells: @spells, levelID: @options.levelID
@teamSpellMap = @generateTeamSpellMap(@spells)
unless programmableThangs.length
@cast()
console.warn 'Warning: There are no Programmable Thangs in this level, which makes it unplayable.'
warning = 'Warning: There are no Programmable Thangs in this level, which makes it unplayable.'
noty text: warning, layout: 'topCenter', type: 'warning', killer: false, timeout: 15000, dismissQueue: true, maxVisible: 3
console.warn warning
delete @options.thangs
onNewWorld: (e) ->