()
| 122 | } |
| 123 | |
| 124 | private monstersHandling(): void{ |
| 125 | // If it's time to add a tree spirit |
| 126 | if(this.timeSinceLastTreeSpiritAdding > 70 && Random.flipACoin()){ |
| 127 | this.addTreeSpirit(); // We add it |
| 128 | this.timeSinceLastTreeSpiritAdding = 0; // We reset the timer |
| 129 | } |
| 130 | else |
| 131 | this.timeSinceLastTreeSpiritAdding += 1; // We increase the timer |
| 132 | |
| 133 | // If it's time to add a wolf |
| 134 | if(this.timeSinceLastWolfAdding > 30 && Random.oneChanceOutOf(5)){ |
| 135 | this.addWolf(); // We add it |
| 136 | this.timeSinceLastWolfAdding = 0; // We reset the timer |
| 137 | } |
| 138 | // Else, it's not the time yet |
| 139 | else |
| 140 | this.timeSinceLastWolfAdding += 1; // We increase the timer |
| 141 | |
| 142 | // If it's time to add a mosquito |
| 143 | if(this.mosquitoTimer <= 0){ |
| 144 | this.addMosquito(); |
| 145 | this.mosquitoTimer = Random.between(5, 10); |
| 146 | } |
| 147 | else this.mosquitoTimer -= 1; |
| 148 | } |
| 149 | |
| 150 | private thePlayerWon(): boolean{ |
| 151 | // If the player is at the right of the desert, we return true |
no test coverage detected