@gamepark/rules-api 7.1.0 → 7.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.
|
@@ -43,7 +43,7 @@ export declare class Polyhex<T = any> implements PolyhexConfig<T> {
|
|
|
43
43
|
* @param location Location to merge the new polyhex in
|
|
44
44
|
* @param onOverlap Callback function when a non-empty value is erased
|
|
45
45
|
*/
|
|
46
|
-
merge(polyhex:
|
|
46
|
+
merge(polyhex: Polyhex, location?: {
|
|
47
47
|
x?: number;
|
|
48
48
|
y?: number;
|
|
49
49
|
rotation?: number;
|
|
@@ -32,9 +32,13 @@ export class Polyhex {
|
|
|
32
32
|
*/
|
|
33
33
|
merge(polyhex, location = {}, onOverlap = () => {
|
|
34
34
|
}) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if (polyhex.system !== this.system) {
|
|
36
|
+
throw new Error('Merging polyhex with different systems is not implemented yet');
|
|
37
|
+
}
|
|
38
|
+
for (let y = polyhex.yMin; y <= polyhex.yMax; y++) {
|
|
39
|
+
for (let x = polyhex.xMin; x <= polyhex.xMax; x++) {
|
|
40
|
+
const value = polyhex.getValue({ x, y });
|
|
41
|
+
if (!this.isEmpty(value)) {
|
|
38
42
|
const rotatedCoordinates = hexRotate({ x, y }, location.rotation, this.system);
|
|
39
43
|
const coordinates = hexTranslate(rotatedCoordinates, { x: location.x ?? 0, y: location.y ?? 0 }, this.system);
|
|
40
44
|
while (coordinates.y < this.yMin) {
|
|
@@ -53,7 +57,7 @@ export class Polyhex {
|
|
|
53
57
|
if (this.grid[coordinates.y - this.yMin][coordinates.x - this.xMin]) {
|
|
54
58
|
onOverlap(x, y);
|
|
55
59
|
}
|
|
56
|
-
this.grid[coordinates.y - this.yMin][coordinates.x - this.xMin] =
|
|
60
|
+
this.grid[coordinates.y - this.yMin][coordinates.x - this.xMin] = value;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
}
|
|
@@ -1 +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AI,CAAA;QACjE,OAAO,QAAQ,GAAG,WAAW,EAAE,CAAC;YAC9B,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YAC5E,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,OAAO,QAAQ,CAAA;YACjB,CAAC;iBAAM,CAAC;gBACN,QAAQ,EAAE,CAAA;YACZ,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@gamepark/rules-api",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "API to implement the rules of a board game",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"prepack": "yarn build"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"Game Park",
|
|
17
|
-
"Board games",
|
|
18
|
-
"Rules"
|
|
19
|
-
],
|
|
20
|
-
"author": "Romain Fromi <romain@game-park.com> (https://game-park.com/)",
|
|
21
|
-
"license": "ISC",
|
|
22
|
-
"publishConfig": {
|
|
23
|
-
"access": "public"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/jest": "^30.0.0",
|
|
27
|
-
"@types/node": "^24.5.1",
|
|
28
|
-
"es-toolkit": "^1.39.10",
|
|
29
|
-
"i18next": "^25.5.2",
|
|
30
|
-
"jest": "^30.1.3",
|
|
31
|
-
"ts-jest": "^29.4.2",
|
|
32
|
-
"typescript": "^5.9.2"
|
|
33
|
-
},
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"es-toolkit": "^1.39.10"
|
|
36
|
-
},
|
|
37
|
-
"packageManager": "yarn@4.9.4"
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@gamepark/rules-api",
|
|
3
|
+
"version": "7.2.0",
|
|
4
|
+
"description": "API to implement the rules of a board game",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"prepack": "yarn build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"Game Park",
|
|
17
|
+
"Board games",
|
|
18
|
+
"Rules"
|
|
19
|
+
],
|
|
20
|
+
"author": "Romain Fromi <romain@game-park.com> (https://game-park.com/)",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jest": "^30.0.0",
|
|
27
|
+
"@types/node": "^24.5.1",
|
|
28
|
+
"es-toolkit": "^1.39.10",
|
|
29
|
+
"i18next": "^25.5.2",
|
|
30
|
+
"jest": "^30.1.3",
|
|
31
|
+
"ts-jest": "^29.4.2",
|
|
32
|
+
"typescript": "^5.9.2"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"es-toolkit": "^1.39.10"
|
|
36
|
+
},
|
|
37
|
+
"packageManager": "yarn@4.9.4"
|
|
38
|
+
}
|