board-game-engine-react 0.0.16 → 0.0.18
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/.nycrc.json +8 -0
- package/babel.config.js +6 -1
- package/dist/board-game-engine-react.js +10 -3
- package/dist/board-game-engine-react.min.js +1 -1
- package/e2e/coverage.js +28 -0
- package/e2e/harness.spec.js +73 -0
- package/examples/checkers.json +793 -0
- package/examples/connect-four.json +126 -0
- package/examples/eights.json +653 -0
- package/examples/reversi.json +215 -0
- package/examples/tic-tac-toe.json +53 -0
- package/package.json +15 -3
- package/playwright.config.cjs +23 -0
- package/src/components/entity/entity.js +10 -3
- package/src/components/game/game.js +1 -0
- package/test-app/index.html +25 -0
- package/test-app/main.jsx +101 -0
- package/test-app/public/games/checkers.json +793 -0
- package/test-app/public/games/connect-four.json +126 -0
- package/test-app/public/games/eights.json +653 -0
- package/test-app/public/games/reversi.json +215 -0
- package/test-app/public/games/tic-tac-toe.json +53 -0
- package/vite.harness.config.js +16 -0
package/.nycrc.json
ADDED
package/babel.config.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
const coverage = process.env.COVERAGE === '1'
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
presets: [
|
|
3
5
|
'@babel/preset-react',
|
|
4
6
|
['@babel/preset-env', { targets: { node: 'current' } }]
|
|
5
7
|
],
|
|
6
8
|
plugins: [
|
|
7
|
-
'@babel/plugin-proposal-object-rest-spread'
|
|
9
|
+
'@babel/plugin-proposal-object-rest-spread',
|
|
10
|
+
...(coverage
|
|
11
|
+
? [['istanbul', { include: ['src/**/*.js'], exclude: ['**/*.spec.js', '**/node_modules/**', 'e2e/**'] }]]
|
|
12
|
+
: [])
|
|
8
13
|
]
|
|
9
14
|
}
|
|
@@ -5651,6 +5651,11 @@ function Space({
|
|
|
5651
5651
|
}))), !entities.length && space.attributes.name));
|
|
5652
5652
|
}
|
|
5653
5653
|
|
|
5654
|
+
function sameEntity(a, b) {
|
|
5655
|
+
const idA = a.entityId ?? a.attributes?.entityId;
|
|
5656
|
+
const idB = b.entityId ?? b.attributes?.entityId;
|
|
5657
|
+
return idA != null && idB != null && idA === idB;
|
|
5658
|
+
}
|
|
5654
5659
|
function Entity({
|
|
5655
5660
|
entity
|
|
5656
5661
|
}) {
|
|
@@ -5658,9 +5663,10 @@ function Entity({
|
|
|
5658
5663
|
clickTarget,
|
|
5659
5664
|
allClickable
|
|
5660
5665
|
} = useGame();
|
|
5661
|
-
const isClickable = allClickable.
|
|
5666
|
+
const isClickable = [...allClickable].some(c => sameEntity(c, entity));
|
|
5662
5667
|
const attributes = entity.attributes;
|
|
5663
|
-
|
|
5668
|
+
const entityType = attributes.entityType ?? attributes.type;
|
|
5669
|
+
switch (entityType) {
|
|
5664
5670
|
case 'Grid':
|
|
5665
5671
|
return /*#__PURE__*/React.createElement(Grid, {
|
|
5666
5672
|
grid: entity,
|
|
@@ -5679,7 +5685,7 @@ function Entity({
|
|
|
5679
5685
|
clickTarget(entity);
|
|
5680
5686
|
}
|
|
5681
5687
|
},
|
|
5682
|
-
className: ['entity', attributes.player && `player-${attributes.player}`,
|
|
5688
|
+
className: ['entity', attributes.player && `player-${attributes.player}`, isClickable && 'entity--clickable'].filter(Boolean).join(' ')
|
|
5683
5689
|
}, entity.rule.displayProperties?.map((property, i) => /*#__PURE__*/React.createElement("div", {
|
|
5684
5690
|
key: i
|
|
5685
5691
|
}, property, ": ", entity.attributes[property]?.toString())));
|
|
@@ -5746,6 +5752,7 @@ function Game({
|
|
|
5746
5752
|
loading,
|
|
5747
5753
|
isSpectator
|
|
5748
5754
|
}) {
|
|
5755
|
+
console.log('gameConnection?.getState?.()', gameConnection?.getState?.());
|
|
5749
5756
|
const G = gameConnection?.getState?.().state.G;
|
|
5750
5757
|
return G ? /*#__PURE__*/React.createElement(GameProvider, {
|
|
5751
5758
|
gameConnection: gameConnection,
|