diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 83363af..445a790 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -29,6 +29,7 @@ interface MyGraphComponentProps { setNetwork: (network: Network) => void showLast: boolean setNetworkEnigme: (networkEnigme: Map[]>) => void + setPlayerIndex: (playerIndex: number) => void } let lastAskingPlayer = 0 @@ -45,10 +46,12 @@ let cptHistory = 0 let lastNodes: NodePerson[] = [] let cptEndgame = 0 let firstEnigme = true +let firstIndex = true let endgame= false let firstHistory = true -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme}) => { + +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex}) => { let cptTour: number = 0 //* Gestion du temps : @@ -118,6 +121,11 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS }, [showLast]) let playerIndex: number = turnPlayerIndex + + if (firstIndex){ + firstIndex=false + setPlayerIndex(playerIndex) + } let index = 0 for (let i=0; i = ({onNodeClick, handleS setNetwork(network) if (isDaily){ - if(!isEasy){ - // setNetworkEnigme(dailyEnigme) + setNetworkEnigme(dailyEnigme) + if (!isEasy){ dailyEnigme.forEach((pairs, index) => { pairs.forEach((pair) => { const i = indices.findIndex((indice) => pair.first.getId() === indice.getId()) 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) } }) }); @@ -312,8 +319,9 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS addToHistory("Indice " + positionToEmoji(index, true) + " : " + indice.ToString("fr")) }) } + + } } - } socket.on("reset graph", () => { console.log("reset graph") @@ -348,6 +356,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS if (node!=undefined){ onNodeClick(false) playerIndex = newPlayerIndex + setPlayerIndex(playerIndex) if (mapIndexPersons.get(askedIndex)?.find((p) => p.getId() == id) == undefined){ const p = personNetwork.getPersons().find((p)=> p.getId() == id) const tab = mapIndexPersons.get(askedIndex) @@ -524,7 +533,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS askedWrongBot=false endgame = true firstHistory=true - try{ if(isLoggedIn){ if(!solo){ diff --git a/cryptide_project/src/Components/PersonStatus.tsx b/cryptide_project/src/Components/PersonStatus.tsx index a66429d..8658aa2 100644 --- a/cryptide_project/src/Components/PersonStatus.tsx +++ b/cryptide_project/src/Components/PersonStatus.tsx @@ -17,37 +17,62 @@ interface PlayerStatusProps { setPlayerTouched: (newPlayerTouch: number) => void; playerTouched: number showCircle: boolean + playerIndex: number } let touchedPlayer = -1 //@ts-ignore -const PersonStatus: React.FC = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle}) => { +const PersonStatus: React.FC = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle, playerIndex}) => { const theme=useTheme(); - const {players} = useGame() + const {players, actualPlayerIndex} = useGame() if (players[index] instanceof Bot){ img = BotImg } + const [buffer, setBuffer] = useState("") + const [touchedPlayer, setTouchedPlayer] = useState(-2) useEffect(() =>{ setTouchedPlayer(playerTouched) }, [playerTouched]) + + let IsActualPlayer = index != actualPlayerIndex + + useEffect(() => { + if (playerIndex===index){ + setBuffer('solid 1px green') + } + else{ + setBuffer('') + } + }, [playerIndex]) + + function onTouch(){ + if (IsActualPlayer){ + setPlayerTouched(index) + } + } + return ( -
setPlayerTouched(index)}> - player -
{name}
- - {(touchedPlayer == index && showCircle) ?( -
- state -
- ): showCircle && - ( -
- state -
- ) } - +
+
onTouch()}> + player +
{name}
+ + {IsActualPlayer && ( + (touchedPlayer == index && showCircle) ?( +
+ state +
+ ): showCircle && + ( +
+ state +
+ ) + )} + +
); } diff --git a/cryptide_project/src/Components/PlayerList.tsx b/cryptide_project/src/Components/PlayerList.tsx index 3dc36d7..52e6f2d 100644 --- a/cryptide_project/src/Components/PlayerList.tsx +++ b/cryptide_project/src/Components/PlayerList.tsx @@ -14,9 +14,10 @@ interface PlayerListProps { players: Player[]; playerTouched: number setPlayerTouched: (newPlayerTouch: number) => void; - } + playerIndex: number +} -const PlayerList: React.FC = ({ players, playerTouched, setPlayerTouched}) => { +const PlayerList: React.FC = ({ players, playerTouched, setPlayerTouched, playerIndex}) => { const theme = useTheme(); return ( @@ -25,7 +26,18 @@ const PlayerList: React.FC = ({ players, playerTouched, setPlay { //@ts-ignore players.map((player, index) => ( - player.id!=socket.id && + //player.id!=socket.id && + )) }
diff --git a/cryptide_project/src/Pages/EndGame.tsx b/cryptide_project/src/Pages/EndGame.tsx index e695e8d..1c24b76 100644 --- a/cryptide_project/src/Pages/EndGame.tsx +++ b/cryptide_project/src/Pages/EndGame.tsx @@ -98,7 +98,7 @@ function EndGame() {
{player.id !== winner?.id && (
- {}} index={index} showCircle={false}/> + {}} index={index} playerIndex={-2} showCircle={false}/>
{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 0880b27..33010ce 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -72,12 +72,12 @@ const InGame = ({locale, changeLocale}) => { isDaily=false } + let isEasy: boolean = true const isEasytmp = params.get('easy'); if (isEasytmp == "false"){ isEasy=false } - //* Historique const [history, setHistory] = useState([]); const [showLast, setShowLast] = useState(false) @@ -106,6 +106,8 @@ const InGame = ({locale, changeLocale}) => { const [showTurnBar, setShowTurnBar] = useState(false); const [turnBarText, setTurnBarText] = useState(""); const [playerTouched, setPlayerTouched] = useState(-2) + const [playerIndex, setPlayerIndex] = useState(-2) + const [network, setNetwork] = useState(null) const [networkEnigme, setNetworkEnigme] = useState[]> | null>(null) @@ -135,6 +137,10 @@ const InGame = ({locale, changeLocale}) => { setTurnBarText(newTurnBarText) } + const setPlayerIndexData = (playerIndex: number) => { + setPlayerIndex(playerIndex) + } + const generateTEX = async () => { if (network != null && personNetwork != null && person != null){ @@ -269,7 +275,8 @@ const InGame = ({locale, changeLocale}) => { playerTouched={playerTouched} setNetwork={setNetworkData} setNetworkEnigme={setNetworkEnigmeData} - showLast={showLast}/> + showLast={showLast} + setPlayerIndex={setPlayerIndexData}/>
@@ -398,7 +405,7 @@ const InGame = ({locale, changeLocale}) => { { !IsSolo &&
- +
} diff --git a/cryptide_project/src/Pages/Lobby.tsx b/cryptide_project/src/Pages/Lobby.tsx index 25c8ab5..1462a1c 100644 --- a/cryptide_project/src/Pages/Lobby.tsx +++ b/cryptide_project/src/Pages/Lobby.tsx @@ -52,7 +52,12 @@ let gameStarted = false function Lobby() { const theme=useTheme(); const navigate = useNavigate(); - + + //@ts-ignore + const handleNumberChange = (event) => { + const newNumber = Math.max(20, Math.min(60, parseInt(event.target.value, 10))); + setEnteredNumber(newNumber); + }; const { indices, setIndicesData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, setActualPlayerIndexData, setTurnPlayerIndexData, setRoomData } = useGame(); @@ -303,6 +308,20 @@ function Lobby() { {/*
+
+ + +

La valeur saisie : {enteredNumber}

+
+ + +
+ + {({ placement, arrowProps, show: _show, popper, ...props }) => ( @@ -255,7 +248,6 @@ function Play() { - diff --git a/package.json b/package.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{}