INFILTRATION: Minesweepergame minor bugfix, made rounding behavior for height, width and mine count consistent (#1526)

This commit is contained in:
mmjr-x 2024-07-31 00:23:55 +02:00 committed by GitHub
parent 6cae65fc0d
commit 4d57d636af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -166,7 +166,7 @@ function fieldEquals(a: boolean[][], b: boolean[][]): boolean {
function generateEmptyField(difficulty: Difficulty): boolean[][] {
const field = [];
for (let i = 0; i < difficulty.height; i++) {
for (let i = 0; i < Math.round(difficulty.height); i++) {
field.push(new Array(Math.round(difficulty.width)).fill(false));
}
return field;
@ -174,7 +174,7 @@ function generateEmptyField(difficulty: Difficulty): boolean[][] {
function generateMinefield(difficulty: Difficulty): boolean[][] {
const field = generateEmptyField(difficulty);
for (let i = 0; i < difficulty.mines; i++) {
for (let i = 0; i < Math.round(difficulty.mines); i++) {
const x = Math.floor(Math.random() * field.length);
const y = Math.floor(Math.random() * field[0].length);
if (field[x][y]) {