Skip to content

Commit

Permalink
fix: field completion check
Browse files Browse the repository at this point in the history
  • Loading branch information
lewxdev committed Aug 30, 2024
1 parent 97cca4e commit 2046a1a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/utils/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Field {
}

public get isComplete() {
return this.data.every((byte) => isExposed(byte) || isMine(byte));
return this.exposedPercent === 100;
}

public static async create(size = 10) {
Expand All @@ -55,7 +55,8 @@ export class Field {
(count, byte) => (isExposed(byte) && !isMine(byte) ? count + 1 : count),
0,
);
return new Field(size, mineCount, data, exposedCount);
const field = new Field(size, mineCount, data, exposedCount);
return field.isComplete ? Field.create(size + 10) : field;
} catch {
return Field.create();
}
Expand Down

0 comments on commit 2046a1a

Please sign in to comment.