@scriptonita/chess-football-ui 0.2.1 → 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 +11 -11
- package/dist/index.js +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,IAAA;AAAA,EACjB,eAAA,EAAiB,IAAA;AAAA,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C,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,CAAA,EAAG,gBAAA,EAAkB,KAAA,EAAM,CAAE;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,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');
|
|
@@ -166,7 +166,7 @@ function GameBoard({ userSide, showCoordinates = false, keyboardNav = true }) {
|
|
|
166
166
|
setInteractionMode,
|
|
167
167
|
movePiece,
|
|
168
168
|
passBall
|
|
169
|
-
} =
|
|
169
|
+
} = chunkLTFNSTAQ_cjs.useGameStore();
|
|
170
170
|
const [cursor, setCursor] = React.useState(null);
|
|
171
171
|
const [disambiguateAt, setDisambiguateAt] = React.useState(null);
|
|
172
172
|
const prevBallRef = React.useRef(boardState?.ball);
|
|
@@ -599,7 +599,7 @@ function Scoreboard({
|
|
|
599
599
|
userSide
|
|
600
600
|
}) {
|
|
601
601
|
const t = useGameT();
|
|
602
|
-
const { boardState } =
|
|
602
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
603
603
|
if (!boardState?.score) return null;
|
|
604
604
|
const { score, turn, actionPoints, kingMustRelease } = boardState;
|
|
605
605
|
const myScore = userSide === "white" ? score.white : score.black;
|
|
@@ -686,7 +686,7 @@ function MiniScoreboard({
|
|
|
686
686
|
className
|
|
687
687
|
}) {
|
|
688
688
|
const t = useGameT();
|
|
689
|
-
const { boardState } =
|
|
689
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
690
690
|
if (!boardState?.score) return null;
|
|
691
691
|
const { score, turn } = boardState;
|
|
692
692
|
const myScore = userSide === "white" ? score.white : score.black;
|
|
@@ -791,7 +791,7 @@ function GameControls({ isMyTurn }) {
|
|
|
791
791
|
const {
|
|
792
792
|
boardState,
|
|
793
793
|
endTurn
|
|
794
|
-
} =
|
|
794
|
+
} = chunkLTFNSTAQ_cjs.useGameStore();
|
|
795
795
|
const t = useGameT();
|
|
796
796
|
const [showEndTurnConfirm, setShowEndTurnConfirm] = React.useState(false);
|
|
797
797
|
if (!boardState) return null;
|
|
@@ -850,7 +850,7 @@ var PIECE_ICON2 = {
|
|
|
850
850
|
};
|
|
851
851
|
function SelectedPieceDetail({ isMyTurn, className }) {
|
|
852
852
|
const t = useGameT();
|
|
853
|
-
const { boardState, selectedPieceId } =
|
|
853
|
+
const { boardState, selectedPieceId } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
854
854
|
if (!boardState) return null;
|
|
855
855
|
const piece = boardState.pieces.find((p) => p.id === selectedPieceId);
|
|
856
856
|
if (!piece) {
|
|
@@ -913,7 +913,7 @@ function SelectedPieceDetail({ isMyTurn, className }) {
|
|
|
913
913
|
}
|
|
914
914
|
function MoveHistory({ scrollable = true, limit, className }) {
|
|
915
915
|
const t = useGameT();
|
|
916
|
-
const { boardState } =
|
|
916
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
917
917
|
const scrollRef = React.useRef(null);
|
|
918
918
|
const history = boardState?.moveHistory ?? [];
|
|
919
919
|
const visible = limit ? history.slice(-limit) : history;
|
|
@@ -1021,7 +1021,7 @@ function HistoryRow({ entry, isLatest }) {
|
|
|
1021
1021
|
var COLS2 = 9;
|
|
1022
1022
|
var ROWS2 = 12;
|
|
1023
1023
|
function StaticGameBoard() {
|
|
1024
|
-
const boardState = React.useMemo(() =>
|
|
1024
|
+
const boardState = React.useMemo(() => chunkLTFNSTAQ_cjs.getInitialBoardState("white"), []);
|
|
1025
1025
|
const renderSquares = () => {
|
|
1026
1026
|
const squares = [];
|
|
1027
1027
|
for (let y = ROWS2 - 1; y >= 0; y--) {
|
|
@@ -1112,7 +1112,7 @@ function StaticGameBoard() {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
function TurnBanner({ isMyTurn, waitingLabel, className }) {
|
|
1114
1114
|
const t = useGameT();
|
|
1115
|
-
const { boardState } =
|
|
1115
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
1116
1116
|
if (!boardState) return null;
|
|
1117
1117
|
const { actionPoints, maxActionPoints } = boardState;
|
|
1118
1118
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1156,7 +1156,7 @@ var TOAST_CONFIG = {
|
|
|
1156
1156
|
};
|
|
1157
1157
|
function EventToast({ className }) {
|
|
1158
1158
|
const t = useGameT();
|
|
1159
|
-
const { boardState } =
|
|
1159
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
1160
1160
|
const [toast, setToast] = React.useState(null);
|
|
1161
1161
|
React.useEffect(() => {
|
|
1162
1162
|
const lastMove = boardState?.lastMove;
|
|
@@ -1195,7 +1195,7 @@ function EventToast({ className }) {
|
|
|
1195
1195
|
);
|
|
1196
1196
|
}
|
|
1197
1197
|
function MobileHistory({ className }) {
|
|
1198
|
-
const { boardState } =
|
|
1198
|
+
const { boardState } = chunkLTFNSTAQ_cjs.useGameStore();
|
|
1199
1199
|
const [open, setOpen] = React.useState(false);
|
|
1200
1200
|
const lastMove = boardState?.moveHistory?.at(-1);
|
|
1201
1201
|
if (!lastMove) return null;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useGameStore, getInitialBoardState } from './chunk-
|
|
1
|
+
import { useGameStore, getInitialBoardState } from './chunk-N24LGLLO.js';
|
|
2
2
|
import { getValidMoves, getValidPasses, isInEnemyArea, RANK_LABELS, FILE_LABELS, LONG_KEY, squareName, SHORT_KEY } from '@scriptonita/chess-football-engine';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
package/dist/store.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkLTFNSTAQ_cjs = require('./chunk-LTFNSTAQ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "getInitialBoardState", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkLTFNSTAQ_cjs.getInitialBoardState; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "useGameStore", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkLTFNSTAQ_cjs.useGameStore; }
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=store.cjs.map
|
|
16
16
|
//# sourceMappingURL=store.cjs.map
|
package/dist/store.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
|
-
import {
|
|
2
|
+
import { BoardState, Position } from '@scriptonita/chess-football-engine';
|
|
3
|
+
export { getInitialBoardState } from '@scriptonita/chess-football-engine';
|
|
3
4
|
|
|
4
5
|
interface GameStore {
|
|
5
6
|
boardState: BoardState | null;
|
|
@@ -13,10 +14,6 @@ interface GameStore {
|
|
|
13
14
|
passBall: (to: Position) => void;
|
|
14
15
|
endTurn: () => void;
|
|
15
16
|
}
|
|
16
|
-
declare const getInitialBoardState: (servingSide: Side, currentScore?: {
|
|
17
|
-
white: number;
|
|
18
|
-
black: number;
|
|
19
|
-
}, maxActionPoints?: number) => BoardState;
|
|
20
17
|
declare const useGameStore: zustand.UseBoundStore<zustand.StoreApi<GameStore>>;
|
|
21
18
|
|
|
22
|
-
export {
|
|
19
|
+
export { useGameStore };
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
|
-
import {
|
|
2
|
+
import { BoardState, Position } from '@scriptonita/chess-football-engine';
|
|
3
|
+
export { getInitialBoardState } from '@scriptonita/chess-football-engine';
|
|
3
4
|
|
|
4
5
|
interface GameStore {
|
|
5
6
|
boardState: BoardState | null;
|
|
@@ -13,10 +14,6 @@ interface GameStore {
|
|
|
13
14
|
passBall: (to: Position) => void;
|
|
14
15
|
endTurn: () => void;
|
|
15
16
|
}
|
|
16
|
-
declare const getInitialBoardState: (servingSide: Side, currentScore?: {
|
|
17
|
-
white: number;
|
|
18
|
-
black: number;
|
|
19
|
-
}, maxActionPoints?: number) => BoardState;
|
|
20
17
|
declare const useGameStore: zustand.UseBoundStore<zustand.StoreApi<GameStore>>;
|
|
21
18
|
|
|
22
|
-
export {
|
|
19
|
+
export { useGameStore };
|
package/dist/store.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scriptonita/chess-football-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Shared, framework-agnostic React UI for Chess.Football: board, pieces, scoreboard, controls and the game store. Consumed by the Next.js app and the CrazyGames Vite SPA.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@scriptonita/chess-football-engine": "^0.
|
|
40
|
+
"@scriptonita/chess-football-engine": "^0.5.0",
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"tailwind-merge": "^3.3.0",
|
|
43
43
|
"zustand": "^5.0.9"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store/use-game-store.ts"],"names":["create","applyMove","applyPass","applyEndTurn"],"mappings":";;;;;;AAiBO,IAAM,oBAAA,GAAuB,CAAC,WAAA,EAAmB,YAAA,GAAe,EAAE,KAAA,EAAO,CAAA,EAAG,KAAA,EAAO,CAAA,EAAE,EAAG,eAAA,GAAkB,CAAA,KAAkB;AAC/H,EAAA,MAAM,SAAkB,EAAC;AAEzB,EAAA,MAAM,QAAA,GAAW,CAAC,IAAA,EAAiB,IAAA,EAAY,GAAW,CAAA,KAAc;AACpE,IAAA,MAAA,CAAO,IAAA,CAAK,EAAE,EAAA,EAAI,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,IAAI,IAAI,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,IAAA,EAAM,MAAM,GAAA,EAAK,EAAE,GAAG,CAAA,EAAE,EAAG,gBAAA,EAAkB,KAAA,EAAO,CAAA;AAAA,EACvG,CAAA;AAIA,EAAA,QAAA,CAAS,MAAA,EAAU,OAAA,EAAS,CAAA,EAAG,CAAC,CAAA;AAChC,EAAA,QAAA,CAAS,MAAA,EAAU,OAAA,EAAS,CAAA,EAAG,CAAC,CAAA;AAChC,EAAA,QAAA,CAAS,QAAA,EAAU,OAAA,EAAS,CAAA,EAAG,CAAC,CAAA;AAChC,EAAA,QAAA,CAAS,QAAA,EAAU,OAAA,EAAS,CAAA,EAAG,CAAC,CAAA;AAChC,EAAA,QAAA,CAAS,MAAA,EAAU,OAAA,EAAS,CAAA,EAAG,CAAC,CAAA;AAChC,EAAA,QAAA,CAAS,OAAA,EAAU,OAA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{ create } from 'zustand'\nimport type { BoardState, Piece, Side, Position, PieceType } from '@scriptonita/chess-football-engine'\nimport { applyMove, applyPass, applyEndTurn } 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 getInitialBoardState = (servingSide: Side, currentScore = { white: 0, black: 0 }, maxActionPoints = 5): BoardState => {\n const pieces: Piece[] = []\n\n const addPiece = (type: PieceType, side: Side, x: number, y: number) => {\n pieces.push({ id: `${side}_${type}_${x}_${y}`, type, side, pos: { x, y }, hasMovedThisTurn: false })\n }\n\n // White pieces (bottom)\n // King at row 1 (front area row). Bishops at y=2 (outside area). Queens at y=5 (kickoff row).\n addPiece('rook', 'white', 0, 1)\n addPiece('rook', 'white', 8, 1)\n addPiece('bishop', 'white', 3, 2)\n addPiece('bishop', 'white', 5, 2)\n addPiece('king', 'white', 4, 1)\n addPiece('queen', 'white', 4, 5)\n addPiece('knight', 'white', 2, 4)\n addPiece('knight', 'white', 6, 4)\n\n // Black pieces (top, symmetric)\n // King at row 10 (front area row). Bishops at y=9 (outside area). Queens at y=6 (kickoff row).\n addPiece('rook', 'black', 0, 10)\n addPiece('rook', 'black', 8, 10)\n addPiece('bishop', 'black', 3, 9)\n addPiece('bishop', 'black', 5, 9)\n addPiece('king', 'black', 4, 10)\n addPiece('queen', 'black', 4, 6)\n addPiece('knight', 'black', 2, 7)\n addPiece('knight', 'black', 6, 7)\n\n const servingQueen = pieces.find(p => p.side === servingSide && p.type === 'queen')!\n\n return {\n pieces,\n ball: { pos: { ...servingQueen.pos }, holderId: servingQueen.id },\n score: currentScore,\n actionPoints: maxActionPoints,\n maxActionPoints,\n turn: servingSide,\n moveHistory: [],\n turnNumber: 1,\n }\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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store/use-game-store.ts"],"names":[],"mappings":";;;;AAiBO,IAAM,oBAAA,GAAuB,CAAC,WAAA,EAAmB,YAAA,GAAe,EAAE,KAAA,EAAO,CAAA,EAAG,KAAA,EAAO,CAAA,EAAE,EAAG,eAAA,GAAkB,CAAA,KAAkB;AAC/H,EAAA,MAAM,SAAkB,EAAC;AAEzB,EAAA,MAAM,QAAA,GAAW,CAAC,IAAA,EAAiB,IAAA,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AAA,IAAI,CAAC,QAAQ,OAAO,KAAA;AAEpB,IAAA,MAAM,EAAE,UAAA,EAAY,aAAA,KAAkB,SAAA,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,EAAY,YAAA,CAAa,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA,EACxD,CAAC;AACL,CAAA,CAAE","file":"chunk-YLNDQ4HG.js","sourcesContent":["import { create } from 'zustand'\nimport type { BoardState, Piece, Side, Position, PieceType } from '@scriptonita/chess-football-engine'\nimport { applyMove, applyPass, applyEndTurn } 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 getInitialBoardState = (servingSide: Side, currentScore = { white: 0, black: 0 }, maxActionPoints = 5): BoardState => {\n const pieces: Piece[] = []\n\n const addPiece = (type: PieceType, side: Side, x: number, y: number) => {\n pieces.push({ id: `${side}_${type}_${x}_${y}`, type, side, pos: { x, y }, hasMovedThisTurn: false })\n }\n\n // White pieces (bottom)\n // King at row 1 (front area row). Bishops at y=2 (outside area). Queens at y=5 (kickoff row).\n addPiece('rook', 'white', 0, 1)\n addPiece('rook', 'white', 8, 1)\n addPiece('bishop', 'white', 3, 2)\n addPiece('bishop', 'white', 5, 2)\n addPiece('king', 'white', 4, 1)\n addPiece('queen', 'white', 4, 5)\n addPiece('knight', 'white', 2, 4)\n addPiece('knight', 'white', 6, 4)\n\n // Black pieces (top, symmetric)\n // King at row 10 (front area row). Bishops at y=9 (outside area). Queens at y=6 (kickoff row).\n addPiece('rook', 'black', 0, 10)\n addPiece('rook', 'black', 8, 10)\n addPiece('bishop', 'black', 3, 9)\n addPiece('bishop', 'black', 5, 9)\n addPiece('king', 'black', 4, 10)\n addPiece('queen', 'black', 4, 6)\n addPiece('knight', 'black', 2, 7)\n addPiece('knight', 'black', 6, 7)\n\n const servingQueen = pieces.find(p => p.side === servingSide && p.type === 'queen')!\n\n return {\n pieces,\n ball: { pos: { ...servingQueen.pos }, holderId: servingQueen.id },\n score: currentScore,\n actionPoints: maxActionPoints,\n maxActionPoints,\n turn: servingSide,\n moveHistory: [],\n turnNumber: 1,\n }\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"]}
|