@logic-pad/core 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2518,6 +2518,7 @@ declare global {
2518
2518
  get explanation(): string;
2519
2519
  get configs(): readonly AnyConfig[] | null;
2520
2520
  createExampleGrid(): GridData;
2521
+ private countForColor;
2521
2522
  countTiles(grid: GridData): {
2522
2523
  completed: number;
2523
2524
  possible: number;
@@ -2663,6 +2664,7 @@ declare global {
2663
2664
  get explanation(): string;
2664
2665
  get configs(): readonly AnyConfig[] | null;
2665
2666
  createExampleGrid(): GridData;
2667
+ private countForColor;
2666
2668
  countTiles(grid: GridData): {
2667
2669
  completed: number;
2668
2670
  possible: number;
@@ -17,6 +17,7 @@ export default class FocusSymbol extends NumberSymbol {
17
17
  get explanation(): string;
18
18
  get configs(): readonly AnyConfig[] | null;
19
19
  createExampleGrid(): GridData;
20
+ private countForColor;
20
21
  countTiles(grid: GridData): {
21
22
  completed: number;
22
23
  possible: number;
@@ -39,12 +39,7 @@ class FocusSymbol extends NumberSymbol {
39
39
  createExampleGrid() {
40
40
  return FocusSymbol.EXAMPLE_GRID;
41
41
  }
42
- countTiles(grid) {
43
- if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
44
- return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
45
- const color = grid.getTile(this.x, this.y).color;
46
- if (color === Color.Gray)
47
- return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
42
+ countForColor(grid, color) {
48
43
  let gray = 0;
49
44
  let same = 0;
50
45
  const visited = [];
@@ -67,6 +62,20 @@ class FocusSymbol extends NumberSymbol {
67
62
  }
68
63
  return { completed: same, possible: same + gray };
69
64
  }
65
+ countTiles(grid) {
66
+ if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
67
+ return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
68
+ const color = grid.getTile(this.x, this.y).color;
69
+ if (color === Color.Gray) {
70
+ const dark = this.countForColor(grid, Color.Dark);
71
+ const light = this.countForColor(grid, Color.Light);
72
+ return {
73
+ completed: Math.min(dark.completed, light.completed),
74
+ possible: Math.max(dark.possible, light.possible),
75
+ };
76
+ }
77
+ return this.countForColor(grid, color);
78
+ }
70
79
  copyWith({ x, y, number, }) {
71
80
  return new FocusSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
72
81
  }
@@ -18,6 +18,7 @@ export default class MinesweeperSymbol extends NumberSymbol {
18
18
  get explanation(): string;
19
19
  get configs(): readonly AnyConfig[] | null;
20
20
  createExampleGrid(): GridData;
21
+ private countForColor;
21
22
  countTiles(grid: GridData): {
22
23
  completed: number;
23
24
  possible: number;
@@ -34,12 +34,7 @@ class MinesweeperSymbol extends NumberSymbol {
34
34
  createExampleGrid() {
35
35
  return MinesweeperSymbol.EXAMPLE_GRID;
36
36
  }
37
- countTiles(grid) {
38
- if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
39
- return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
40
- const color = grid.getTile(this.x, this.y).color;
41
- if (color === Color.Gray)
42
- return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
37
+ countForColor(grid, color) {
43
38
  let gray = 0;
44
39
  let opposite = 0;
45
40
  const visited = [];
@@ -64,6 +59,20 @@ class MinesweeperSymbol extends NumberSymbol {
64
59
  }
65
60
  return { completed: opposite, possible: opposite + gray };
66
61
  }
62
+ countTiles(grid) {
63
+ if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
64
+ return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
65
+ const color = grid.getTile(this.x, this.y).color;
66
+ if (color === Color.Gray) {
67
+ const dark = this.countForColor(grid, Color.Dark);
68
+ const light = this.countForColor(grid, Color.Light);
69
+ return {
70
+ completed: Math.min(dark.completed, light.completed),
71
+ possible: Math.max(dark.possible, light.possible),
72
+ };
73
+ }
74
+ return this.countForColor(grid, color);
75
+ }
67
76
  copyWith({ x, y, number, }) {
68
77
  return new MinesweeperSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
69
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",