diff --git a/COPYING.md b/COPYING.md index db41c51..081b37d 100644 --- a/COPYING.md +++ b/COPYING.md @@ -58,4 +58,5 @@ public/piece/companion | David L. Brown | ["freeware"](http://www.enpassant.dk/c public/piece/leipzig | Armando Hernandez Marroquin | ["freeware"](http://www.enpassant.dk/chess/fonteng.htm#LEIPZIG) public/piece/reillycraig | [Reilly Craig](https://instagram.com/fader_) | public/piece/symmetric | [Arcticpenguins](https://github.com/lichess-org/lichobile/issues/215) | +public/sounds | [Lichess](https://github.com/lichess-org/lila) | [GNU AGPL v3](https://github.com/lichess-org/lila?tab=License-2-ov-file) public/piece/riohacha | | diff --git a/public/sounds/capture.mp3 b/public/sounds/capture.mp3 new file mode 100644 index 0000000..ab51d76 Binary files /dev/null and b/public/sounds/capture.mp3 differ diff --git a/public/sounds/capture.webm b/public/sounds/capture.webm deleted file mode 100644 index 5b9a0bb..0000000 Binary files a/public/sounds/capture.webm and /dev/null differ diff --git a/public/sounds/castle.webm b/public/sounds/castle.webm deleted file mode 100644 index f601a9e..0000000 Binary files a/public/sounds/castle.webm and /dev/null differ diff --git a/public/sounds/error.mp3 b/public/sounds/error.mp3 new file mode 100644 index 0000000..af769c0 Binary files /dev/null and b/public/sounds/error.mp3 differ diff --git a/public/sounds/game-end.webm b/public/sounds/game-end.webm deleted file mode 100644 index 502eee4..0000000 Binary files a/public/sounds/game-end.webm and /dev/null differ diff --git a/public/sounds/game-start.webm b/public/sounds/game-start.webm deleted file mode 100644 index 0ac2714..0000000 Binary files a/public/sounds/game-start.webm and /dev/null differ diff --git a/public/sounds/illegal-move.webm b/public/sounds/illegal-move.webm deleted file mode 100644 index 7af7963..0000000 Binary files a/public/sounds/illegal-move.webm and /dev/null differ diff --git a/public/sounds/move-check.webm b/public/sounds/move-check.webm deleted file mode 100644 index 5ac91c0..0000000 Binary files a/public/sounds/move-check.webm and /dev/null differ diff --git a/public/sounds/move.mp3 b/public/sounds/move.mp3 new file mode 100644 index 0000000..7ed0cf6 Binary files /dev/null and b/public/sounds/move.mp3 differ diff --git a/public/sounds/move.webm b/public/sounds/move.webm deleted file mode 100644 index 4599fe2..0000000 Binary files a/public/sounds/move.webm and /dev/null differ diff --git a/public/sounds/promote.webm b/public/sounds/promote.webm deleted file mode 100644 index 108199b..0000000 Binary files a/public/sounds/promote.webm and /dev/null differ diff --git a/src/hooks/useChessActions.ts b/src/hooks/useChessActions.ts index 1b2ec98..4e1789f 100644 --- a/src/hooks/useChessActions.ts +++ b/src/hooks/useChessActions.ts @@ -1,9 +1,5 @@ import { getGameFromPgn, setGameHeaders } from "@/lib/chess"; -import { - playGameEndSound, - playIllegalMoveSound, - playSoundFromMove, -} from "@/lib/sounds"; +import { playIllegalMoveSound, playSoundFromMove } from "@/lib/sounds"; import { Player } from "@/types/game"; import { Chess, Move, DEFAULT_POSITION } from "chess.js"; import { PrimitiveAtom, useAtom } from "jotai"; @@ -129,11 +125,7 @@ export const useChessActions = (chessAtom: PrimitiveAtom) => { } setGame(newGame); - if (lastMove) { - playSoundFromMove(lastMove); - } else { - playGameEndSound(); - } + playSoundFromMove(lastMove); }, [setGame] ); diff --git a/src/lib/sounds.ts b/src/lib/sounds.ts index 705d6fd..558dbcc 100644 --- a/src/lib/sounds.ts +++ b/src/lib/sounds.ts @@ -1,5 +1,4 @@ import { Move } from "chess.js"; -import { getWhoIsCheckmated, isCheck } from "./chess"; let audioContext: AudioContext | null = null; let audio: HTMLAudioElement | null = null; @@ -20,29 +19,15 @@ const playSound = async (url: string) => { } }; -export const playCaptureSound = () => playSound("/sounds/capture.webm"); -export const playCastleSound = () => playSound("/sounds/castle.webm"); -export const playGameEndSound = () => playSound("/sounds/game-end.webm"); -export const playGameStartSound = () => playSound("/sounds/game-start.webm"); -export const playIllegalMoveSound = () => - playSound("/sounds/illegal-move.webm"); -export const playMoveCheckSound = () => playSound("/sounds/move-check.webm"); -export const playMoveSound = () => playSound("/sounds/move.webm"); -export const playPromoteSound = () => playSound("/sounds/promote.webm"); +export const playCaptureSound = () => playSound("/sounds/capture.mp3"); +export const playIllegalMoveSound = () => playSound("/sounds/error.mp3"); +export const playMoveSound = () => playSound("/sounds/move.mp3"); export const playSoundFromMove = async (move: Move | null) => { if (!move) { playIllegalMoveSound(); - } else if (getWhoIsCheckmated(move.after)) { - playGameEndSound(); - } else if (isCheck(move.after)) { - playMoveCheckSound(); - } else if (move.promotion) { - playPromoteSound(); } else if (move.captured) { playCaptureSound(); - } else if (move.isKingsideCastle() || move.isQueensideCastle()) { - playCastleSound(); } else { playMoveSound(); } diff --git a/src/sections/play/gameInProgress.tsx b/src/sections/play/gameInProgress.tsx index 0c29972..c540da7 100644 --- a/src/sections/play/gameInProgress.tsx +++ b/src/sections/play/gameInProgress.tsx @@ -7,7 +7,6 @@ import { import { useAtom, useAtomValue } from "jotai"; import { gameAtom, isGameInProgressAtom } from "./states"; import { useEffect } from "react"; -import { playGameEndSound } from "@/lib/sounds"; import UndoMoveButton from "./undoMoveButton"; export default function GameInProgress() { @@ -19,7 +18,6 @@ export default function GameInProgress() { }, [game, setIsGameInProgress]); const handleResign = () => { - playGameEndSound(); setIsGameInProgress(false); }; diff --git a/src/sections/play/gameSettings/gameSettingsDialog.tsx b/src/sections/play/gameSettings/gameSettingsDialog.tsx index d835848..f3114a2 100644 --- a/src/sections/play/gameSettings/gameSettingsDialog.tsx +++ b/src/sections/play/gameSettings/gameSettingsDialog.tsx @@ -28,7 +28,6 @@ import { enginePlayNameAtom, } from "../states"; import { useChessActions } from "@/hooks/useChessActions"; -import { playGameStartSound } from "@/lib/sounds"; import { logAnalyticsEvent } from "@/lib/firebase"; import { useEffect, useState } from "react"; import { isEngineSupported } from "@/lib/engine/shared"; @@ -93,7 +92,6 @@ export default function GameSettingsDialog({ open, onClose }: Props) { setIsGameInProgress(true); handleClose(); - playGameStartSound(); logAnalyticsEvent("play_game", { engine: engineName,