| 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. |