import React, {useEffect} from 'react'; /* Style */ import './EndGame.css'; import '../Style/Global.css'; import { useTheme } from '../Style/ThemeContext'; /* res */ import Person from '../res/img/Person.png'; import Leave from '../res/icon/leave.png'; import Replay from '../res/icon/replay.png'; /* Component */ import PersonStatus from '../Components/PersonStatus'; import ButtonImgNav from '../Components/ButtonImgNav'; import BigButtonNav from '../Components/BigButtonNav'; // import { Network } from "vis-network/standalone/esm/vis-network"; import { map } from 'lodash'; /* Nav */ import { Link } from 'react-router-dom'; /* Lang */ import { FormattedMessage } from 'react-intl'; /* Model */ import Player from '../model/Player'; /* Context */ import { useGame } from '../Contexts/GameContext'; /* Boostrap */ import { Button } from 'react-bootstrap'; import Bot from '../model/Bot'; function EndGame() { const {networkData, seed} = useGame(); const params = new URLSearchParams(window.location.search); const initialOptions = { layout: { improvedLayout: true, randomSeed: seed, hierarchical: { enabled: false, direction: 'LR', sortMethod: 'hubsize' }, //randomSeed: 2 }, physics: { enabled: true, barnesHut: { gravitationalConstant: -1000, springConstant: 0.001, springLength: 100 } } }; useEffect(() => { const container = document.getElementById("vis-graph"); if (!container) { console.error("Container not found"); return; } const network = new Network(container, networkData, initialOptions); console.log(networkData) }, []); //* Gestion solo let IsSolo: boolean = false const solotmp = params.get('solo'); if (solotmp == "true"){ IsSolo=true } //* Gestion daily let IsDaily: boolean = false const dailytmp = params.get('daily'); if (dailytmp == "true"){ IsDaily=true } const {reset} = useGame() const resetAll = () => { reset() } const {winner, person, players, indices, nbCoup, temps} =useGame() let indice = indices[0] let losingPlayers : Player[]; if(!IsSolo){ const index = players.findIndex((p) => p.id == winner?.id) if (index != -1) { indice = indices[index] } if (winner != null) { losingPlayers = players.filter(player => player.id !== winner.id); } else { losingPlayers = players; } } else{ losingPlayers = []; } const theme = useTheme(); console.log(winner) console.log(indices) let indicenull = false; if (indices.length == 0){ indicenull = true; } return (
{!IsSolo ? (

{winner?.pseudo} a gagné !

Le tueur était {person?.getName()}

{!indicenull && (

{indices[players.findIndex((p) => p.id == winner?.id)].ToString("fr")}

)}
{/*
*/}
{losingPlayers.map((player, index) => (
{player.id !== winner?.id && (
{}} index={index} playerIndex={-2} showCircle={false}/> {!indicenull && (
{indices[players.findIndex((p) => p.id == player?.id)].ToString("fr")}
)}
)}
))}
): (

Vous avez gagné !

Le tueur était {person?.getName()}

{winner?.pseudo}

{!IsDaily &&

Nombre de coups : {nbCoup}

}

Temps : {temps}s

{indices.map((indice, index) => ( //
Indice {index+1} : {indice.ToString("fr")}
//
)) }
)}
); } export default EndGame;