hotfix
This commit is contained in:
		
							parent
							
								
									fec941e502
								
							
						
					
					
						commit
						0754689f33
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		|  | @ -36,7 +36,7 @@ class Minesweeper { | ||||||
|         for (let i = 0; i < this.bombAmount; i++) { |         for (let i = 0; i < this.bombAmount; i++) { | ||||||
|             let x = Math.floor(Math.random() * this.width); |             let x = Math.floor(Math.random() * this.width); | ||||||
|             let y = Math.floor(Math.random() * this.height); |             let y = Math.floor(Math.random() * this.height); | ||||||
|             this.bombs[x][y] && this.field[x][y] != 0 ? i-- : this.bombs[x][y] = true; |             (this.bombs[x][y] || this.field[x][y] == 0) ? i-- : this.bombs[x][y] = true; | ||||||
|         } |         } | ||||||
|         this.firstClick = true; |         this.firstClick = true; | ||||||
|     } |     } | ||||||
|  | @ -58,11 +58,14 @@ class Minesweeper { | ||||||
|             for (let y = 0; y < this.field[x].length; y++) { |             for (let y = 0; y < this.field[x].length; y++) { | ||||||
|                 if (this.field[x][y] != 0 && !this.bombs[x][y]) { |                 if (this.field[x][y] != 0 && !this.bombs[x][y]) { | ||||||
|                     return; |                     return; | ||||||
|  |                 } else if (this.field[x][y] == 0 && this.bombs[x][y]) { | ||||||
|  |                     alert(`[ERROR]: Square (${x}|${y}) should not be a bomb!`); | ||||||
|  |                     this.bombs[x][y] = false; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         this.drawField(); |         this.drawField(); | ||||||
|         alert("You won!"); |         alert('You won!'); | ||||||
|         window.location.reload(); |         window.location.reload(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -88,7 +91,7 @@ class Minesweeper { | ||||||
|     uncoverSquare(x, y) { |     uncoverSquare(x, y) { | ||||||
|         if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) { |         if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) { | ||||||
|             if (this.bombs[x][y] && this.field[x][y] == 1) { |             if (this.bombs[x][y] && this.field[x][y] == 1) { | ||||||
|                 alert("You lost!"); |                 alert('You lost!'); | ||||||
|                 window.location.reload(); |                 window.location.reload(); | ||||||
|             } else if (this.field[x][y] == 1) { |             } else if (this.field[x][y] == 1) { | ||||||
|                 this.field[x][y] = 0; |                 this.field[x][y] = 0; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue