Full game worked!
This commit is contained in:
parent
3d5b6836ed
commit
888688a019
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -27,18 +27,32 @@ import { assetsPath } from "./Common";
|
||||
import "./App.css";
|
||||
import equal from "fast-deep-equal";
|
||||
|
||||
import itsYourTurnAudio from './assets/its-your-turn.mp3';
|
||||
import robberAudio from './assets/robber.mp3';
|
||||
import knightsAudio from './assets/the-knights-who-say-ni.mp3';
|
||||
import volcanoAudio from './assets/volcano-eruption.mp3';
|
||||
|
||||
const audioFiles: Record<string, string> = {
|
||||
'its-your-turn.mp3': itsYourTurnAudio,
|
||||
'robber.mp3': robberAudio,
|
||||
'the-knights-who-say-ni.mp3': knightsAudio,
|
||||
'volcano-eruption.mp3': volcanoAudio,
|
||||
};
|
||||
|
||||
type AudioEffect = HTMLAudioElement & { hasPlayed?: boolean };
|
||||
const audioEffects: Record<string, AudioEffect | undefined> = {};
|
||||
|
||||
const loadAudio = (src: string) => {
|
||||
const audio = document.createElement("audio") as AudioEffect;
|
||||
audio.src = `${assetsPath}/assets/${src}`;
|
||||
audio.src = audioFiles[src];
|
||||
console.log("Loading audio:", audio.src);
|
||||
audio.setAttribute("preload", "auto");
|
||||
audio.setAttribute("controls", "none");
|
||||
audio.style.display = "none";
|
||||
document.body.appendChild(audio);
|
||||
void audio.play();
|
||||
audio.hasPlayed = true;
|
||||
audio.load();
|
||||
audio.addEventListener('error', (e) => console.error("Audio load error:", e, audio.src));
|
||||
audio.addEventListener('canplay', () => console.log("Audio can play:", audio.src));
|
||||
return audio;
|
||||
};
|
||||
|
||||
@ -322,9 +336,9 @@ const Table: React.FC = () => {
|
||||
audioEffects.volcano = loadAudio("volcano-eruption.mp3");
|
||||
audioEffects.volcano.volume = volume * volume;
|
||||
} else {
|
||||
if (!audioEffects.volcano.hasPlayed) {
|
||||
if (!audioEffects.volcano.hasPlayed && audioEffects.volcano.readyState >= 2) {
|
||||
audioEffects.volcano.hasPlayed = true;
|
||||
audioEffects.volcano.play();
|
||||
audioEffects.volcano.play().catch((e) => console.error("Audio play failed:", e));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -340,9 +354,9 @@ const Table: React.FC = () => {
|
||||
audioEffects.yourTurn = loadAudio("its-your-turn.mp3");
|
||||
audioEffects.yourTurn.volume = volume * volume;
|
||||
} else {
|
||||
if (!audioEffects.yourTurn.hasPlayed) {
|
||||
if (!audioEffects.yourTurn.hasPlayed && audioEffects.yourTurn.readyState >= 2) {
|
||||
audioEffects.yourTurn.hasPlayed = true;
|
||||
audioEffects.yourTurn.play();
|
||||
audioEffects.yourTurn.play().catch((e) => console.error("Audio play failed:", e));
|
||||
}
|
||||
}
|
||||
} else if (turn) {
|
||||
@ -356,9 +370,9 @@ const Table: React.FC = () => {
|
||||
audioEffects.robber = loadAudio("robber.mp3");
|
||||
audioEffects.robber.volume = volume * volume;
|
||||
} else {
|
||||
if (!audioEffects.robber.hasPlayed) {
|
||||
if (!audioEffects.robber.hasPlayed && audioEffects.robber.readyState >= 2) {
|
||||
audioEffects.robber.hasPlayed = true;
|
||||
audioEffects.robber.play();
|
||||
audioEffects.robber.play().catch((e) => console.error("Audio play failed:", e));
|
||||
}
|
||||
}
|
||||
} else if (turn) {
|
||||
@ -372,9 +386,9 @@ const Table: React.FC = () => {
|
||||
audioEffects.knights = loadAudio("the-knights-who-say-ni.mp3");
|
||||
audioEffects.knights.volume = volume * volume;
|
||||
} else {
|
||||
if (!audioEffects.knights.hasPlayed) {
|
||||
if (!audioEffects.knights.hasPlayed && audioEffects.knights.readyState >= 2) {
|
||||
audioEffects.knights.hasPlayed = true;
|
||||
audioEffects.knights.play();
|
||||
audioEffects.knights.play().catch((e) => console.error("Audio play failed:", e));
|
||||
}
|
||||
}
|
||||
} else if (turn && turn.actions && turn.actions.indexOf("playing-knight") === -1) {
|
||||
|
BIN
client/src/assets/its-your-turn.mp3
Executable file
BIN
client/src/assets/its-your-turn.mp3
Executable file
Binary file not shown.
BIN
client/src/assets/robber.mp3
Executable file
BIN
client/src/assets/robber.mp3
Executable file
Binary file not shown.
BIN
client/src/assets/the-knights-who-say-ni.mp3
Executable file
BIN
client/src/assets/the-knights-who-say-ni.mp3
Executable file
Binary file not shown.
BIN
client/src/assets/volcano-eruption.mp3
Executable file
BIN
client/src/assets/volcano-eruption.mp3
Executable file
Binary file not shown.
@ -273,7 +273,6 @@ const roll = (game, session, dice) => {
|
||||
return `You already rolled this turn.`;
|
||||
}
|
||||
processRoll(game, session, dice);
|
||||
sendUpdateToPlayers(game, { chat: game.chat });
|
||||
return;
|
||||
|
||||
case 'volcano':
|
||||
|
Loading…
x
Reference in New Issue
Block a user