MCPcopy Create free account
hub / github.com/codecombat/codecombat / simulateNextGame

Method simulateNextGame

app/views/ladder/SimulateTabView.js:87–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85 }
86
87 simulateNextGame () {
88 if (!this.simulator) {
89 this.simulator = new Simulator({ levelID: this.options.level.get('slug'), leagueID: this.options.leagueID, singleLadder: this.options.level.isType('ladder'), levelOriginal: this.options.level.get('original') })
90 this.listenTo(this.simulator, 'statusUpdate', this.updateSimulationStatus)
91 // Work around simulator getting super slow on Chrome
92 const fetchAndSimulateTaskOriginal = this.simulator.fetchAndSimulateTask
93 this.simulator.fetchAndSimulateTask = () => {
94 if (this.destroyed) { return }
95 if (this.simulator.simulatedByYou >= 100) {
96 console.log('------------------- Destroying Simulator and making a new one -----------------')
97 this.simulator.destroy()
98 this.simulator = null
99 return this.simulateNextGame()
100 } else {
101 return fetchAndSimulateTaskOriginal.apply(this.simulator)
102 }
103 }
104 }
105 return this.simulator.fetchAndSimulateTask()
106 }
107
108 refresh () {
109 if (!(this.simulatorsLeaderboardData.numberOfGamesInQueue > 0)) { return } // Queue-based scoring is currently not active anyway, so don't keep checking this until we fix it.

Callers 1

startSimulatingMethod · 0.95

Calls 5

isTypeMethod · 0.80
logMethod · 0.80
applyMethod · 0.80
getMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected