Squashed commit of the following:
commit 933ba823d5f991b9ab1f66bd94262c181e9d0267 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Mon Apr 21 20:13:37 2025 +0200 fix : new chessjs version commit b9376bcbc718f6eaa9a0fd9caada6b957f73b85a Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Mon Apr 21 19:34:12 2025 +0200 chore : chessjs bump version
This commit is contained in:
@@ -1,28 +1,25 @@
|
||||
import { getCapturedPieces, getMaterialDifference } from "@/lib/chess";
|
||||
import { Color } from "@/types/enums";
|
||||
import { Grid2 as Grid, Typography } from "@mui/material";
|
||||
import { Chess } from "chess.js";
|
||||
import { PrimitiveAtom, useAtomValue } from "jotai";
|
||||
import { CSSProperties, useMemo } from "react";
|
||||
|
||||
export interface Props {
|
||||
gameAtom: PrimitiveAtom<Chess>;
|
||||
fen: string;
|
||||
color: Color;
|
||||
}
|
||||
|
||||
const PIECE_SCALE = 0.6;
|
||||
|
||||
export default function CapturedPieces({ gameAtom, color }: Props) {
|
||||
const game = useAtomValue(gameAtom);
|
||||
export default function CapturedPieces({ fen, color }: Props) {
|
||||
const cssProps = useMemo(() => {
|
||||
const capturedPieces = getCapturedPieces(game.fen(), color);
|
||||
const capturedPieces = getCapturedPieces(fen, color);
|
||||
return getCapturedPiecesCSSProps(capturedPieces, color);
|
||||
}, [game, color]);
|
||||
}, [fen, color]);
|
||||
|
||||
const materialDiff = useMemo(() => {
|
||||
const materialDiff = getMaterialDifference(game.fen());
|
||||
const materialDiff = getMaterialDifference(fen);
|
||||
return color === Color.White ? materialDiff : -materialDiff;
|
||||
}, [game, color]);
|
||||
}, [fen, color]);
|
||||
|
||||
return (
|
||||
<Grid container alignItems="end" columnGap={0.6} size="auto">
|
||||
|
||||
@@ -254,7 +254,7 @@ export default function Board({
|
||||
</Typography>
|
||||
|
||||
<CapturedPieces
|
||||
gameAtom={gameAtom}
|
||||
fen={gameFen}
|
||||
color={boardOrientation === Color.White ? Color.Black : Color.White}
|
||||
/>
|
||||
</Grid>
|
||||
@@ -302,7 +302,7 @@ export default function Board({
|
||||
{boardOrientation === Color.White ? whitePlayer : blackPlayer}
|
||||
</Typography>
|
||||
|
||||
<CapturedPieces gameAtom={gameAtom} color={boardOrientation} />
|
||||
<CapturedPieces fen={gameFen} color={boardOrientation} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user