From d4171022ffccbe70264e28f1b5c6071d615be2e6 Mon Sep 17 00:00:00 2001 From: Pierre Ferreira Date: Fri, 24 Nov 2023 11:35:57 +0100 Subject: [PATCH] =?UTF-8?q?ajout=20du=20bouton=20pour=20l'EdJ,=20et=20gest?= =?UTF-8?q?ion=20de=20son=20interface=20en=20cons=C3=A9quence=20:zap:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Components/GraphContainer.tsx | 31 +++++++------- cryptide_project/src/Pages/InGame.tsx | 42 ++++++++++++------- cryptide_project/src/Pages/Play.tsx | 14 ++++++- 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index a124dc7..7ec1cae 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -23,6 +23,7 @@ interface MyGraphComponentProps { changecptTour: (newcptTour : number) => void addToHistory: (message : string) => void solo : boolean + isDaily : boolean setNetwork: (network: Network) => void showLast: boolean } @@ -42,7 +43,7 @@ let lastNodes: NodePerson[] = [] let firstEnigme = true -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, addToHistory, showLast, setNetwork}) => { +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, addToHistory, showLast, setNetwork}) => { let cptTour: number = 0 const {user} = useAuth() @@ -259,20 +260,22 @@ let cptTour: number = 0 setNetwork(network) - dailyEnigme.forEach((pairs, index) => { - pairs.forEach((pair) => { - const i = indices.findIndex((indice) => pair.first.getId() === indice.getId()) - console.log(index) - 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 (test!=undefined){ - console.log(test.label) + if (isDaily){ + dailyEnigme.forEach((pairs, index) => { + pairs.forEach((pair) => { + const i = indices.findIndex((indice) => pair.first.getId() === indice.getId()) + console.log(index) + 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 (test!=undefined){ + console.log(test.label) + } } - } - }) - }); + }) + }); + } indices.forEach((i, index) => { console.log(i.ToString("fr") + " => " + positionToEmoji(index, true)) diff --git a/cryptide_project/src/Pages/InGame.tsx b/cryptide_project/src/Pages/InGame.tsx index 7c04d6e..e3feff6 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -62,6 +62,13 @@ const InGame = ({locale, changeLocale}) => { IsSolo=false } + //* Gestion daily + let isDaily: boolean = true + const isDailytmp = params.get('daily'); + if (isDailytmp == "false"){ + isDaily=false + } + //* Historique const [history, setHistory] = useState([]); const [showLast, setShowLast] = useState(false) @@ -212,6 +219,7 @@ const InGame = ({locale, changeLocale}) => { changecptTour={changecptTour} addToHistory={addToHistory} solo={IsSolo} + isDaily={isDaily} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} setNetwork={setNetworkData} @@ -219,7 +227,7 @@ const InGame = ({locale, changeLocale}) => { - {IsSolo && + {IsSolo && !isDaily &&
{
} - -
- {history.map((item, index) => ( -
{item}
- ))} -
+ {!isDaily && +
+ {history.map((item, index) => ( +
{item}
+ ))} +
+ }
*/} - {!IsSolo && + {!IsSolo && + } - {IsSolo && + {IsSolo && + + }
diff --git a/cryptide_project/src/Pages/Play.tsx b/cryptide_project/src/Pages/Play.tsx index 281087a..b6975b3 100644 --- a/cryptide_project/src/Pages/Play.tsx +++ b/cryptide_project/src/Pages/Play.tsx @@ -91,6 +91,16 @@ function Play() { } function launchMastermind(){ + const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30) + setPersonData(choosenPerson) + setPersonNetworkData(networkPerson) + setIndicesData(choosenIndices) + setIndicesData(choosenIndices) + navigate('/game?solo=true&daily=false'); + } + + + function launchEngimeJour(){ const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30) setPersonData(choosenPerson) setPersonNetworkData(networkPerson) @@ -101,9 +111,8 @@ function Play() { const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice()) setDailyEnigmeData(map) } - navigate('/game?solo=true'); + navigate('/game?solo=true&daily=true'); } - useEffect(() => { @@ -150,6 +159,7 @@ function Play() {
+