Updated audio and added robber laugh
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
b6608e519a
commit
c4cb0b84e2
Binary file not shown.
BIN
client/public/assets/robber.mp3
Executable file
BIN
client/public/assets/robber.mp3
Executable file
Binary file not shown.
Binary file not shown.
@ -47,6 +47,18 @@ const Pip = () => {
|
||||
let audioEffects = {
|
||||
};
|
||||
|
||||
const loadAudio = (src) => {
|
||||
const audio = document.createElement("audio");
|
||||
audio.src = `${assetsPath}/${src}`;
|
||||
audio.setAttribute("preload", "auto");
|
||||
audio.setAttribute("controls", "none");
|
||||
audio.style.display = "none";
|
||||
document.body.appendChild(audio);
|
||||
audio.play();
|
||||
audio.hasPlayed = true;
|
||||
return audio;
|
||||
}
|
||||
|
||||
const Table = () => {
|
||||
const params = useParams();
|
||||
const [ gameId, setGameId ] = useState(params.gameId ? params.gameId : undefined);
|
||||
@ -340,14 +352,7 @@ const Table = () => {
|
||||
useEffect(() => {
|
||||
if (state === 'volcano') {
|
||||
if (!audioEffects.volcano) {
|
||||
audioEffects.volcano = document.createElement("audio");
|
||||
audioEffects.volcano.src = `${assetsPath}/volcano-eruption.mp3`;
|
||||
audioEffects.volcano.setAttribute("preload", "auto");
|
||||
audioEffects.volcano.setAttribute("controls", "none");
|
||||
audioEffects.volcano.style.display = "none";
|
||||
document.body.appendChild(audioEffects.volcano);
|
||||
audioEffects.volcano.play();
|
||||
audioEffects.volcano.hasPlayed = true;
|
||||
audioEffects.volcano = loadAudio('volcano-eruption.mp3');
|
||||
} else {
|
||||
if (!audioEffects.volcano.hasPlayed) {
|
||||
audioEffects.volcano.hasPlayed = true;
|
||||
@ -364,26 +369,34 @@ const Table = () => {
|
||||
useEffect(() => {
|
||||
if (turn && turn.color === color) {
|
||||
if (!audioEffects.yourTurn) {
|
||||
audioEffects.yourTurn = document.createElement("audio");
|
||||
audioEffects.yourTurn.src = `${assetsPath}/its-your-turn.mp3`;
|
||||
audioEffects.yourTurn.setAttribute("preload", "auto");
|
||||
audioEffects.yourTurn.setAttribute("controls", "none");
|
||||
audioEffects.yourTurn.style.display = "none";
|
||||
document.body.appendChild(audioEffects.yourTurn);
|
||||
audioEffects.yourTurn.play();
|
||||
audioEffects.yourTurn.hasPlayed = true;
|
||||
audioEffects.yourTurn = loadAudio('its-your-turn.mp3');
|
||||
} else {
|
||||
if (!audioEffects.yourTurn.hasPlayed) {
|
||||
audioEffects.yourTurn.hasPlayed = true;
|
||||
audioEffects.yourTurn.play();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (turn) {
|
||||
if (audioEffects.yourTurn) {
|
||||
audioEffects.yourTurn.hasPlayed = false;
|
||||
}
|
||||
}
|
||||
}, [turn]);
|
||||
|
||||
if (turn && turn.roll === 7) {
|
||||
if (!audioEffects.robber) {
|
||||
audioEffects.robber = loadAudio('robber.mp3');
|
||||
} else {
|
||||
if (!audioEffects.robber.hasPlayed) {
|
||||
audioEffects.robber.hasPlayed = true;
|
||||
audioEffects.robber.play();
|
||||
}
|
||||
}
|
||||
} else if (turn) {
|
||||
if (audioEffects.robber) {
|
||||
audioEffects.robber.hasPlayed = false;
|
||||
}
|
||||
}
|
||||
}, [turn, color]);
|
||||
|
||||
return <GlobalContext.Provider value={global}>
|
||||
{ /* <PingPong/> */ }
|
||||
|
Loading…
x
Reference in New Issue
Block a user