diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index f5789b9..1d49f65 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -35,7 +35,7 @@ interface MyGraphComponentProps { addToHistory: (message : string) => void solo : boolean isDaily : boolean - isEasy: boolean + difficulty: string setNetwork: (network: Network) => void showLast: boolean setNetworkEnigme: (networkEnigme: Map[]>) => void @@ -90,7 +90,7 @@ let testFirst = false let testFirst2 = true -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey, handleTurn, nbNodes, setChangeGraph}) => { +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, difficulty, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey, handleTurn, nbNodes, setChangeGraph}) => { let cptTour: number = 1 //* Gestion du temps : @@ -451,7 +451,9 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS if (isDaily){ setNetworkEnigme(dailyEnigme) - if (!isEasy){ + console.log(difficulty) + if (difficulty === "hard" || difficulty=== "intermediate"){ + console.log(dailyEnigme) dailyEnigme.forEach((pairs, index) => { pairs.forEach((pair) => { //@ts-ignore @@ -464,7 +466,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS }) }); } - else{ + else if (difficulty === "easy"){ if (firstHistory){ firstHistory=false indices.forEach((indice, index) => { @@ -757,7 +759,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS else { if (firstLap){ firstLap=false - if (!isDaily){ + if (solo && (difficulty === "intermediate" || !isDaily)){ addToHistory("<----- [Tour " + 1 +"/"+networkData.nodes.length + "] ----->"); } } @@ -1082,9 +1084,11 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS if(isDaily){ // TODO: verif difficulté et add les stats // TODO: verif pour facile et difficile, si réussi en one shot ou non - if(isEasy){ + if(difficulty==="easy"){ manager.userService.addEasyEnigmaStats(user.pseudo, 1, testTemps - 0.5); } + else if (difficulty === "intermediate"){ + } else{ manager.userService.addHardEnigmaStats(user.pseudo, 1, testTemps - 0.5); } @@ -1114,10 +1118,29 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`) } else{ - addToHistory(personTest.getName() + " n'est pas le coupable !"); //TODO préciser le nombre d'indice qu'il a de juste - cptTour ++; // On Incrémente le nombre de tour du joueur - addToHistory("<----- [Tour " + cptTour +"/"+networkData.nodes.length + "] ----->"); - changecptTour(cptTour); // On le transmet a la page précédente avec la fonction + if (isDaily){ + if (difficulty==="intermediate"){ + addToHistory(personTest.getName() + " n'est pas le coupable !"); //TODO préciser le nombre d'indice qu'il a de juste + cptTour ++; // On Incrémente le nombre de tour du joueur + addToHistory("<----- [Tour " + cptTour +"/"+networkData.nodes.length + "] ----->"); + changecptTour(cptTour); // On le transmet a la page précédente avec la fonction + } + else if (difficulty==="easy"){ + cptTour ++; // On Incrémente le nombre de tour du joueur + changecptTour(cptTour); // On le transmet a la page précédente avec la fonction + } + else{ + navigate(`${basePath}/endgame?solo=true&daily=true`) + setNetworkDataData(networkData) + setWinnerData(null) + } + } + else{ + addToHistory(personTest.getName() + " n'est pas le coupable !"); //TODO préciser le nombre d'indice qu'il a de juste + cptTour ++; // On Incrémente le nombre de tour du joueur + addToHistory("<----- [Tour " + cptTour +"/"+networkData.nodes.length + "] ----->"); + changecptTour(cptTour); // On le transmet a la page précédente avec la fonction + } } } } diff --git a/cryptide_project/src/Contexts/GameContext.tsx b/cryptide_project/src/Contexts/GameContext.tsx index 9910e73..8c456ec 100644 --- a/cryptide_project/src/Contexts/GameContext.tsx +++ b/cryptide_project/src/Contexts/GameContext.tsx @@ -37,7 +37,7 @@ interface GameContextProps { setTurnPlayerIndexData: (newTurnPlayerIndex: number) => void; setRoomData: (newRoom: string) => void; setOnlyFalseData: (newOnlyFalse: boolean) => void - setWinnerData: (winner: Player) => void + setWinnerData: (winner: Player | null) => void reset: () => void setDailyEnigmeData: (map: Map[]>) => void setNbCoupData: (newNbCoup : number) => void @@ -131,7 +131,7 @@ export const GameProvider: React.FC = ({ children }) => { setOnlyFalse(newOnlyFalse) } - const setWinnerData = (winner: Player) =>{ + const setWinnerData = (winner: Player | null) =>{ setWinner(winner) } diff --git a/cryptide_project/src/Pages/InGame.tsx b/cryptide_project/src/Pages/InGame.tsx index bab5aab..ba24dd3 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -92,11 +92,12 @@ const InGame = ({locale, changeLocale}) => { } - let isEasy: boolean = true - const isEasytmp = params.get('easy'); - if (isEasytmp == "false"){ - isEasy=false + let difficulty: string = ""; + let difficultyTmp = params.get('difficulty') + if (difficultyTmp !== null){ + difficulty=difficultyTmp } + //* Historique const [history, setHistory] = useState([]); const [showLast, setShowLast] = useState(false) @@ -360,7 +361,7 @@ const InGame = ({locale, changeLocale}) => { addToHistory={addToHistory} solo={IsSolo} isDaily={isDaily} - isEasy={isEasy} + difficulty={difficulty} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} setNetwork={setNetworkData} @@ -386,7 +387,7 @@ const InGame = ({locale, changeLocale}) => { {playTurnSound &&