Added infinite loop handling to Simulator.

This commit is contained in:
Nick Winter 2014-03-26 11:25:05 -07:00
parent 97613f12b4
commit 773df44b14

View file

@ -81,8 +81,14 @@ module.exports = class Simulator extends CocoClass
commenceSimulationAndSetupCallback: ->
@god.createWorld()
Backbone.Mediator.subscribeOnce 'god:infinite-loop', @onInfiniteLoop, @
Backbone.Mediator.subscribeOnce 'god:new-world-created', @processResults, @
onInfiniteLoop: ->
console.warn "Skipping infinitely looping game."
@trigger 'statusUpdate', 'Infinite loop detected; grabbing a new game.'
_.delay @cleanupAndSimulateAnotherTask, 5000
processResults: (simulationResults) ->
taskResults = @formTaskResultsObject simulationResults
@sendResultsBackToServer taskResults