Squashed commit of the following:
commit 4810de3b94b0ec0d7e9b8570de58f85792dffa80 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Sat Apr 6 01:37:42 2024 +0200 fix : lint commit 59e0b571e6089da6c086ab6340ec6a966b2e9739 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Sat Apr 6 01:36:17 2024 +0200 feat : UI refacto commit 56806a89dca5c7fb2c229b5a57404f9a856fac09 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Fri Apr 5 03:56:08 2024 +0200 feat : add moves list commit 9e3d2347882074c38ab183e642ecef8153dbfcde Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Thu Apr 4 02:18:52 2024 +0200 feat : init branch, wip
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { setGameHeaders } from "@/lib/chess";
|
||||
import { playIllegalMoveSound, playSoundFromMove } from "@/lib/sounds";
|
||||
import {
|
||||
playGameEndSound,
|
||||
playIllegalMoveSound,
|
||||
playSoundFromMove,
|
||||
} from "@/lib/sounds";
|
||||
import { Chess, Move } from "chess.js";
|
||||
import { PrimitiveAtom, useAtom } from "jotai";
|
||||
import { useCallback } from "react";
|
||||
@@ -76,7 +80,11 @@ export const useChessActions = (chessAtom: PrimitiveAtom<Chess>) => {
|
||||
}
|
||||
|
||||
setGame(newGame);
|
||||
playSoundFromMove(lastMove);
|
||||
if (lastMove) {
|
||||
playSoundFromMove(lastMove);
|
||||
} else {
|
||||
playGameEndSound();
|
||||
}
|
||||
},
|
||||
[setGame]
|
||||
);
|
||||
|
||||
@@ -11,8 +11,16 @@ export const usePlayersNames = (gameAtom: PrimitiveAtom<Chess>) => {
|
||||
const blackName =
|
||||
gameFromUrl?.black?.name || game.header()["Black"] || "Black";
|
||||
|
||||
const whiteElo =
|
||||
gameFromUrl?.white?.rating || game.header()["WhiteElo"] || "?";
|
||||
|
||||
const blackElo =
|
||||
gameFromUrl?.black?.rating || game.header()["BlackElo"] || "?";
|
||||
|
||||
return {
|
||||
whiteName,
|
||||
blackName,
|
||||
whiteElo,
|
||||
blackElo,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user