board-game-engine 1.0.4 → 2.0.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/dist/board-game-engine.cjs +5 -5
- package/dist/board-game-engine.js +5 -5
- package/dist/board-game-engine.min.js +2 -2
- package/dist/board-game-engine.mjs +5 -5
- package/examples/checkers.json +2 -2
- package/examples/connect-four.json +1 -1
- package/examples/eights.json +15 -15
- package/package.json +1 -1
- package/src/client/client.js +1 -1
- package/src/game-factory/condition/condition.js +1 -1
- package/src/utils/resolve-properties.js +9 -9
|
@@ -8416,10 +8416,10 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8416
8416
|
return get(bgioArguments.ctx, value2.path);
|
|
8417
8417
|
} else if (value2?.type === "gamePath") {
|
|
8418
8418
|
return get(bgioArguments.G, value2.path);
|
|
8419
|
-
} else if (value2?.type === "RelativePath") {
|
|
8419
|
+
} else if (value2?.type === "relativePath" || value2?.type === "RelativePath") {
|
|
8420
8420
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8421
8421
|
return get(target.attributes, value2.path) ?? null;
|
|
8422
|
-
} else if (value2?.type === "Parent") {
|
|
8422
|
+
} else if (value2?.type === "parent" || value2?.type === "Parent") {
|
|
8423
8423
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8424
8424
|
return bgioArguments.G.bank.findParent(originalTarget) ?? null;
|
|
8425
8425
|
} else if (value2?.type === "map") {
|
|
@@ -8449,7 +8449,7 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8449
8449
|
}
|
|
8450
8450
|
}
|
|
8451
8451
|
return maxTargets;
|
|
8452
|
-
} else if (value2?.type === "Pick") {
|
|
8452
|
+
} else if (value2?.type === "pick" || value2?.type === "Pick") {
|
|
8453
8453
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8454
8454
|
return (0, import_pick.default)(
|
|
8455
8455
|
resolveProperties(
|
|
@@ -8460,7 +8460,7 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8460
8460
|
),
|
|
8461
8461
|
value2.properties
|
|
8462
8462
|
);
|
|
8463
|
-
} else if (value2?.type === "Coordinates") {
|
|
8463
|
+
} else if (value2?.type === "coordinates" || value2?.type === "Coordinates") {
|
|
8464
8464
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8465
8465
|
const parent = bgioArguments.G.bank.findParent(originalTarget);
|
|
8466
8466
|
return parent.getCoordinates(originalTarget.rule.index);
|
|
@@ -27062,7 +27062,7 @@ function createPayload(bgioState, moveRule, targets, context) {
|
|
|
27062
27062
|
var Client2 = class {
|
|
27063
27063
|
constructor(options) {
|
|
27064
27064
|
this.options = options;
|
|
27065
|
-
this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules));
|
|
27065
|
+
this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules), options.gameName);
|
|
27066
27066
|
if (!options.boardgameIOGame) {
|
|
27067
27067
|
this.moveBuilder = { targets: [], stepIndex: 0, eliminatedMoves: [] };
|
|
27068
27068
|
this.optimisticWinner = null;
|
package/examples/checkers.json
CHANGED
|
@@ -719,7 +719,7 @@
|
|
|
719
719
|
"expression": "(player == '0' and destinationCoordinates[1] == 0) or (player == '1' and destinationCoordinates[1] == 7)",
|
|
720
720
|
"arguments": {
|
|
721
721
|
"player": {
|
|
722
|
-
"type": "
|
|
722
|
+
"type": "relativePath",
|
|
723
723
|
"target": {
|
|
724
724
|
"type": "contextPath",
|
|
725
725
|
"path": ["originalTarget"]
|
|
@@ -727,7 +727,7 @@
|
|
|
727
727
|
"path": ["entities", 0, "rule", "player"]
|
|
728
728
|
},
|
|
729
729
|
"destinationCoordinates": {
|
|
730
|
-
"type": "
|
|
730
|
+
"type": "coordinates",
|
|
731
731
|
"target": {
|
|
732
732
|
"type": "contextPath",
|
|
733
733
|
"path": ["target"]
|
package/examples/eights.json
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"conditions": [
|
|
162
162
|
{
|
|
163
163
|
"conditionType": "Is",
|
|
164
|
-
"target": { "type": "
|
|
164
|
+
"target": { "type": "parent" },
|
|
165
165
|
"matcher": { "name": "stock" }
|
|
166
166
|
},
|
|
167
167
|
{
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"conditions": [
|
|
196
196
|
{
|
|
197
197
|
"conditionType": "Is",
|
|
198
|
-
"target": { "type": "
|
|
198
|
+
"target": { "type": "parent" },
|
|
199
199
|
"matcher": { "name": "stock" }
|
|
200
200
|
},
|
|
201
201
|
{
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
"conditions": [
|
|
232
232
|
{
|
|
233
233
|
"conditionType": "Is",
|
|
234
|
-
"target": { "type": "
|
|
234
|
+
"target": { "type": "parent" },
|
|
235
235
|
"matcher": { "name": "discard" }
|
|
236
236
|
},
|
|
237
237
|
{
|
|
@@ -298,7 +298,7 @@
|
|
|
298
298
|
"conditions": [
|
|
299
299
|
{
|
|
300
300
|
"conditionType": "Is",
|
|
301
|
-
"target": { "type": "
|
|
301
|
+
"target": { "type": "parent" },
|
|
302
302
|
"matcher": {
|
|
303
303
|
"name": "hand",
|
|
304
304
|
"player": {
|
|
@@ -319,13 +319,13 @@
|
|
|
319
319
|
{
|
|
320
320
|
"conditionType": "Is",
|
|
321
321
|
"matcher": {
|
|
322
|
-
"type": "
|
|
322
|
+
"type": "pick",
|
|
323
323
|
"properties": ["suit"],
|
|
324
324
|
"target": {
|
|
325
325
|
"conditions": [
|
|
326
326
|
{
|
|
327
327
|
"conditionType": "Is",
|
|
328
|
-
"target": { "type": "
|
|
328
|
+
"target": { "type": "parent" },
|
|
329
329
|
"matcher": { "name": "discard" }
|
|
330
330
|
},
|
|
331
331
|
{
|
|
@@ -339,13 +339,13 @@
|
|
|
339
339
|
{
|
|
340
340
|
"conditionType": "Is",
|
|
341
341
|
"matcher": {
|
|
342
|
-
"type": "
|
|
342
|
+
"type": "pick",
|
|
343
343
|
"properties": ["value"],
|
|
344
344
|
"target": {
|
|
345
345
|
"conditions": [
|
|
346
346
|
{
|
|
347
347
|
"conditionType": "Is",
|
|
348
|
-
"target": { "type": "
|
|
348
|
+
"target": { "type": "parent" },
|
|
349
349
|
"matcher": { "name": "discard" }
|
|
350
350
|
},
|
|
351
351
|
{
|
|
@@ -452,7 +452,7 @@
|
|
|
452
452
|
"conditions": [
|
|
453
453
|
{
|
|
454
454
|
"conditionType": "Is",
|
|
455
|
-
"target": { "type": "
|
|
455
|
+
"target": { "type": "parent" },
|
|
456
456
|
"matcher": { "name": "discard" }
|
|
457
457
|
},
|
|
458
458
|
{
|
|
@@ -512,7 +512,7 @@
|
|
|
512
512
|
"matcher": {
|
|
513
513
|
"name": "score",
|
|
514
514
|
"player": {
|
|
515
|
-
"type": "
|
|
515
|
+
"type": "relativePath",
|
|
516
516
|
"target": {
|
|
517
517
|
"conditions": [
|
|
518
518
|
{
|
|
@@ -538,7 +538,7 @@
|
|
|
538
538
|
"expression": "existingScore + sum(faceValues)",
|
|
539
539
|
"arguments": {
|
|
540
540
|
"existingScore": {
|
|
541
|
-
"type": "
|
|
541
|
+
"type": "relativePath",
|
|
542
542
|
"target": {
|
|
543
543
|
"conditions": [
|
|
544
544
|
{
|
|
@@ -546,7 +546,7 @@
|
|
|
546
546
|
"matcher": {
|
|
547
547
|
"name": "score",
|
|
548
548
|
"player": {
|
|
549
|
-
"type": "
|
|
549
|
+
"type": "relativePath",
|
|
550
550
|
"target": {
|
|
551
551
|
"conditions": [
|
|
552
552
|
{
|
|
@@ -574,7 +574,7 @@
|
|
|
574
574
|
"conditions": [
|
|
575
575
|
{
|
|
576
576
|
"conditionType": "Is",
|
|
577
|
-
"target": { "type": "
|
|
577
|
+
"target": { "type": "parent" },
|
|
578
578
|
"matcher": {
|
|
579
579
|
"name": "hand",
|
|
580
580
|
"player": {
|
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
"expression": "cardValue == 8 ? 50 : (cardValue >= 10 and cardValue <= 13) ? 10 : cardValue",
|
|
591
591
|
"arguments": {
|
|
592
592
|
"cardValue": {
|
|
593
|
-
"
|
|
593
|
+
"type": "relativePath",
|
|
594
594
|
"target": {
|
|
595
595
|
|
|
596
596
|
"type": "contextPath",
|
|
@@ -627,7 +627,7 @@
|
|
|
627
627
|
"expression": "score >= numPlayers * 50",
|
|
628
628
|
"arguments": {
|
|
629
629
|
"score": {
|
|
630
|
-
"type": "
|
|
630
|
+
"type": "relativePath",
|
|
631
631
|
"target": {
|
|
632
632
|
"type": "contextPath",
|
|
633
633
|
"path": ["loopTarget"]
|
package/package.json
CHANGED
package/src/client/client.js
CHANGED
|
@@ -16,7 +16,7 @@ export class Client {
|
|
|
16
16
|
constructor (options) {
|
|
17
17
|
this.options = options
|
|
18
18
|
this.game = options.boardgameIOGame
|
|
19
|
-
|| gameFactory(JSON.parse(options.gameRules))
|
|
19
|
+
|| gameFactory(JSON.parse(options.gameRules), options.gameName)
|
|
20
20
|
|
|
21
21
|
if (!options.boardgameIOGame) {
|
|
22
22
|
this.moveBuilder = { targets: [], stepIndex: 0, eliminatedMoves: [] }
|
|
@@ -19,7 +19,7 @@ export default class Condition {
|
|
|
19
19
|
newContext
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
// We don't simply defer to payload target because of
|
|
22
|
+
// We don't simply defer to payload target because of parent and relativePath
|
|
23
23
|
// target types, for instance, which retarget to another entity
|
|
24
24
|
if (rule.target !== undefined) {
|
|
25
25
|
conditionPayload.target = rule.target
|
|
@@ -65,10 +65,10 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
65
65
|
return get(bgioArguments.ctx, value.path)
|
|
66
66
|
} else if (value?.type === 'gamePath') {
|
|
67
67
|
return get(bgioArguments.G, value.path)
|
|
68
|
-
} else if (value?.type === 'RelativePath') {
|
|
68
|
+
} else if (value?.type === 'relativePath' || value?.type === 'RelativePath') {
|
|
69
69
|
const target = resolveProperties(bgioArguments, value.target, context, 'target')
|
|
70
70
|
return get(target.attributes, value.path) ?? null
|
|
71
|
-
} else if (value?.type === 'Parent') {
|
|
71
|
+
} else if (value?.type === 'parent' || value?.type === 'Parent') {
|
|
72
72
|
const originalTarget = value.target
|
|
73
73
|
? resolveProperties(bgioArguments, value.target, context, 'target')
|
|
74
74
|
: context.originalTarget
|
|
@@ -100,7 +100,7 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
return maxTargets
|
|
103
|
-
} else if (value?.type === 'Pick') {
|
|
103
|
+
} else if (value?.type === 'pick' || value?.type === 'Pick') {
|
|
104
104
|
const target = resolveProperties(bgioArguments, value.target, context, 'target')
|
|
105
105
|
return pick(
|
|
106
106
|
resolveProperties(
|
|
@@ -111,12 +111,12 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
111
111
|
),
|
|
112
112
|
value.properties
|
|
113
113
|
)
|
|
114
|
-
} else if (value?.type === 'Coordinates') {
|
|
114
|
+
} else if (value?.type === 'coordinates' || value?.type === 'Coordinates') {
|
|
115
115
|
const originalTarget = value.target
|
|
116
116
|
? resolveProperties(bgioArguments, value.target, context, 'target')
|
|
117
117
|
: context.originalTarget
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const parent = bgioArguments.G.bank.findParent(originalTarget)
|
|
119
|
+
return parent.getCoordinates(originalTarget.rule.index)
|
|
120
120
|
} else if (value?.type === 'relativeCoordinates') {
|
|
121
121
|
const originalTarget = value.target
|
|
122
122
|
? resolveProperties(bgioArguments, value.target, context, 'target')
|
|
@@ -126,9 +126,9 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
126
126
|
parent.getCoordinates(originalTarget.rule.index)
|
|
127
127
|
const newCoordinates =
|
|
128
128
|
parent.getRelativeCoordinates(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
oldCoordinates,
|
|
130
|
+
resolveProperties(bgioArguments, value.location, context, 'location')
|
|
131
|
+
)
|
|
132
132
|
return (newCoordinates && parent.spaces[parent.getIndex(newCoordinates)]) ?? null
|
|
133
133
|
} else {
|
|
134
134
|
return value
|