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.
@@ -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;
@@ -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": "RelativePath",
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": "Coordinates",
730
+ "type": "coordinates",
731
731
  "target": {
732
732
  "type": "contextPath",
733
733
  "path": ["target"]
@@ -107,7 +107,7 @@
107
107
  "conditions": [
108
108
  {
109
109
  "conditionType": "Is",
110
- "target": { "type": "Parent" },
110
+ "target": { "type": "parent" },
111
111
  "matcher": { "name": "mainGrid" }
112
112
  }
113
113
  ]
@@ -161,7 +161,7 @@
161
161
  "conditions": [
162
162
  {
163
163
  "conditionType": "Is",
164
- "target": { "type": "Parent" },
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": "Parent" },
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": "Parent" },
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": "Parent" },
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": "Pick",
322
+ "type": "pick",
323
323
  "properties": ["suit"],
324
324
  "target": {
325
325
  "conditions": [
326
326
  {
327
327
  "conditionType": "Is",
328
- "target": { "type": "Parent" },
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": "Pick",
342
+ "type": "pick",
343
343
  "properties": ["value"],
344
344
  "target": {
345
345
  "conditions": [
346
346
  {
347
347
  "conditionType": "Is",
348
- "target": { "type": "Parent" },
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": "Parent" },
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": "RelativePath",
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": "RelativePath",
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": "RelativePath",
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": "Parent" },
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
- "conditionType": "RelativePath",
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": "RelativePath",
630
+ "type": "relativePath",
631
631
  "target": {
632
632
  "type": "contextPath",
633
633
  "path": ["loopTarget"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "board-game-engine",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "wip board game engine",
5
5
  "main": "dist/board-game-engine.cjs",
6
6
  "module": "dist/board-game-engine.mjs",
@@ -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 Parent and RelativePath
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
- const parent = bgioArguments.G.bank.findParent(originalTarget)
119
- return parent.getCoordinates(originalTarget.rule.index)
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
- oldCoordinates,
130
- resolveProperties(bgioArguments, value.location, context, 'location')
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