changement selon les indication de thomas, et ajout du soundeffect pour la win 🔊

pull/106/head
Pierre Ferreira 1 year ago
parent 3e4233d33e
commit 6d93bfb180

@ -187,6 +187,10 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
} }
useEffect(() =>{ useEffect(() =>{
//* Gestion du sound des tours :
if (actualPlayerIndex == lastIndex){
handleTurn();
}
cptBug=0 cptBug=0
if (actualPlayerIndex==firstPlayer){ if (actualPlayerIndex==firstPlayer){
const bot = testPlayers[lastIndex] const bot = testPlayers[lastIndex]
@ -207,9 +211,8 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
let i = 0 let i = 0
socket.emit("node checked", personIndex, true, lastIndex, room, lastIndex) socket.emit("node checked", personIndex, true, lastIndex, room, lastIndex)
while(playerIndex != lastIndex){ while(playerIndex != lastIndex){
//! Play sound ? // //! Play sound ?
handleTurn(); // handleTurn();
i++ i++
if (playerIndex == players.length){ if (playerIndex == players.length){
playerIndex = 0 playerIndex = 0

@ -1,4 +1,4 @@
import React, {useEffect} from 'react'; import React, {useEffect, useState} from 'react';
/* Style */ /* Style */
@ -11,6 +11,9 @@ import Person from '../res/img/Person.png';
import Leave from '../res/icon/leave.png'; import Leave from '../res/icon/leave.png';
import Replay from '../res/icon/replay.png'; import Replay from '../res/icon/replay.png';
/* sound */
import WinSound from '../res/Audio/win.wav';
/* Component */ /* Component */
import PersonStatus from '../Components/PersonStatus'; import PersonStatus from '../Components/PersonStatus';
import ButtonImgNav from '../Components/ButtonImgNav'; import ButtonImgNav from '../Components/ButtonImgNav';
@ -64,6 +67,11 @@ function EndGame() {
} }
}; };
useEffect(() => {
handleWinSound();
}, []);
useEffect(() => { useEffect(() => {
const container = document.getElementById("vis-graph"); const container = document.getElementById("vis-graph");
if (!container) { if (!container) {
@ -126,8 +134,21 @@ function EndGame() {
indicenull = true; indicenull = true;
} }
//* Sound
const [playTurnSound, setPlayTurnSound] = useState(false);
const handleWinSound = () => {
setTimeout(() => { // on attend 1s avant de jouer le son
setPlayTurnSound(true);
}, 300);
setTimeout(() => { // on attend 2s avant de remettre le son à false
setPlayTurnSound(false);
}, 2000);
};
return ( return (
<div> <div>
{playTurnSound && <audio src={WinSound} autoPlay />}
{!IsSolo ? ( {!IsSolo ? (
<div> <div>
<div className="head"> <div className="head">

Loading…
Cancel
Save