diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 4375ee1..abdc68f 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -41,13 +41,14 @@ let firstLap = true let cptHistory = 0 let lastNodes: NodePerson[] = [] let firstEnigme = true +let endgame= false const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, addToHistory, showLast, setNetwork}) => { let cptTour: number = 0 //* Gestion du temps : - const initMtn = new Date().getSeconds() + let initMtn = 0 const {user} = useAuth() const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData, dailyEnigme, setNbCoupData, settempsData} = useGame(); @@ -56,6 +57,24 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS const navigate = useNavigate(); const [lastIndex, setLastIndex] = useState(-1) + const [elapsedTime, setElapsedTime] = useState(0); + + useEffect(() => { + // Démarrez le timer au montage du composant + const intervalId = setInterval(() => { + setElapsedTime((prevElapsedTime) => prevElapsedTime + 0.5); + settempsData(elapsedTime) + + // Vérifiez si la durée est écoulée, puis arrêtez le timer + if (endgame) { + clearInterval(intervalId); + } + }, 500); + + // Nettoyez l'intervalle lorsque le composant est démonté + return () => clearInterval(intervalId); + }, [elapsedTime, endgame]); + useEffect(() =>{ touchedPlayer=playerTouched @@ -201,7 +220,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS if (first){ first = false - + endgame= false if (!solo){ for(let i = 0; i = ({onNodeClick, handleS dailyEnigme.forEach((pairs, index) => { pairs.forEach((pair) => { const i = indices.findIndex((indice) => pair.first.getId() === indice.getId()) - console.log(index) const node = networkData.nodes.get().find((n) => index == n.id) if (node != undefined){ networkData.nodes.update({id: node.id, label: node.label + positionToEmoji(i, pair.second)}) const test = networkData.nodes.get().find((n) => index == n.id) - if (test!=undefined){ - console.log(test.label) - } } }) }); } - indices.forEach((i, index) => { - console.log(i.ToString("fr") + " => " + positionToEmoji(index, true)) - }) - - if (!solo){ socket.on("asked all", (id) =>{ const pers = personNetwork.getPersons().find((p) => p.getId() == id) @@ -313,7 +323,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS }) socket.on("node checked",(id, works, askedIndex, newPlayerIndex, socketId) => { - console.log(newPlayerIndex) const node = nodes.get().find((n) => id == n.id) if (node!=undefined){ onNodeClick(false) @@ -480,10 +489,12 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setLastIndex(-1) setPlayerTouched(-1) setWinnerData(players[winnerIndex]) + setElapsedTime(0) first = true cptHistory = 0 askedWrong=false askedWrongBot=false + endgame = true socket.off("end game") socket.off("asked all") socket.off("opacity activated") @@ -512,7 +523,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } if (a==indices.length){ //networkData.nodes.update({id: p.getId(), label: p.getName() + "\n🔵"}) - console.log(p) + //console.log(p) } }); @@ -651,12 +662,14 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS works = false } if (index == indices.length - 1 && works){ - const Mtn = new Date().getSeconds() - - settempsData(Mtn - initMtn) + if (user!=null){ + setWinnerData(user) + } cptTour ++; setNbCoupData(cptTour) + setElapsedTime(0) + endgame = true navigate("/endgame?solo=true&daily=" + isDaily) } diff --git a/cryptide_project/src/Pages/EndGame.tsx b/cryptide_project/src/Pages/EndGame.tsx index 3948253..2e56dee 100644 --- a/cryptide_project/src/Pages/EndGame.tsx +++ b/cryptide_project/src/Pages/EndGame.tsx @@ -53,7 +53,6 @@ function EndGame() { const {winner, person, players, indices, nbCoup, temps} =useGame() - console.log(winner) let indice = indices[0] let losingPlayers : Player[]; @@ -120,7 +119,7 @@ function EndGame() {
-

[ {winner?.pseudo} ]

+

{winner?.pseudo}

diff --git a/cryptide_project/src/Pages/Lobby.tsx b/cryptide_project/src/Pages/Lobby.tsx index 5f86ed5..0332131 100644 --- a/cryptide_project/src/Pages/Lobby.tsx +++ b/cryptide_project/src/Pages/Lobby.tsx @@ -216,7 +216,7 @@ function Lobby() {
diff --git a/cryptide_project/src/Pages/Play.tsx b/cryptide_project/src/Pages/Play.tsx index 7c6ae2b..1c87332 100644 --- a/cryptide_project/src/Pages/Play.tsx +++ b/cryptide_project/src/Pages/Play.tsx @@ -159,7 +159,7 @@ function Play() {
- + diff --git a/cryptide_project/src/SocketConfig.ts b/cryptide_project/src/SocketConfig.ts index 339e25f..f636f79 100644 --- a/cryptide_project/src/SocketConfig.ts +++ b/cryptide_project/src/SocketConfig.ts @@ -1,6 +1,7 @@ import { io } from "socket.io-client"; +import { ADRESSE_WEBSERVER } from "./adressConfig"; -const socket = io("http://172.20.10.4:3002"); +const socket = io(ADRESSE_WEBSERVER); export {socket} \ No newline at end of file diff --git a/cryptide_project/src/adressConfig.ts b/cryptide_project/src/adressConfig.ts new file mode 100644 index 0000000..8d49e11 --- /dev/null +++ b/cryptide_project/src/adressConfig.ts @@ -0,0 +1,7 @@ +const ADRESSE_WEBSERVER = "http://localhost:3002" + +const ADRESSE_DBSERVER = "http://localhost:3003" + +const ADRESSE_WEBSITE = "http://localhost:3000" + +export {ADRESSE_DBSERVER, ADRESSE_WEBSERVER, ADRESSE_WEBSITE} \ No newline at end of file diff --git a/cryptide_project/src/model/Indices/NbSportIndice.ts b/cryptide_project/src/model/Indices/NbSportIndice.ts index eab219e..9d3bcb2 100644 --- a/cryptide_project/src/model/Indices/NbSportIndice.ts +++ b/cryptide_project/src/model/Indices/NbSportIndice.ts @@ -16,7 +16,7 @@ class NbSportIndice extends Indice { // Implémentation de la méthode abstraite ToString(lang: string): string { let json = GetJsonFile(lang) - let string = `${json.nb_sports_indice_start}`; + let string = `${json.nb_sports_indice_start} `; this.nbSport.forEach((i, index) =>{ if (index == this.nbSport.length - 1){ string += i diff --git a/cryptide_project/src/model/Indices/SportIndice.ts b/cryptide_project/src/model/Indices/SportIndice.ts index 2dbae4b..ecd9ea5 100644 --- a/cryptide_project/src/model/Indices/SportIndice.ts +++ b/cryptide_project/src/model/Indices/SportIndice.ts @@ -16,10 +16,10 @@ class SportIndice extends Indice { let string = json.sport_start; for (let i = 0; i/dev/null; then + # Tuer le processus associé au port + pid=$(lsof -Pi :3002 -sTCP:LISTEN -t) + kill -9 $pid +fi + +if lsof -Pi :3003 -sTCP:LISTEN -t >/dev/null; then + # Tuer le processus associé au port + pid=$(lsof -Pi :3003 -sTCP:LISTEN -t) + kill -9 $pid +fi \ No newline at end of file