WIP
This commit is contained in:
@@ -119,12 +119,43 @@ class Player {
|
||||
if (this.ply > 0 && state.siteConfig.sounds) {
|
||||
if (position.mate) {
|
||||
sfx.snap.play();
|
||||
if (position.move?.flags && position.move.flags.includes("e")) {
|
||||
sfx.fanfare.play();
|
||||
} else if (position.move?.piece === "r") {
|
||||
position.move.flags.includes("c")
|
||||
? sfx.brickTake.play()
|
||||
: sfx.brickMove.play();
|
||||
}
|
||||
} else if (/[ce]/.test(position.move?.flags as string)) {
|
||||
sfx.take.play();
|
||||
if (position.move?.piece === "r") {
|
||||
sfx.brickTake.play();
|
||||
} else {
|
||||
sfx.take.play();
|
||||
}
|
||||
|
||||
if (
|
||||
position.move?.piece === "n" &&
|
||||
state.boardConfig.piecesStyle === "anarchy"
|
||||
) {
|
||||
sfx.neigh.play();
|
||||
} else if (position.move?.flags && position.move.flags.includes("e")) {
|
||||
sfx.fanfare.play();
|
||||
}
|
||||
} else if (/[kqp]/.test(position.move?.flags as string)) {
|
||||
sfx.swap.play();
|
||||
} else {
|
||||
sfx.move.play();
|
||||
if (position.move?.piece === "r") {
|
||||
sfx.brickMove.play();
|
||||
} else {
|
||||
sfx.move.play();
|
||||
}
|
||||
|
||||
if (
|
||||
position.move?.piece === "n" &&
|
||||
state.boardConfig.piecesStyle === "anarchy"
|
||||
) {
|
||||
sfx.snort.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,26 @@ const sfx = {
|
||||
src: ["/sfx/rewind.wav"],
|
||||
volume: 0.2,
|
||||
}),
|
||||
snort: new Howl({
|
||||
src: ["/sfx/snort.wav"],
|
||||
volume: 0.5,
|
||||
}),
|
||||
neigh: new Howl({
|
||||
src: ["/sfx/neigh.wav"],
|
||||
volume: 0.5,
|
||||
}),
|
||||
fanfare: new Howl({
|
||||
src: ["/sfx/fanfare.wav"],
|
||||
volume: 0.5,
|
||||
}),
|
||||
brickMove: new Howl({
|
||||
src: ["/sfx/brick-move.wav"],
|
||||
volume: 0.5,
|
||||
}),
|
||||
brickTake: new Howl({
|
||||
src: ["/sfx/brick-take.wav"],
|
||||
volume: 0.5,
|
||||
}),
|
||||
};
|
||||
|
||||
export default sfx;
|
||||
|
||||
Reference in New Issue
Block a user