mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-30 16:03:37 -04:00
Merge branch 'adi2412-simulator-teardown'
This commit is contained in:
commit
661c60ec50
1 changed files with 5 additions and 1 deletions
|
@ -1,9 +1,10 @@
|
||||||
SuperModel = require 'models/SuperModel'
|
SuperModel = require 'models/SuperModel'
|
||||||
|
CocoClass = require 'lib/CocoClass'
|
||||||
LevelLoader = require 'lib/LevelLoader'
|
LevelLoader = require 'lib/LevelLoader'
|
||||||
GoalManager = require 'lib/world/GoalManager'
|
GoalManager = require 'lib/world/GoalManager'
|
||||||
God = require 'lib/God'
|
God = require 'lib/God'
|
||||||
|
|
||||||
module.exports = class Simulator
|
module.exports = class Simulator extends CocoClass
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
_.extend @, Backbone.Events
|
_.extend @, Backbone.Events
|
||||||
|
@ -14,9 +15,11 @@ module.exports = class Simulator
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@off()
|
@off()
|
||||||
@cleanupSimulation()
|
@cleanupSimulation()
|
||||||
|
super()
|
||||||
# TODO: More teardown?
|
# TODO: More teardown?
|
||||||
|
|
||||||
fetchAndSimulateTask: =>
|
fetchAndSimulateTask: =>
|
||||||
|
return if @destroyed
|
||||||
@trigger 'statusUpdate', 'Fetching simulation data!'
|
@trigger 'statusUpdate', 'Fetching simulation data!'
|
||||||
$.ajax
|
$.ajax
|
||||||
url: @taskURL
|
url: @taskURL
|
||||||
|
@ -49,6 +52,7 @@ module.exports = class Simulator
|
||||||
@levelLoader.once 'loaded-all', @simulateGame
|
@levelLoader.once 'loaded-all', @simulateGame
|
||||||
|
|
||||||
simulateGame: =>
|
simulateGame: =>
|
||||||
|
return if @destroyed
|
||||||
@trigger 'statusUpdate', 'All resources loaded, simulating!', @task.getSessions()
|
@trigger 'statusUpdate', 'All resources loaded, simulating!', @task.getSessions()
|
||||||
@assignWorldAndLevelFromLevelLoaderAndDestroyIt()
|
@assignWorldAndLevelFromLevelLoaderAndDestroyIt()
|
||||||
@setupGod()
|
@setupGod()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue