@scriptonita/chess-football-ui 0.2.0 → 0.3.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/{chunk-J2TBQPPC.cjs → chunk-LTFNSTAQ.cjs} +6 -36
- package/dist/chunk-LTFNSTAQ.cjs.map +1 -0
- package/dist/{chunk-YLNDQ4HG.js → chunk-N24LGLLO.js} +4 -36
- package/dist/chunk-N24LGLLO.js.map +1 -0
- package/dist/index.cjs +13 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/store.cjs +3 -3
- package/dist/store.d.cts +3 -6
- package/dist/store.d.ts +3 -6
- package/dist/store.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-J2TBQPPC.cjs.map +0 -1
- package/dist/chunk-YLNDQ4HG.js.map +0 -1
|
@@ -4,39 +4,6 @@ var zustand = require('zustand');
|
|
|
4
4
|
var chessFootballEngine = require('@scriptonita/chess-football-engine');
|
|
5
5
|
|
|
6
6
|
// src/store/use-game-store.ts
|
|
7
|
-
var getInitialBoardState = (servingSide, currentScore = { white: 0, black: 0 }, maxActionPoints = 5) => {
|
|
8
|
-
const pieces = [];
|
|
9
|
-
const addPiece = (type, side, x, y) => {
|
|
10
|
-
pieces.push({ id: `${side}_${type}_${x}_${y}`, type, side, pos: { x, y }, hasMovedThisTurn: false });
|
|
11
|
-
};
|
|
12
|
-
addPiece("rook", "white", 0, 1);
|
|
13
|
-
addPiece("rook", "white", 8, 1);
|
|
14
|
-
addPiece("bishop", "white", 3, 2);
|
|
15
|
-
addPiece("bishop", "white", 5, 2);
|
|
16
|
-
addPiece("king", "white", 4, 1);
|
|
17
|
-
addPiece("queen", "white", 4, 5);
|
|
18
|
-
addPiece("knight", "white", 2, 4);
|
|
19
|
-
addPiece("knight", "white", 6, 4);
|
|
20
|
-
addPiece("rook", "black", 0, 10);
|
|
21
|
-
addPiece("rook", "black", 8, 10);
|
|
22
|
-
addPiece("bishop", "black", 3, 9);
|
|
23
|
-
addPiece("bishop", "black", 5, 9);
|
|
24
|
-
addPiece("king", "black", 4, 10);
|
|
25
|
-
addPiece("queen", "black", 4, 6);
|
|
26
|
-
addPiece("knight", "black", 2, 7);
|
|
27
|
-
addPiece("knight", "black", 6, 7);
|
|
28
|
-
const servingQueen = pieces.find((p) => p.side === servingSide && p.type === "queen");
|
|
29
|
-
return {
|
|
30
|
-
pieces,
|
|
31
|
-
ball: { pos: { ...servingQueen.pos }, holderId: servingQueen.id },
|
|
32
|
-
score: currentScore,
|
|
33
|
-
actionPoints: maxActionPoints,
|
|
34
|
-
maxActionPoints,
|
|
35
|
-
turn: servingSide,
|
|
36
|
-
moveHistory: [],
|
|
37
|
-
turnNumber: 1
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
7
|
var useGameStore = zustand.create((set) => ({
|
|
41
8
|
boardState: null,
|
|
42
9
|
selectedPieceId: null,
|
|
@@ -79,7 +46,10 @@ var useGameStore = zustand.create((set) => ({
|
|
|
79
46
|
})
|
|
80
47
|
}));
|
|
81
48
|
|
|
82
|
-
exports
|
|
49
|
+
Object.defineProperty(exports, "getInitialBoardState", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () { return chessFootballEngine.getInitialBoardState; }
|
|
52
|
+
});
|
|
83
53
|
exports.useGameStore = useGameStore;
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-LTFNSTAQ.cjs.map
|
|
55
|
+
//# sourceMappingURL=chunk-LTFNSTAQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/store/use-game-store.ts"],"names":["create","applyMove","applyPass","applyEndTurn"],"mappings":";;;;;;AAqBO,IAAM,YAAA,GAAeA,cAAA,CAAkB,CAAC,GAAA,MAAS;AAAA,EACpD,UAAA,EAAY,IAAA;AAAA,EACZ,eAAA,EAAiB,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,EAAM,iBAAiB,IAAA,EAAK;AAAA,EACtE,CAAC,CAAA;AAAA,EAED,QAAA,EAAU,CAAC,EAAA,KAAO,GAAA,CAAI,CAAC,KAAA,KAAU;AAC7B,IAAA,IAAI,CAAC,KAAA,CAAM,UAAA,IAAc,KAAA,CAAM,UAAA,CAAW,YAAA,IAAgB,CAAA,IAAK,CAAC,KAAA,CAAM,UAAA,CAAW,IAAA,CAAK,QAAA,EAAU,OAAO,KAAA;AACvG,IAAA,MAAM,MAAA,GAAS,KAAA,CAAM,UAAA,CAAW,MAAA,CAAO,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,EAAA,KAAO,KAAA,CAAM,UAAA,CAAY,IAAA,CAAK,QAAQ,CAAA;AACzF,IAAA,IAAI,CAAC,QAAQ,OAAO,KAAA;AAEpB,IAAA,MAAM,EAAE,UAAA,EAAY,aAAA,KAAkBC,6BAAA,CAAU,KAAA,CAAM,YAAY,EAAE,CAAA;AACpE,IAAA,MAAM,aAAA,GAAgB,CAAC,aAAA,IAAiB,UAAA,CAAW,IAAA,CAAK,QAAA;AACxD,IAAA,OAAO;AAAA,MACH,UAAA;AAAA,MACA,eAAA,EAAiB,aAAA,GAAgB,UAAA,CAAW,IAAA,CAAK,QAAA,GAAW,IAAA;AAAA,MAC5D,eAAA,EAAiB,gBAAgB,MAAA,GAAS;AAAA,KAC9C;AAAA,EACJ,CAAC,CAAA;AAAA,EAED,OAAA,EAAS,MAAM,GAAA,CAAI,CAAC,KAAA,KAAU;AAC1B,IAAA,IAAI,CAAC,KAAA,CAAM,UAAA,EAAY,OAAO,KAAA;AAC9B,IAAA,OAAO,EAAE,UAAA,EAAYC,gCAAA,CAAa,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA,EACxD,CAAC;AACL,CAAA,CAAE","file":"chunk-LTFNSTAQ.cjs","sourcesContent":["import { create } from 'zustand'\nimport type { BoardState, Position } from '@scriptonita/chess-football-engine'\nimport { applyMove, applyPass, applyEndTurn } from '@scriptonita/chess-football-engine'\n\n// The canonical kickoff position lives in the engine (rules-adjacent). Re-exported\n// here so app imports from `@scriptonita/chess-football-ui/store` keep working.\nexport { getInitialBoardState } from '@scriptonita/chess-football-engine'\n\ninterface GameStore {\n boardState: BoardState | null\n selectedPieceId: string | null\n interactionMode: 'move' | 'pass' | null\n setBoardState: (state: BoardState) => void\n setSelectedPieceId: (id: string | null) => void\n setInteractionMode: (mode: 'move' | 'pass' | null) => void\n resetTurn: () => void\n movePiece: (pieceId: string, to: Position) => void\n passBall: (to: Position) => void\n endTurn: () => void\n}\n\nexport const useGameStore = create<GameStore>((set) => ({\n boardState: null,\n selectedPieceId: null,\n interactionMode: null,\n\n setBoardState: (state) => set({ boardState: state }),\n setSelectedPieceId: (id) => set({ selectedPieceId: id }),\n setInteractionMode: (mode) => set({ interactionMode: mode }),\n\n resetTurn: () => set((state) => {\n if (!state.boardState) return state\n return {\n boardState: {\n ...state.boardState,\n actionPoints: state.boardState.maxActionPoints ?? 5,\n pieces: state.boardState.pieces.map(p => ({ ...p, hasMovedThisTurn: false })),\n },\n }\n }),\n\n movePiece: (pieceId, to) => set((state) => {\n if (!state.boardState || state.boardState.actionPoints <= 0) return state\n const piece = state.boardState.pieces.find(p => p.id === pieceId)\n if (!piece || piece.hasMovedThisTurn) return state\n\n const { boardState } = applyMove(state.boardState, pieceId, to)\n return { boardState, selectedPieceId: null, interactionMode: null }\n }),\n\n passBall: (to) => set((state) => {\n if (!state.boardState || state.boardState.actionPoints <= 0 || !state.boardState.ball.holderId) return state\n const holder = state.boardState.pieces.find(p => p.id === state.boardState!.ball.holderId)\n if (!holder) return state\n\n const { boardState, forcedTurnEnd } = applyPass(state.boardState, to)\n const keepSelection = !forcedTurnEnd && boardState.ball.holderId\n return {\n boardState,\n selectedPieceId: keepSelection ? boardState.ball.holderId : null,\n interactionMode: keepSelection ? 'pass' : null,\n }\n }),\n\n endTurn: () => set((state) => {\n if (!state.boardState) return state\n return { boardState: applyEndTurn(state.boardState) }\n }),\n}))\n"]}
|
|
@@ -1,40 +1,8 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { applyEndTurn, applyPass, applyMove } from '@scriptonita/chess-football-engine';
|
|
3
|
+
export { getInitialBoardState } from '@scriptonita/chess-football-engine';
|
|
3
4
|
|
|
4
5
|
// src/store/use-game-store.ts
|
|
5
|
-
var getInitialBoardState = (servingSide, currentScore = { white: 0, black: 0 }, maxActionPoints = 5) => {
|
|
6
|
-
const pieces = [];
|
|
7
|
-
const addPiece = (type, side, x, y) => {
|
|
8
|
-
pieces.push({ id: `${side}_${type}_${x}_${y}`, type, side, pos: { x, y }, hasMovedThisTurn: false });
|
|
9
|
-
};
|
|
10
|
-
addPiece("rook", "white", 0, 1);
|
|
11
|
-
addPiece("rook", "white", 8, 1);
|
|
12
|
-
addPiece("bishop", "white", 3, 2);
|
|
13
|
-
addPiece("bishop", "white", 5, 2);
|
|
14
|
-
addPiece("king", "white", 4, 1);
|
|
15
|
-
addPiece("queen", "white", 4, 5);
|
|
16
|
-
addPiece("knight", "white", 2, 4);
|
|
17
|
-
addPiece("knight", "white", 6, 4);
|
|
18
|
-
addPiece("rook", "black", 0, 10);
|
|
19
|
-
addPiece("rook", "black", 8, 10);
|
|
20
|
-
addPiece("bishop", "black", 3, 9);
|
|
21
|
-
addPiece("bishop", "black", 5, 9);
|
|
22
|
-
addPiece("king", "black", 4, 10);
|
|
23
|
-
addPiece("queen", "black", 4, 6);
|
|
24
|
-
addPiece("knight", "black", 2, 7);
|
|
25
|
-
addPiece("knight", "black", 6, 7);
|
|
26
|
-
const servingQueen = pieces.find((p) => p.side === servingSide && p.type === "queen");
|
|
27
|
-
return {
|
|
28
|
-
pieces,
|
|
29
|
-
ball: { pos: { ...servingQueen.pos }, holderId: servingQueen.id },
|
|
30
|
-
score: currentScore,
|
|
31
|
-
actionPoints: maxActionPoints,
|
|
32
|
-
maxActionPoints,
|
|
33
|
-
turn: servingSide,
|
|
34
|
-
moveHistory: [],
|
|
35
|
-
turnNumber: 1
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
6
|
var useGameStore = create((set) => ({
|
|
39
7
|
boardState: null,
|
|
40
8
|
selectedPieceId: null,
|
|
@@ -77,6 +45,6 @@ var useGameStore = create((set) => ({
|
|
|
77
45
|
})
|
|
78
46
|
}));
|
|
79
47
|
|
|
80
|
-
export {
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
export { useGameStore };
|
|
49
|
+
//# sourceMappingURL=chunk-N24LGLLO.js.map
|
|
50
|
+
//# sourceMappingURL=chunk-N24LGLLO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/store/use-game-store.ts"],"names":[],"mappings":";;;;;AAqBO,IAAM,YAAA,GAAe,MAAA,CAAkB,CAAC,GAAA,MAAS;AAAA,EACpD,UAAA,EAAY,IAAA;AAAA,EACZ,eAAA,EAAiB,IAAA;AAAA,EACjB,eAAA,EAAiB,IAAA;AAAA,EAEjB,eAAe,CAAC,KAAA,KAAU,IAAI,EAAE,UAAA,EAAY,OAAO,CAAA;AAAA,EACnD,oBAAoB,CAAC,EAAA,KAAO,IAAI,EAAE,eAAA,EAAiB,IAAI,CAAA;AAAA,EACvD,oBAAoB,CAAC,IAAA,KAAS,IAAI,EAAE,eAAA,EAAiB,MAAM,CAAA;AAAA,EAE3D,SAAA,EAAW,MAAM,GAAA,CAAI,CAAC,KAAA,KAAU;AAC5B,IAAA,IAAI,CAAC,KAAA,CAAM,UAAA,EAAY,OAAO,KAAA;AAC9B,IAAA,OAAO;AAAA,MACH,UAAA,EAAY;AAAA,QACR,GAAG,KAAA,CAAM,UAAA;AAAA,QACT,YAAA,EAAc,KAAA,CAAM,UAAA,CAAW,eAAA,IAAmB,CAAA;AAAA,QAClD,MAAA,EAAQ,KAAA,CAAM,UAAA,CAAW,MAAA,CAAO,GAAA,CAAI,CAAA,CAAA,MAAM,EAAE,GAAG,C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,IAAiB,UAAA,CAAW,IAAA,CAAK,QAAA;AACxD,IAAA,OAAO;AAAA,MACH,UAAA;AAAA,MACA,eAAA,EAAiB,aAAA,GAAgB,UAAA,CAAW,IAAA,CAAK,QAAA,GAAW,IAAA;AAAA,MAC5D,eAAA,EAAiB,gBAAgB,MAAA,GAAS;AAAA,KAC9C;AAAA,EACJ,CAAC,CAAA;AAAA,EAED,OAAA,EAAS,MAAM,GAAA,CAAI,CAAC,KAAA,KAAU;AAC1B,IAAA,IAAI,CAAC,KAAA,CAAM,UAAA,EAAY,OAAO,KAAA;AAC9B,IAAA,OAAO,EAAE,UAAA,EAAY,YAAA,CAAa,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA,EACxD,CAAC;AACL,CAAA,CAAE","file":"chunk-N24LGLLO.js","sourcesContent":["import { create } from 'zustand'\nimport type { BoardState, Position } from '@scriptonita/chess-football-engine'\nimport { applyMove, applyPass, applyEndTurn } from '@scriptonita/chess-football-engine'\n\n// The canonical kickoff position lives in the engine (rules-adjacent). Re-exported\n// here so app imports from `@scriptonita/chess-football-ui/store` keep working.\nexport { getInitialBoardState } from '@scriptonita/chess-football-engine'\n\ninterface GameStore {\n boardState: BoardState | null\n selectedPieceId: string | null\n interactionMode: 'move' | 'pass' | null\n setBoardState: (state: BoardState) => void\n setSelectedPieceId: (id: string | null) => void\n setInteractionMode: (mode: 'move' | 'pass' | null) => void\n resetTurn: () => void\n movePiece: (pieceId: string, to: Position) => void\n passBall: (to: Position) => void\n endTurn: () => void\n}\n\nexport const useGameStore = create<GameStore>((set) => ({\n boardState: null,\n selectedPieceId: null,\n interactionMode: null,\n\n setBoardState: (state) => set({ boardState: state }),\n setSelectedPieceId: (id) => set({ selectedPieceId: id }),\n setInteractionMode: (mode) => set({ interactionMode: mode }),\n\n resetTurn: () => set((state) => {\n if (!state.boardState) return state\n return {\n boardState: {\n ...state.boardState,\n actionPoints: state.boardState.maxActionPoints ?? 5,\n pieces: state.boardState.pieces.map(p => ({ ...p, hasMovedThisTurn: false })),\n },\n }\n }),\n\n movePiece: (pieceId, to) => set((state) => {\n if (!state.boardState || state.boardState.actionPoints <= 0) return state\n const piece = state.boardState.pieces.find(p => p.id === pieceId)\n if (!piece || piece.hasMovedThisTurn) return state\n\n const { boardState } = applyMove(state.boardState, pieceId, to)\n return { boardState, selectedPieceId: null, interactionMode: null }\n }),\n\n passBall: (to) => set((state) => {\n if (!state.boardState || state.boardState.actionPoints <= 0 || !state.boardState.ball.holderId) return state\n const holder = state.boardState.pieces.find(p => p.id === state.boardState!.ball.holderId)\n if (!holder) return state\n\n const { boardState, forcedTurnEnd } = applyPass(state.boardState, to)\n const keepSelection = !forcedTurnEnd && boardState.ball.holderId\n return {\n boardState,\n selectedPieceId: keepSelection ? boardState.ball.holderId : null,\n interactionMode: keepSelection ? 'pass' : null,\n }\n }),\n\n endTurn: () => set((state) => {\n if (!state.boardState) return state\n return { boardState: applyEndTurn(state.boardState) }\n }),\n}))\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkLTFNSTAQ_cjs = require('./chunk-LTFNSTAQ.cjs');
|
|
4
4
|
var chessFootballEngine = require('@scriptonita/chess-football-engine');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var tailwindMerge = require('tailwind-merge');
|
|
@@ -93,14 +93,6 @@ function GamePiece({ piece, isSelected, hasBall, onClick }) {
|
|
|
93
93
|
children: [
|
|
94
94
|
/* @__PURE__ */ jsxRuntime.jsx(PieceIcon, { type: piece.type, side: piece.side }),
|
|
95
95
|
hasBall && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 rounded-full ring-2 ring-orange-400 pointer-events-none" }),
|
|
96
|
-
piece.hasMovedThisTurn && /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
-
"span",
|
|
98
|
-
{
|
|
99
|
-
"aria-hidden": "true",
|
|
100
|
-
className: "absolute top-0.5 right-0.5 w-[14px] h-[14px] rounded-full bg-fg-muted/80 flex items-center justify-center text-[9px] text-bg-primary font-bold leading-none pointer-events-none",
|
|
101
|
-
children: "\u2713"
|
|
102
|
-
}
|
|
103
|
-
),
|
|
104
96
|
isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 rounded-full animate-pulse ring-2 ring-yellow-400 ring-offset-2 ring-offset-transparent" })
|
|
105
97
|
]
|
|
106
98
|
}
|
|
@@ -174,7 +166,7 @@ function GameBoard({ userSide, showCoordinates = false, keyboardNav = true }) {
|
|
|
174
166
|
setInteractionMode,
|
|
175
167
|
movePiece,
|
|
176
168
|
passBall
|
|
177
|
-
} =
|
|
169
|
+
} = chunkLTFNSTAQ_cjs.useGameStore();
|
|
178
170
|
const [cursor, setCursor] = React.useState(null);
|
|
179
171
|
const [disambiguateAt, setDisambiguateAt] = React.useState(null);
|
|
180
172
|
const prevBallRef = React.useRef(boardState?.ball);
|
|
@@ -220,6 +212,7 @@ function GameBoard({ userSide, showCoordinates = false, keyboardNav = true }) {
|
|
|
220
212
|
const ballCarrier = ball.holderId ? boardState.pieces.find((p) => p.id === ball.holderId) ?? null : null;
|
|
221
213
|
const isOffsideRisk = !!ballCarrier && ballCarrier.type !== "king" && userSide !== null && ballCarrier.side === userSide && boardState.turn === userSide && chessFootballEngine.isInEnemyArea(ballCarrier.pos, ballCarrier.side);
|
|
222
214
|
const handleSquareClick = (x, y) => {
|
|
215
|
+
setCursor(null);
|
|
223
216
|
const isValidMove = validMoves.some((m) => m.x === x && m.y === y);
|
|
224
217
|
const isValidPass = validPasses.some((p) => p.x === x && p.y === y);
|
|
225
218
|
if (isValidMove && isValidPass) {
|
|
@@ -421,8 +414,7 @@ function GameBoard({ userSide, showCoordinates = false, keyboardNav = true }) {
|
|
|
421
414
|
tabIndex: 0,
|
|
422
415
|
role: "application",
|
|
423
416
|
"aria-label": "Game board \u2014 arrow keys to move the cursor, Enter to act",
|
|
424
|
-
onKeyDown: handleKeyDown
|
|
425
|
-
onFocus: () => setCursor((c) => c ?? defaultCursor())
|
|
417
|
+
onKeyDown: handleKeyDown
|
|
426
418
|
} : {},
|
|
427
419
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", style: { containerType: "inline-size" }, children: [
|
|
428
420
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-9 gap-[1px]", children: renderSquares() }),
|
|
@@ -607,7 +599,7 @@ function Scoreboard({
|
|
|
607
599
|
userSide
|
|
608
600
|
}) {
|
|
609
601
|
const t = useGameT();
|
|
610
|
-
const { boardState } =
|
|
602
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
611
603
|
if (!boardState?.score) return null;
|
|
612
604
|
const { score, turn, actionPoints, kingMustRelease } = boardState;
|
|
613
605
|
const myScore = userSide === "white" ? score.white : score.black;
|
|
@@ -694,7 +686,7 @@ function MiniScoreboard({
|
|
|
694
686
|
className
|
|
695
687
|
}) {
|
|
696
688
|
const t = useGameT();
|
|
697
|
-
const { boardState } =
|
|
689
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
698
690
|
if (!boardState?.score) return null;
|
|
699
691
|
const { score, turn } = boardState;
|
|
700
692
|
const myScore = userSide === "white" ? score.white : score.black;
|
|
@@ -799,7 +791,7 @@ function GameControls({ isMyTurn }) {
|
|
|
799
791
|
const {
|
|
800
792
|
boardState,
|
|
801
793
|
endTurn
|
|
802
|
-
} =
|
|
794
|
+
} = chunkLTFNSTAQ_cjs.useGameStore();
|
|
803
795
|
const t = useGameT();
|
|
804
796
|
const [showEndTurnConfirm, setShowEndTurnConfirm] = React.useState(false);
|
|
805
797
|
if (!boardState) return null;
|
|
@@ -858,7 +850,7 @@ var PIECE_ICON2 = {
|
|
|
858
850
|
};
|
|
859
851
|
function SelectedPieceDetail({ isMyTurn, className }) {
|
|
860
852
|
const t = useGameT();
|
|
861
|
-
const { boardState, selectedPieceId } =
|
|
853
|
+
const { boardState, selectedPieceId } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
862
854
|
if (!boardState) return null;
|
|
863
855
|
const piece = boardState.pieces.find((p) => p.id === selectedPieceId);
|
|
864
856
|
if (!piece) {
|
|
@@ -921,7 +913,7 @@ function SelectedPieceDetail({ isMyTurn, className }) {
|
|
|
921
913
|
}
|
|
922
914
|
function MoveHistory({ scrollable = true, limit, className }) {
|
|
923
915
|
const t = useGameT();
|
|
924
|
-
const { boardState } =
|
|
916
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
925
917
|
const scrollRef = React.useRef(null);
|
|
926
918
|
const history = boardState?.moveHistory ?? [];
|
|
927
919
|
const visible = limit ? history.slice(-limit) : history;
|
|
@@ -1029,7 +1021,7 @@ function HistoryRow({ entry, isLatest }) {
|
|
|
1029
1021
|
var COLS2 = 9;
|
|
1030
1022
|
var ROWS2 = 12;
|
|
1031
1023
|
function StaticGameBoard() {
|
|
1032
|
-
const boardState = React.useMemo(() =>
|
|
1024
|
+
const boardState = React.useMemo(() => chunkLTFNSTAQ_cjs.getInitialBoardState("white"), []);
|
|
1033
1025
|
const renderSquares = () => {
|
|
1034
1026
|
const squares = [];
|
|
1035
1027
|
for (let y = ROWS2 - 1; y >= 0; y--) {
|
|
@@ -1120,7 +1112,7 @@ function StaticGameBoard() {
|
|
|
1120
1112
|
}
|
|
1121
1113
|
function TurnBanner({ isMyTurn, waitingLabel, className }) {
|
|
1122
1114
|
const t = useGameT();
|
|
1123
|
-
const { boardState } =
|
|
1115
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
1124
1116
|
if (!boardState) return null;
|
|
1125
1117
|
const { actionPoints, maxActionPoints } = boardState;
|
|
1126
1118
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1164,7 +1156,7 @@ var TOAST_CONFIG = {
|
|
|
1164
1156
|
};
|
|
1165
1157
|
function EventToast({ className }) {
|
|
1166
1158
|
const t = useGameT();
|
|
1167
|
-
const { boardState } =
|
|
1159
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
1168
1160
|
const [toast, setToast] = React.useState(null);
|
|
1169
1161
|
React.useEffect(() => {
|
|
1170
1162
|
const lastMove = boardState?.lastMove;
|
|
@@ -1203,7 +1195,7 @@ function EventToast({ className }) {
|
|
|
1203
1195
|
);
|
|
1204
1196
|
}
|
|
1205
1197
|
function MobileHistory({ className }) {
|
|
1206
|
-
const { boardState } =
|
|
1198
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
1207
1199
|
const [open, setOpen] = React.useState(false);
|
|
1208
1200
|
const lastMove = boardState?.moveHistory?.at(-1);
|
|
1209
1201
|
if (!lastMove) return null;
|