From eebc45b9d496bcd9a7d08f05ba2cf110125bbc79 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Tue, 28 Nov 2023 14:23:39 +0100 Subject: [PATCH] Enigme facile et difficile --- .../src/Components/GraphContainer.tsx | 40 +++++++++++++------ cryptide_project/src/Pages/InGame.tsx | 8 +++- cryptide_project/src/Pages/Play.tsx | 10 ++--- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 945b4e3..44c8aa5 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -23,6 +23,7 @@ interface MyGraphComponentProps { addToHistory: (message : string) => void solo : boolean isDaily : boolean + isEasy: boolean setNetwork: (network: Network) => void showLast: boolean } @@ -42,9 +43,10 @@ let lastNodes: NodePerson[] = [] let cptEndgame = 0 let firstEnigme = true let endgame= false +let firstHistory = true -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, addToHistory, showLast, setNetwork}) => { +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork}) => { let cptTour: number = 0 //* Gestion du temps : @@ -283,16 +285,26 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setNetwork(network) if (isDaily){ - 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", () => { @@ -429,7 +441,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 + "] ----->"); + } } } @@ -501,7 +515,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/Pages/InGame.tsx b/cryptide_project/src/Pages/InGame.tsx index e3feff6..a93af7a 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -69,6 +69,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) @@ -220,6 +225,7 @@ const InGame = ({locale, changeLocale}) => { addToHistory={addToHistory} solo={IsSolo} isDaily={isDaily} + isEasy={isEasy} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} setNetwork={setNetworkData} @@ -236,7 +242,7 @@ const InGame = ({locale, changeLocale}) => { } - {!isDaily && + {(!isDaily || (isDaily && isEasy)) &&
{history.map((item, index) => (
{item}
diff --git a/cryptide_project/src/Pages/Play.tsx b/cryptide_project/src/Pages/Play.tsx index ecb1995..4b2cc93 100644 --- a/cryptide_project/src/Pages/Play.tsx +++ b/cryptide_project/src/Pages/Play.tsx @@ -183,12 +183,8 @@ function Play() { setPersonNetworkData(networkPerson) setIndicesData(choosenIndices) setIndicesData(choosenIndices) - if (first){ - first = false - const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice()) - setDailyEnigmeData(map) - } - navigate('/game?solo=true&daily=true'); + + navigate('/game?solo=true&daily=true&easy=true'); setShowOverlay(false); }; @@ -206,7 +202,7 @@ function Play() { const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice()) setDailyEnigmeData(map) } - navigate('/game?solo=true&daily=true'); + navigate('/game?solo=true&daily=true&easy=false'); setShowOverlay(false); };