board-game-engine-react 0.0.17 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "board-game-engine-react",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "React library for using board-game-engine",
5
5
  "main": "dist/board-game-engine-react.js",
6
6
  "scripts": {
@@ -3,9 +3,15 @@ import { useGame } from "../../contexts/game-context.js";
3
3
  import Grid from '../board/grid.js'
4
4
  import Space from "../space/space.js";
5
5
 
6
+ function sameEntity (a, b) {
7
+ const idA = a.entityId ?? a.attributes?.entityId
8
+ const idB = b.entityId ?? b.attributes?.entityId
9
+ return idA != null && idB != null && idA === idB
10
+ }
11
+
6
12
  export default function Entity ({ entity }) {
7
13
  const { clickTarget, allClickable } = useGame()
8
- const isClickable = allClickable.has(entity)
14
+ const isClickable = [...allClickable].some(c => sameEntity(c, entity))
9
15
  const attributes = entity.attributes
10
16
  const entityType = attributes.entityType ?? attributes.type
11
17
 
@@ -25,7 +31,7 @@ export default function Entity ({ entity }) {
25
31
  className={[
26
32
  'entity',
27
33
  attributes.player && `player-${attributes.player}`,
28
- allClickable.has(entity) && 'entity--clickable',
34
+ isClickable && 'entity--clickable',
29
35
  ].filter(Boolean).join(' ')}
30
36
  >
31
37
  {entity.rule.displayProperties?.map((property, i) => (
@@ -5,6 +5,7 @@ import GameStatus from '../game-status/game-status.js'
5
5
  import { GameProvider } from "../../contexts/game-context.js";
6
6
 
7
7
  export default function Game ({ gameConnection, loading, isSpectator }) {
8
+ console.log('gameConnection?.getState?.()', gameConnection?.getState?.())
8
9
  const G = gameConnection?.getState?.().state.G
9
10
 
10
11
  return G