| 39 | } |
| 40 | |
| 41 | SetBestPlayer() { |
| 42 | |
| 43 | this.bestPlayerIndex = 0; |
| 44 | this.newLevelReached = false; |
| 45 | for (let i = 0; i < this.players.length; i++) { |
| 46 | if (this.players[i].bestHeightReached > this.players[this.bestPlayerIndex].bestHeightReached) { |
| 47 | this.bestPlayerIndex = i; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | if (this.players[this.bestPlayerIndex].bestLevelReached > this.currentBestLevelReached) { |
| 52 | this.currentBestLevelReached = this.players[this.bestPlayerIndex].bestLevelReached; |
| 53 | this.newLevelReached = true; |
| 54 | this.reachedBestLevelAtActionNo = this.players[this.bestPlayerIndex].bestLevelReachedOnActionNo; |
| 55 | print("NEW LEVEL, action number", this.reachedBestLevelAtActionNo) |
| 56 | } |
| 57 | this.bestHeight = this.players[this.bestPlayerIndex].bestHeightReached; |
| 58 | } |
| 59 | |
| 60 | SetCurrentHighestPlayer() { |
| 61 | this.currentHighestPlayerIndex = 0; |