mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 06:23:41 -04:00
Simulator handles more errors.
This commit is contained in:
parent
ac222c27e8
commit
515b8723a3
1 changed files with 11 additions and 3 deletions
|
@ -44,10 +44,18 @@ module.exports = class Simulator extends CocoClass
|
|||
return @handleNoGamesResponse() if jqXHR.status is 204
|
||||
@trigger 'statusUpdate', 'Setting up simulation!'
|
||||
@task = new SimulationTask(taskData)
|
||||
try
|
||||
levelID = @task.getLevelName()
|
||||
catch err
|
||||
console.error err
|
||||
@trigger 'statusUpdate', "Error simulating game: #{err}. Trying another game in #{@retryDelayInSeconds} seconds."
|
||||
@simulateAnotherTaskAfterDelay()
|
||||
return
|
||||
|
||||
@supermodel ?= new SuperModel()
|
||||
@god = new God maxWorkerPoolSize: 1, maxAngels: 1 # Start loading worker.
|
||||
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @task.getLevelName(), sessionID: @task.getFirstSessionID(), headless: true
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: levelID, sessionID: @task.getFirstSessionID(), headless: true
|
||||
@listenToOnce(@levelLoader, 'loaded-all', @simulateGame)
|
||||
|
||||
simulateGame: ->
|
||||
|
@ -86,8 +94,8 @@ module.exports = class Simulator extends CocoClass
|
|||
|
||||
onInfiniteLoop: ->
|
||||
console.warn "Skipping infinitely looping game."
|
||||
@trigger 'statusUpdate', 'Infinite loop detected; grabbing a new game.'
|
||||
_.delay @cleanupAndSimulateAnotherTask, 5000
|
||||
@trigger 'statusUpdate', "Infinite loop detected; grabbing a new game in #{@retryDelayInSeconds} seconds."
|
||||
_.delay @cleanupAndSimulateAnotherTask, @retryDelayInMilliseconds
|
||||
|
||||
processResults: (simulationResults) ->
|
||||
taskResults = @formTaskResultsObject simulationResults
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue