diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index d7d222d..8495501 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -50,6 +50,8 @@ interface MyGraphComponentProps { putGreyBackground : () => void putCorrectBackground : () => void putImposssibleGrey : () => void + + handleTurn :() => void } let lastAskingPlayer = 0 @@ -80,7 +82,7 @@ let testTemps = 0 let testFirst = false -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey}) => { +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey, handleTurn}) => { let cptTour: number = 0 //* Gestion du temps : @@ -185,6 +187,10 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } useEffect(() =>{ + //* Gestion du sound des tours : + if (actualPlayerIndex == lastIndex){ + handleTurn(); + } cptBug=0 if (actualPlayerIndex==firstPlayer){ const bot = testPlayers[lastIndex] @@ -205,6 +211,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS let i = 0 socket.emit("node checked", personIndex, true, lastIndex, room, lastIndex) while(playerIndex != lastIndex){ + // //! Play sound ? + // handleTurn(); i++ if (playerIndex == players.length){ playerIndex = 0 diff --git a/cryptide_project/src/Pages/EndGame.tsx b/cryptide_project/src/Pages/EndGame.tsx index 3e72f2c..05c1224 100644 --- a/cryptide_project/src/Pages/EndGame.tsx +++ b/cryptide_project/src/Pages/EndGame.tsx @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react'; +import React, {useEffect, useState} from 'react'; /* Style */ @@ -11,6 +11,9 @@ import Person from '../res/img/Person.png'; import Leave from '../res/icon/leave.png'; import Replay from '../res/icon/replay.png'; +/* sound */ +import WinSound from '../res/Audio/win.wav'; + /* Component */ import PersonStatus from '../Components/PersonStatus'; import ButtonImgNav from '../Components/ButtonImgNav'; @@ -64,6 +67,11 @@ function EndGame() { } }; + useEffect(() => { + handleWinSound(); + }, []); + + useEffect(() => { const container = document.getElementById("vis-graph"); if (!container) { @@ -126,8 +134,21 @@ function EndGame() { 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 (
+ {playTurnSound &&