diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index bfbbfe7..22e33ea 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -28,13 +28,15 @@ interface MyGraphComponentProps { setNetwork: (network: Network) => void showLast: boolean setNetworkEnigme: (networkEnigme: Map[]>) => void + askedWrong: boolean + setAskedWrong: (askedWrong: boolean) => void setPlayerIndex: (playerIndex: number) => void } let lastAskingPlayer = 0 let lastNodeId = -1 let first = true -let askedWrong = false +let askedWrongLocal = false let mapIndexPersons: Map = new Map() let touchedPlayer = -1 let botIndex = -1 @@ -50,7 +52,7 @@ let endgame= false let firstHistory = true -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex}) => { +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong}) => { let cptTour: number = 0 //* Gestion du temps : @@ -85,12 +87,12 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS useEffect(() =>{ touchedPlayer=playerTouched if (touchedPlayer == -1){ - if (!askedWrong){ + if (!askedWrongLocal){ socket.emit("put correct background", socket.id) } } else if (touchedPlayer < players.length && touchedPlayer>=0){ - if(!askedWrong){ + if(!askedWrongLocal){ socket.emit("put correct background", socket.id) socket.emit("put grey background", socket.id, touchedPlayer) } @@ -432,7 +434,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS }) socket.on("asked wrong", () =>{ - askedWrong = true + askedWrongLocal= true + setAskedWrong(true) askedWrongBot=true handleShowTurnBar(true) handleTurnBarTextChange("Mauvais choix, posez un carré !") @@ -566,7 +569,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS first = true cptHistory = 0 - askedWrong=false + askedWrongLocal=false + setAskedWrong(false) askedWrongBot=false endgame = true firstHistory=true @@ -647,8 +651,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setNodeIdData(params.nodes[0]) // addToHistory("Le joueur a cliqué") //! TEST DEBUG if (!solo){ - if (askedWrong){ - //@ts-ignore + if (askedWrongLocal){ const person = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0]) if (person !== undefined && indice !== null){ const tester = IndiceTesterFactory.Create(indice) @@ -661,7 +664,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS socket.emit("put correct background", socket.id) touchedPlayer=-1 askedPersons.push(person) - askedWrong = false + askedWrongLocal=false + setAskedWrong(false) } } } diff --git a/cryptide_project/src/Components/PersonStatus.tsx b/cryptide_project/src/Components/PersonStatus.tsx index 8658aa2..7ec2942 100644 --- a/cryptide_project/src/Components/PersonStatus.tsx +++ b/cryptide_project/src/Components/PersonStatus.tsx @@ -18,11 +18,12 @@ interface PlayerStatusProps { playerTouched: number showCircle: boolean playerIndex: number + askedWrong: boolean } let touchedPlayer = -1 //@ts-ignore -const PersonStatus: React.FC = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle, playerIndex}) => { +const PersonStatus: React.FC = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle, playerIndex, askedWrong}) => { const theme=useTheme(); const {players, actualPlayerIndex} = useGame() if (players[index] instanceof Bot){ @@ -48,7 +49,7 @@ const PersonStatus: React.FC = ({img = Person, state= Person, }, [playerIndex]) function onTouch(){ - if (IsActualPlayer){ + if (IsActualPlayer && !askedWrong){ setPlayerTouched(index) } } diff --git a/cryptide_project/src/Components/PlayerList.tsx b/cryptide_project/src/Components/PlayerList.tsx index 52e6f2d..34efe30 100644 --- a/cryptide_project/src/Components/PlayerList.tsx +++ b/cryptide_project/src/Components/PlayerList.tsx @@ -15,11 +15,18 @@ interface PlayerListProps { playerTouched: number setPlayerTouched: (newPlayerTouch: number) => void; playerIndex: number + askedWrong: boolean } -const PlayerList: React.FC = ({ players, playerTouched, setPlayerTouched, playerIndex}) => { +const PlayerList: React.FC = ({ players, playerTouched, setPlayerTouched, playerIndex, askedWrong}) => { const theme = useTheme(); + function askEveryone(){ + if (!askedWrong){ + setPlayerTouched(players.length) + } + } + return (
@@ -37,7 +44,8 @@ const PlayerList: React.FC = ({ players, playerTouched, setPlay setPlayerTouched={setPlayerTouched} index={index} showCircle={true} - playerIndex={playerIndex}/> + playerIndex={playerIndex} + askedWrong={askedWrong}/> )) }
@@ -57,7 +65,7 @@ const PlayerList: React.FC = ({ players, playerTouched, setPlay border: "solid 1px", textAlign: "center", padding: "10px"}} - onClick={() => setPlayerTouched(players.length)}>Ask everyone + onClick={() => askEveryone()}>Ask everyone ): ( + onClick={() => askEveryone()}>Ask everyone ) }
diff --git a/cryptide_project/src/Pages/EndGame.tsx b/cryptide_project/src/Pages/EndGame.tsx index e4f5c89..8728d12 100644 --- a/cryptide_project/src/Pages/EndGame.tsx +++ b/cryptide_project/src/Pages/EndGame.tsx @@ -150,7 +150,7 @@ function EndGame() {
{player.id !== winner?.id && (
- {}} index={index} playerIndex={-2} showCircle={false}/> + {}} index={index} playerIndex={-2} showCircle={false} askedWrong={false}/> {!indicenull && (
{indices[players.findIndex((p) => p.id == player?.id)].ToString("fr")}
)}
)} diff --git a/cryptide_project/src/Pages/InGame.tsx b/cryptide_project/src/Pages/InGame.tsx index 33010ce..422bca8 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -81,6 +81,7 @@ const InGame = ({locale, changeLocale}) => { //* Historique const [history, setHistory] = useState([]); const [showLast, setShowLast] = useState(false) + const [askedWrong, setAskedWrong] = useState(false) // Fonction pour ajouter un élément à l'historique const addToHistory = (message: string) => { @@ -92,6 +93,10 @@ const InGame = ({locale, changeLocale}) => { setShowLast(!showLast); } + const setAskedWrongData = (askedWrong: boolean) => { + setAskedWrong(askedWrong) + } + useEffect(() => { const historyContainer = document.getElementById('history-container'); if (historyContainer) { @@ -276,7 +281,9 @@ const InGame = ({locale, changeLocale}) => { setNetwork={setNetworkData} setNetworkEnigme={setNetworkEnigmeData} showLast={showLast} - setPlayerIndex={setPlayerIndexData}/> + setPlayerIndex={setPlayerIndexData} + askedWrong={askedWrong} + setAskedWrong={setAskedWrongData}/>
@@ -405,7 +412,7 @@ const InGame = ({locale, changeLocale}) => { { !IsSolo &&
- +
}