Update highlighting colors

And fix a bug where the two preferences would get mixed up.
This commit is contained in:
Florine W. Dekker 2023-12-01 12:58:44 +01:00
parent bfbbda2624
commit fc959d9619
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
3 changed files with 19 additions and 17 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "minesweeper",
"version": "0.85.3",
"version": "0.85.4",
"description": "Just Minesweeper!",
"author": "Florine W. Dekker",
"browser": "dist/bundle.js",
@ -17,21 +17,21 @@
},
"dependencies": {
"alea": "^1.0.1",
"canvas-confetti": "^1.6.0"
"canvas-confetti": "^1.9.2"
},
"devDependencies": {
"grunt": "^1.5.3",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^5.0.0",
"ts-loader": "^9.4.1",
"grunt-webpack": "^6.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0"
"typescript": "^5.3.2",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
}
}

View File

@ -10,8 +10,9 @@ import {Preferences} from "./Preferences";
*/
export class Display {
private readonly errorColor: string = "rgba(255, 0, 0, 0.3)";
private readonly hintColor: string = "rgba(0, 0, 255, 0.3)";
private readonly safeColor: string = "rgba(0, 255, 0, 0.5)";
private readonly hintColor: string = "rgba(128, 0, 128, 0.3)";
private readonly chordableColor: string = "rgba(0, 0, 255, 0.5)";
private readonly allNeighborsAreMinesColor: string = "rgba(0, 255, 0, 0.5)";
private readonly scale: number = 30;
@ -321,7 +322,6 @@ export class Display {
(this.preferences.showChordableHints || this.preferences.showAllNeighborsAreMinesHints)
) {
ctx.save();
ctx.fillStyle = this.safeColor;
this.field.squareList
.filter(it => !it.isCovered)
.filter(it => {
@ -329,12 +329,14 @@ export class Display {
const flags = it.getNeighborCount(it => it.hasFlag);
const covered = it.getNeighborCount(it => it.isCovered);
return (
(this.preferences.showChordableHints && mines === flags && covered !== flags) ||
(this.preferences.showAllNeighborsAreMinesHints && mines === covered && mines !== flags)
);
})
.forEach(square => ctx.fillRect(square.x * this.scale, square.y * this.scale, this.scale, this.scale));
if (this.preferences.showChordableHints && mines === covered && mines !== flags) {
ctx.fillStyle = this.chordableColor;
ctx.fillRect(it.x * this.scale, it.y * this.scale, this.scale, this.scale)
} else if (this.preferences.showAllNeighborsAreMinesHints && mines === flags && covered !== flags) {
ctx.fillStyle = this.allNeighborsAreMinesColor;
ctx.fillRect(it.x * this.scale, it.y * this.scale, this.scale, this.scale)
}
});
ctx.restore();
}
}