board-game-engine 0.0.8 → 0.0.9
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.js +23 -22
- package/dist/board-game-engine.min.js +1 -1
- package/e2e/bge.spec.js +267 -0
- package/e2e/bgio-minimal.spec.js +70 -0
- package/e2e/examples.spec.js +34 -0
- package/e2e/fixtures/bge-checkers.html +39 -0
- package/e2e/fixtures/bge-minimal.html +43 -0
- package/e2e/fixtures/bge-ttt.html +45 -0
- package/e2e/fixtures/bgio-minimal-debug.html +47 -0
- package/e2e/fixtures/bgio-minimal.html +44 -0
- package/e2e/fixtures/minimal-game.json +4 -0
- package/examples/checkers.json +793 -0
- package/examples/connect-four.json +126 -0
- package/examples/eights.json +653 -0
- package/examples/index.html +219 -0
- package/examples/reversi.json +215 -0
- package/examples/tic-tac-toe.json +53 -0
- package/package.json +8 -5
- package/playwright-report/index.html +85 -0
- package/playwright.config.cjs +23 -0
- package/src/client/client.js +2 -1
- package/src/game-factory/bank/bank.js +1 -1
- package/src/game-factory/condition/is-full-condition.js +1 -1
- package/src/game-factory/condition/would-condition.js +1 -1
- package/src/game-factory/expand-game-rules.js +7 -12
- package/src/game-factory/move/move-factory.js +1 -1
- package/src/game-factory/space-group/space-group.js +1 -1
- package/src/index.js +1 -1
- package/src/utils/get-steps.js +1 -1
- package/test-results/.last-run.json +4 -0
- package/babel.config.js +0 -6
- package/board-game-engine.test.js +0 -7
- package/jest.config.js +0 -21
- package/tic-tac-toe-verbose.json +0 -54
|
@@ -16407,7 +16407,8 @@ class Client {
|
|
|
16407
16407
|
this.client.start();
|
|
16408
16408
|
return this;
|
|
16409
16409
|
} catch (error) {
|
|
16410
|
-
console.error('Failed to join game:', error);
|
|
16410
|
+
console.error('Failed to join game:', error?.message ?? error);
|
|
16411
|
+
if (error?.stack) console.error(error.stack);
|
|
16411
16412
|
}
|
|
16412
16413
|
}
|
|
16413
16414
|
update() {
|
|
@@ -16676,7 +16677,7 @@ class Bank {
|
|
|
16676
16677
|
createEntity() {
|
|
16677
16678
|
let definition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16678
16679
|
let options = arguments.length > 1 ? arguments[1] : undefined;
|
|
16679
|
-
const entity = new _registry.registry[definition.
|
|
16680
|
+
const entity = new _registry.registry[definition.entityType || 'Entity']({
|
|
16680
16681
|
bank: this,
|
|
16681
16682
|
fromBank: true,
|
|
16682
16683
|
...options
|
|
@@ -17158,7 +17159,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
17158
17159
|
class IsFull extends _condition.default {
|
|
17159
17160
|
checkCondition(bgioArguments, rule, payload, context) {
|
|
17160
17161
|
return {
|
|
17161
|
-
conditionIsMet: payload.target.spaces.every(space => space
|
|
17162
|
+
conditionIsMet: payload.target.spaces.every(space => space?.entities.length)
|
|
17162
17163
|
};
|
|
17163
17164
|
}
|
|
17164
17165
|
}
|
|
@@ -17345,7 +17346,7 @@ class WouldCondition extends _condition.default {
|
|
|
17345
17346
|
const payload = {
|
|
17346
17347
|
arguments: targets.reduce((acc, target, i) => ({
|
|
17347
17348
|
...acc,
|
|
17348
|
-
[argNameMap[context.moveInstance.rule.
|
|
17349
|
+
[argNameMap[context.moveInstance.rule.moveType][i]]: target
|
|
17349
17350
|
}), {})
|
|
17350
17351
|
};
|
|
17351
17352
|
const simulatedG = (0, _simulateMove.default)(bgioArguments, payload, context);
|
|
@@ -17477,10 +17478,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
17477
17478
|
// Things we always want, don't need to configure, and
|
|
17478
17479
|
// want to treat as first-class citizens
|
|
17479
17480
|
const invariantEntities = [{
|
|
17480
|
-
|
|
17481
|
+
entityType: "Space",
|
|
17481
17482
|
count: "Infinity"
|
|
17482
17483
|
}, {
|
|
17483
|
-
|
|
17484
|
+
entityType: "Board",
|
|
17484
17485
|
name: 'sharedBoard'
|
|
17485
17486
|
}, {
|
|
17486
17487
|
name: "playerMarker",
|
|
@@ -17503,7 +17504,7 @@ function expandInitialPlacements(rules, entities) {
|
|
|
17503
17504
|
}
|
|
17504
17505
|
if (rules.personalBoard) {
|
|
17505
17506
|
entities.push({
|
|
17506
|
-
|
|
17507
|
+
entityType: "Board",
|
|
17507
17508
|
name: 'personalBoard',
|
|
17508
17509
|
perPlayer: true
|
|
17509
17510
|
});
|
|
@@ -17527,7 +17528,7 @@ function expandInitialPlacements(rules, entities) {
|
|
|
17527
17528
|
const entityDefinition = (0, _find.default)(entities, matcher);
|
|
17528
17529
|
if (placement.destination.name === 'personalBoard') {
|
|
17529
17530
|
return {
|
|
17530
|
-
|
|
17531
|
+
moveType: 'ForEach',
|
|
17531
17532
|
arguments: {
|
|
17532
17533
|
targets: {
|
|
17533
17534
|
type: 'ctxPath',
|
|
@@ -17535,7 +17536,7 @@ function expandInitialPlacements(rules, entities) {
|
|
|
17535
17536
|
}
|
|
17536
17537
|
},
|
|
17537
17538
|
move: {
|
|
17538
|
-
|
|
17539
|
+
moveType: 'PlaceNew',
|
|
17539
17540
|
entity: {
|
|
17540
17541
|
state,
|
|
17541
17542
|
conditions: [{
|
|
@@ -17569,7 +17570,7 @@ function expandInitialPlacements(rules, entities) {
|
|
|
17569
17570
|
};
|
|
17570
17571
|
} else {
|
|
17571
17572
|
return {
|
|
17572
|
-
|
|
17573
|
+
moveType: 'PlaceNew',
|
|
17573
17574
|
entity: {
|
|
17574
17575
|
state,
|
|
17575
17576
|
conditions: [{
|
|
@@ -17593,7 +17594,7 @@ function expandInitialPlacements(rules, entities) {
|
|
|
17593
17594
|
delete rules.initialPlacements;
|
|
17594
17595
|
}
|
|
17595
17596
|
}
|
|
17596
|
-
const keyMappings = [
|
|
17597
|
+
const keyMappings = [];
|
|
17597
17598
|
const simpleReplacements = [['isCurrentPlayer', {
|
|
17598
17599
|
conditionType: 'Is',
|
|
17599
17600
|
matcher: {
|
|
@@ -18105,7 +18106,7 @@ function revivePayload(serializablePayload, G) {
|
|
|
18105
18106
|
}
|
|
18106
18107
|
}
|
|
18107
18108
|
function getMoveInstance(moveRule) {
|
|
18108
|
-
switch (moveRule.
|
|
18109
|
+
switch (moveRule.moveType) {
|
|
18109
18110
|
case 'MoveEntity':
|
|
18110
18111
|
return new _moveEntity.default(moveRule);
|
|
18111
18112
|
case 'PlaceNew':
|
|
@@ -18563,7 +18564,7 @@ class SpaceGroup extends _entity.default {
|
|
|
18563
18564
|
}
|
|
18564
18565
|
makeSpaces(bank) {
|
|
18565
18566
|
return Array(this.getSpacesCount()).fill().map((_, i) => bank.createEntity({
|
|
18566
|
-
|
|
18567
|
+
entityType: 'Space',
|
|
18567
18568
|
index: i
|
|
18568
18569
|
}));
|
|
18569
18570
|
}
|
|
@@ -19071,7 +19072,7 @@ const argNamesMap = {
|
|
|
19071
19072
|
|
|
19072
19073
|
// this might not be where special handling for setstate wants to live
|
|
19073
19074
|
function getSteps(bgioState, moveRule) {
|
|
19074
|
-
return argNamesMap[moveRule.
|
|
19075
|
+
return argNamesMap[moveRule.moveType].filter(argName => moveRule.arguments[argName].playerChoice).map(argName => ({
|
|
19075
19076
|
argName,
|
|
19076
19077
|
getClickable: argName === 'state' ? () => moveRule.arguments[argName].possibleValues.map(value => ({
|
|
19077
19078
|
abstract: true,
|
|
@@ -20418,7 +20419,7 @@ module.exports = ListCache;
|
|
|
20418
20419
|
|
|
20419
20420
|
/***/ },
|
|
20420
20421
|
|
|
20421
|
-
/***/
|
|
20422
|
+
/***/ 8223
|
|
20422
20423
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
20423
20424
|
|
|
20424
20425
|
var getNative = __webpack_require__(6110),
|
|
@@ -23468,7 +23469,7 @@ module.exports = getSymbolsIn;
|
|
|
23468
23469
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
23469
23470
|
|
|
23470
23471
|
var DataView = __webpack_require__(5580),
|
|
23471
|
-
Map = __webpack_require__(
|
|
23472
|
+
Map = __webpack_require__(8223),
|
|
23472
23473
|
Promise = __webpack_require__(2804),
|
|
23473
23474
|
Set = __webpack_require__(6545),
|
|
23474
23475
|
WeakMap = __webpack_require__(8303),
|
|
@@ -24257,7 +24258,7 @@ module.exports = listCacheSet;
|
|
|
24257
24258
|
|
|
24258
24259
|
var Hash = __webpack_require__(1549),
|
|
24259
24260
|
ListCache = __webpack_require__(79),
|
|
24260
|
-
Map = __webpack_require__(
|
|
24261
|
+
Map = __webpack_require__(8223);
|
|
24261
24262
|
|
|
24262
24263
|
/**
|
|
24263
24264
|
* Removes all key-value entries from the map.
|
|
@@ -24896,7 +24897,7 @@ module.exports = stackHas;
|
|
|
24896
24897
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
24897
24898
|
|
|
24898
24899
|
var ListCache = __webpack_require__(79),
|
|
24899
|
-
Map = __webpack_require__(
|
|
24900
|
+
Map = __webpack_require__(8223),
|
|
24900
24901
|
MapCache = __webpack_require__(3661);
|
|
24901
24902
|
|
|
24902
24903
|
/** Used as the size to enable large array optimizations. */
|
|
@@ -28818,9 +28819,9 @@ function createCookieJar() { }
|
|
|
28818
28819
|
|
|
28819
28820
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
28820
28821
|
exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = exports.Socket = void 0;
|
|
28821
|
-
const socket_js_1 = __webpack_require__(
|
|
28822
|
+
const socket_js_1 = __webpack_require__(604);
|
|
28822
28823
|
Object.defineProperty(exports, "Socket", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));
|
|
28823
|
-
var socket_js_2 = __webpack_require__(
|
|
28824
|
+
var socket_js_2 = __webpack_require__(604);
|
|
28824
28825
|
Object.defineProperty(exports, "SocketWithoutUpgrade", ({ enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } }));
|
|
28825
28826
|
Object.defineProperty(exports, "SocketWithUpgrade", ({ enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } }));
|
|
28826
28827
|
exports.protocol = socket_js_1.Socket.protocol;
|
|
@@ -28851,7 +28852,7 @@ Object.defineProperty(exports, "WebTransport", ({ enumerable: true, get: functio
|
|
|
28851
28852
|
|
|
28852
28853
|
/***/ },
|
|
28853
28854
|
|
|
28854
|
-
/***/
|
|
28855
|
+
/***/ 604
|
|
28855
28856
|
(__unused_webpack_module, exports, __webpack_require__) {
|
|
28856
28857
|
|
|
28857
28858
|
"use strict";
|
|
@@ -35613,8 +35614,8 @@ Object.defineProperty(exports, "gameFactory", ({
|
|
|
35613
35614
|
return _gameFactory.default;
|
|
35614
35615
|
}
|
|
35615
35616
|
}));
|
|
35616
|
-
var _client = __webpack_require__(4245);
|
|
35617
35617
|
var _gameFactory = _interopRequireDefault(__webpack_require__(4913));
|
|
35618
|
+
var _client = __webpack_require__(4245);
|
|
35618
35619
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
35619
35620
|
})();
|
|
35620
35621
|
|