diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index ae976d7..445a790 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -25,9 +25,11 @@ interface MyGraphComponentProps { addToHistory: (message : string) => void solo : boolean isDaily : boolean + isEasy: boolean setNetwork: (network: Network) => void showLast: boolean setNetworkEnigme: (networkEnigme: Map[]>) => void + setPlayerIndex: (playerIndex: number) => void } let lastAskingPlayer = 0 @@ -44,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, 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 : @@ -117,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 (isDaily){ setNetworkEnigme(dailyEnigme) - 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) - } - }) - }); + 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)}) + } + }) + }); + } + else{ + if (firstHistory){ + firstHistory=false + indices.forEach((indice, index) => { + addToHistory("Indice " + positionToEmoji(index, true) + " : " + indice.ToString("fr")) + }) + } + + } } socket.on("reset graph", () => { @@ -337,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) @@ -438,7 +458,9 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS else { if (firstLap){ firstLap=false - addToHistory("<----- [Tour " + 1 +"/"+networkData.nodes.length + "] ----->"); + if (!isDaily){ + addToHistory("<----- [Tour " + 1 +"/"+networkData.nodes.length + "] ----->"); + } } } @@ -510,7 +532,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS askedWrong=false 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 7359bad..da57d35 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -72,6 +72,11 @@ 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) @@ -100,6 +105,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) @@ -129,6 +136,10 @@ const InGame = ({locale, changeLocale}) => { setTurnBarText(newTurnBarText) } + const setPlayerIndexData = (playerIndex: number) => { + setPlayerIndex(playerIndex) + } + const generateTEX = async () => { if (network != null && personNetwork != null && person != null){ @@ -258,11 +269,13 @@ const InGame = ({locale, changeLocale}) => { addToHistory={addToHistory} solo={IsSolo} isDaily={isDaily} + isEasy={isEasy} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} setNetwork={setNetworkData} setNetworkEnigme={setNetworkEnigmeData} - showLast={showLast}/> + showLast={showLast} + setPlayerIndex={setPlayerIndexData}/>
@@ -275,7 +288,7 @@ const InGame = ({locale, changeLocale}) => { } - {!isDaily && + {(!isDaily || (isDaily && isEasy)) &&
{history.map((item, index) => (
{item}
@@ -391,7 +404,7 @@ const InGame = ({locale, changeLocale}) => { { !IsSolo &&
- +
} diff --git a/cryptide_project/src/Pages/Lobby.tsx b/cryptide_project/src/Pages/Lobby.tsx index 6fcd06f..e77b8cd 100644 --- a/cryptide_project/src/Pages/Lobby.tsx +++ b/cryptide_project/src/Pages/Lobby.tsx @@ -42,13 +42,19 @@ import { socket } from "../SocketConfig"; import { random } from 'lodash'; import SessionService from '../services/SessionService'; - let gameStarted = false function Lobby() { const theme=useTheme(); const navigate = useNavigate(); + const [enteredNumber, setEnteredNumber] = useState(20); + + //@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(); @@ -146,7 +152,7 @@ function Lobby() { function StartGame(){ - const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(players.length, 30) + const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(players.length, enteredNumber) setPersonData(choosenPerson) setPersonNetworkData(networkPerson) setIndicesData(choosenIndices) @@ -214,6 +220,19 @@ function Lobby() { */} +
+ + +

La valeur saisie : {enteredNumber}

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