@peacestay/arcade-core 0.1.0 → 0.2.0

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.
package/CHANGELOG.md CHANGED
@@ -12,3 +12,11 @@
12
12
  - `Tile`, represents a tile with attributes
13
13
  - `Direction`, union type of left, right, up and down
14
14
  - `Position`, wrapper for row, col coord
15
+
16
+ ## [0.2.0] - 2026-10-27
17
+
18
+ ### Added
19
+ - `canMove(board, direction)`, flag for possible move in a certain direction, hasMoves now use canMove as helper function
20
+
21
+ ### Note
22
+ score() was implemented before the update, keep it unchanged to display the score
package/README.md CHANGED
@@ -49,6 +49,9 @@ points earned by the move
49
49
  ### `hasMoves(board): boolean`
50
50
  use move in four directions too see if any move is possible
51
51
 
52
+ ### `canMove(board, direction): boolean`
53
+ boolean flag if the board could move in a specific direction
54
+
52
55
  ## Key Types
53
56
 
54
57
  ### Board
@@ -1,4 +1,5 @@
1
- import type { Board } from "./types.js";
1
+ import type { Board, Direction } from "./types.js";
2
2
  export declare function score(board: Board): number;
3
3
  export declare function hasMoves(board: Board): boolean;
4
+ export declare function canMove(board: Board, direction: Direction): boolean;
4
5
  //# sourceMappingURL=rules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/2048/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA6B,MAAM,YAAY,CAAC;AAGnE,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE1C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAO9C"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/2048/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGnD,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE1C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAK9C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAEnE"}
@@ -4,10 +4,12 @@ export function score(board) {
4
4
  }
5
5
  export function hasMoves(board) {
6
6
  for (const direction of ['up', 'down', 'left', 'right']) {
7
- if (move(board, direction) !== board) {
7
+ if (canMove(board, direction))
8
8
  return true;
9
- }
10
9
  }
11
10
  return false;
12
11
  }
12
+ export function canMove(board, direction) {
13
+ return move(board, direction) !== board;
14
+ }
13
15
  //# sourceMappingURL=rules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/2048/rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,KAAK,CAAC,KAAY;IAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAY;IACjC,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAgB,EAAE,CAAC;QACrE,IAAI,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/2048/rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,KAAK,CAAC,KAAY;IAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAY;IACjC,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAgB,EAAE,CAAC;QACrE,IAAI,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY,EAAE,SAAoB;IACtD,OAAO,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,KAAK,CAAC;AAC5C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export type { Direction, Tile, Board, Position } from "./2048/types.js";
2
2
  export { createBoard } from "./2048/board.js";
3
3
  export { move } from "./2048/move.js";
4
4
  export { spawn } from "./2048/spawn.js";
5
- export { score, hasMoves } from "./2048/rules.js";
5
+ export { score, hasMoves, canMove } from "./2048/rules.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createBoard } from "./2048/board.js";
2
2
  export { move } from "./2048/move.js";
3
3
  export { spawn } from "./2048/spawn.js";
4
- export { score, hasMoves } from "./2048/rules.js";
4
+ export { score, hasMoves, canMove } from "./2048/rules.js";
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peacestay/arcade-core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Arcade core package for 2048 game logic",
6
6
  "main": "./dist/index.js",