diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index b4a832b..bff26b6 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -28,6 +28,7 @@ interface MyGraphComponentProps { isEasy: boolean setNetwork: (network: Network) => void showLast: boolean + setPlayerIndex: (playerIndex: number) => void setNetworkEnigme: (networkEnigme: Map[]>) => void } @@ -45,11 +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, setPlayerIndex, setNetworkEnigme}) => { let cptTour: number = 0 //* Gestion du temps : @@ -119,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 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) 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 03ad0b4..e9880cc 100644 --- a/cryptide_project/src/Pages/EndGame.tsx +++ b/cryptide_project/src/Pages/EndGame.tsx @@ -93,7 +93,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 71c5624..e8f2f0a 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -107,6 +107,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) @@ -136,6 +138,10 @@ const InGame = ({locale, changeLocale}) => { setTurnBarText(newTurnBarText) } + const setPlayerIndexData = (playerIndex: number) => { + setPlayerIndex(playerIndex) + } + const generateTEX = async () => { if (network != null && personNetwork != null && person != null){ @@ -266,7 +272,8 @@ const InGame = ({locale, changeLocale}) => { playerTouched={playerTouched} setNetwork={setNetworkData} setNetworkEnigme={setNetworkEnigmeData} - showLast={showLast}/> + showLast={showLast} + setPlayerIndex={setPlayerIndexData}/>
@@ -395,7 +402,7 @@ const InGame = ({locale, changeLocale}) => { { !IsSolo &&
- +
}