mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-02 11:58:10 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
f93753b4bc
6 changed files with 31 additions and 18 deletions
|
@ -378,6 +378,7 @@ self.onWorldLoaded = function onWorldLoaded() {
|
||||||
}
|
}
|
||||||
var t3 = new Date();
|
var t3 = new Date();
|
||||||
console.log("And it was so: (" + (diff / self.world.totalFrames).toFixed(3) + "ms per frame,", self.world.totalFrames, "frames)\nSimulation :", diff + "ms \nSerialization:", (t2 - t1) + "ms\nDelivery :", (t3 - t2) + "ms");
|
console.log("And it was so: (" + (diff / self.world.totalFrames).toFixed(3) + "ms per frame,", self.world.totalFrames, "frames)\nSimulation :", diff + "ms \nSerialization:", (t2 - t1) + "ms\nDelivery :", (t3 - t2) + "ms");
|
||||||
|
self.world.goalManager.destroy();
|
||||||
self.world = null;
|
self.world = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -408,6 +409,7 @@ self.onWorldLoadProgress = function onWorldLoadProgress(progress) {
|
||||||
self.abort = function abort() {
|
self.abort = function abort() {
|
||||||
if(self.world) {
|
if(self.world) {
|
||||||
self.world.abort();
|
self.world.abort();
|
||||||
|
self.world.goalManager.destroy();
|
||||||
self.world = null;
|
self.world = null;
|
||||||
}
|
}
|
||||||
self.postMessage({type: 'abort'});
|
self.postMessage({type: 'abort'});
|
||||||
|
|
|
@ -47,7 +47,9 @@ module.exports = class God extends CocoClass
|
||||||
|
|
||||||
setLevel: (@level) ->
|
setLevel: (@level) ->
|
||||||
setLevelSessionIDs: (@levelSessionIDs) ->
|
setLevelSessionIDs: (@levelSessionIDs) ->
|
||||||
setGoalManager: (goalManager) -> @angelsShare.goalManager = goalManager
|
setGoalManager: (goalManager) ->
|
||||||
|
@angelsShare.goalManager?.destroy() unless @angelsShare.goalManager is goalManager
|
||||||
|
@angelsShare.goalManager = goalManager
|
||||||
setWorldClassMap: (worldClassMap) -> @angelsShare.worldClassMap = worldClassMap
|
setWorldClassMap: (worldClassMap) -> @angelsShare.worldClassMap = worldClassMap
|
||||||
|
|
||||||
onTomeCast: (e) ->
|
onTomeCast: (e) ->
|
||||||
|
|
|
@ -36,6 +36,7 @@ module.exports = class Simulator extends CocoClass
|
||||||
error: (errorData) ->
|
error: (errorData) ->
|
||||||
console.log "There was an error fetching two games! #{JSON.stringify errorData}"
|
console.log "There was an error fetching two games! #{JSON.stringify errorData}"
|
||||||
success: (taskData) =>
|
success: (taskData) =>
|
||||||
|
return if @destroyed
|
||||||
@trigger 'statusUpdate', 'Setting up simulation...'
|
@trigger 'statusUpdate', 'Setting up simulation...'
|
||||||
#refactor this
|
#refactor this
|
||||||
@task = new SimulationTask(taskData)
|
@task = new SimulationTask(taskData)
|
||||||
|
@ -48,6 +49,7 @@ module.exports = class Simulator extends CocoClass
|
||||||
@simulateSingleGame()
|
@simulateSingleGame()
|
||||||
else
|
else
|
||||||
@listenToOnce @supermodel, 'loaded-all', @simulateSingleGame
|
@listenToOnce @supermodel, 'loaded-all', @simulateSingleGame
|
||||||
|
|
||||||
simulateSingleGame: ->
|
simulateSingleGame: ->
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
@trigger 'statusUpdate', 'Simulating...'
|
@trigger 'statusUpdate', 'Simulating...'
|
||||||
|
@ -191,7 +193,7 @@ module.exports = class Simulator extends CocoClass
|
||||||
|
|
||||||
setupGod: ->
|
setupGod: ->
|
||||||
@god.setLevel @level.serialize @supermodel
|
@god.setLevel @level.serialize @supermodel
|
||||||
@god.setLevelSessionIDs (session.id for session in @task.getSessions())
|
@god.setLevelSessionIDs (session.sessionID for session in @task.getSessions())
|
||||||
@god.setWorldClassMap @world.classMap
|
@god.setWorldClassMap @world.classMap
|
||||||
@god.setGoalManager new GoalManager(@world, @level.get 'goals')
|
@god.setGoalManager new GoalManager(@world, @level.get 'goals')
|
||||||
|
|
||||||
|
@ -250,6 +252,7 @@ module.exports = class Simulator extends CocoClass
|
||||||
complete: @cleanupAndSimulateAnotherTask
|
complete: @cleanupAndSimulateAnotherTask
|
||||||
|
|
||||||
handleTaskResultsTransferSuccess: (result) =>
|
handleTaskResultsTransferSuccess: (result) =>
|
||||||
|
return if @destroyed
|
||||||
console.log "Task registration result: #{JSON.stringify result}"
|
console.log "Task registration result: #{JSON.stringify result}"
|
||||||
@trigger 'statusUpdate', 'Results were successfully sent back to server!'
|
@trigger 'statusUpdate', 'Results were successfully sent back to server!'
|
||||||
console.log "Simulated by you: " + @simulatedByYou
|
console.log "Simulated by you: " + @simulatedByYou
|
||||||
|
@ -260,10 +263,12 @@ module.exports = class Simulator extends CocoClass
|
||||||
application.tracker?.trackEvent 'Simulator Result', label: "Success"
|
application.tracker?.trackEvent 'Simulator Result', label: "Success"
|
||||||
|
|
||||||
handleTaskResultsTransferError: (error) =>
|
handleTaskResultsTransferError: (error) =>
|
||||||
|
return if @destroyed
|
||||||
@trigger 'statusUpdate', 'There was an error sending the results back to the server.'
|
@trigger 'statusUpdate', 'There was an error sending the results back to the server.'
|
||||||
console.log "Task registration error: #{JSON.stringify error}"
|
console.log "Task registration error: #{JSON.stringify error}"
|
||||||
|
|
||||||
cleanupAndSimulateAnotherTask: =>
|
cleanupAndSimulateAnotherTask: =>
|
||||||
|
return if @destroyed
|
||||||
@cleanupSimulation()
|
@cleanupSimulation()
|
||||||
@fetchAndSimulateTask()
|
@fetchAndSimulateTask()
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ module.exports = class Mark extends CocoClass
|
||||||
if @name is 'debug' or (@name is 'shadow' and @sprite.thang?.shape in ["rectangle", "box"])
|
if @name is 'debug' or (@name is 'shadow' and @sprite.thang?.shape in ["rectangle", "box"])
|
||||||
@mark.rotation = @sprite.thang.rotation * 180 / Math.PI
|
@mark.rotation = @sprite.thang.rotation * 180 / Math.PI
|
||||||
|
|
||||||
updateScale: ->
|
updateScale: (log) ->
|
||||||
if @name is 'bounds' and (@sprite.thang.width isnt @lastWidth or @sprite.thang.height isnt @lastHeight)
|
if @name is 'bounds' and (@sprite.thang.width isnt @lastWidth or @sprite.thang.height isnt @lastHeight)
|
||||||
oldMark = @mark
|
oldMark = @mark
|
||||||
@buildBounds()
|
@buildBounds()
|
||||||
|
@ -243,6 +243,7 @@ module.exports = class Mark extends CocoClass
|
||||||
oldMark.parent.removeChild oldMark
|
oldMark.parent.removeChild oldMark
|
||||||
|
|
||||||
if @markSprite?
|
if @markSprite?
|
||||||
|
@markSprite.scaleFactor = 1.2
|
||||||
@markSprite.updateScale()
|
@markSprite.updateScale()
|
||||||
return unless @name in ["selection", "target", "repair", "highlight"]
|
return unless @name in ["selection", "target", "repair", "highlight"]
|
||||||
if @sprite?.imageObject
|
if @sprite?.imageObject
|
||||||
|
|
|
@ -94,6 +94,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
super()
|
super()
|
||||||
|
@removeSubView subview for key, subview of @subviews when subview instanceof LadderSubmissionView
|
||||||
@$el.find('.ladder-submission-view').each (i, el) =>
|
@$el.find('.ladder-submission-view').each (i, el) =>
|
||||||
placeholder = $(el)
|
placeholder = $(el)
|
||||||
sessionID = placeholder.data('session-id')
|
sessionID = placeholder.data('session-id')
|
||||||
|
|
|
@ -22,7 +22,9 @@ module.exports = class ThangAvatarView extends View
|
||||||
unless @thangType.isFullyLoaded() or @thangType.loading
|
unless @thangType.isFullyLoaded() or @thangType.loading
|
||||||
@thangType.fetch()
|
@thangType.fetch()
|
||||||
|
|
||||||
@supermodel.loadModel @thangType, 'thang'
|
# couldn't get the level view to load properly through the supermodel
|
||||||
|
# so just doing it manually this time.
|
||||||
|
@listenTo @thangType, 'sync', @render
|
||||||
|
|
||||||
getSpriteThangType: ->
|
getSpriteThangType: ->
|
||||||
thangs = @supermodel.getModels(ThangType)
|
thangs = @supermodel.getModels(ThangType)
|
||||||
|
|
Loading…
Reference in a new issue