diff --git a/cryptide_project/Scripts/social_graph.sh b/cryptide_project/Scripts/social_graph.sh index 4af7d54..3a179af 100755 --- a/cryptide_project/Scripts/social_graph.sh +++ b/cryptide_project/Scripts/social_graph.sh @@ -1,5 +1,6 @@ #!/bin/sh +npm install --force SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/cryptide_project/server/api/controllers/AuthController.js b/cryptide_project/server/api/controllers/AuthController.js index 6ef56cd..da07529 100644 --- a/cryptide_project/server/api/controllers/AuthController.js +++ b/cryptide_project/server/api/controllers/AuthController.js @@ -69,6 +69,9 @@ class AuthController { // Stocker l'utilisateur dans la session) req.session.user = user; + req.session.user.nbNodes = 25 + req.session.user.nbIndices = 3 + // Envoyer une réponse réussie console.log("[" + hour + ":" + minutes + "] " + user.pseudo + " have been connected."); @@ -84,6 +87,20 @@ class AuthController { } } + static async UpdateNbNodesIndices(req, res){ + try{ + if (req.session.user){ + req.session.user.nbNodes = req.body.nbNodes; + req.session.user.nbIndices = req.body.nbIndices; + res.status(200).json({ message: 'Nombre de noeuds mis à jour.' }); + } + } + catch(error){ + console.error(error); + res.status(500).json({ error: 'Erreur lors de la mise à jour du nombre de noeuds.' }); + } +} + static async logout(req, res) { const pseudo = req.session.user.pseudo; const date = new Date(); diff --git a/cryptide_project/server/api/controllers/SessionController.js b/cryptide_project/server/api/controllers/SessionController.js index 2268c2c..ee8d97b 100644 --- a/cryptide_project/server/api/controllers/SessionController.js +++ b/cryptide_project/server/api/controllers/SessionController.js @@ -87,7 +87,7 @@ class SessionController { req.session.user.onlineStats = {nbGames: nbGamesOL, nbWins: nbWinsOL, ratio: ratioOL}; - + res.status(200).json({ user: req.session.user }); } catch(error){ diff --git a/cryptide_project/server/api/routes/AuthRoutes.js b/cryptide_project/server/api/routes/AuthRoutes.js index d289950..262d30c 100644 --- a/cryptide_project/server/api/routes/AuthRoutes.js +++ b/cryptide_project/server/api/routes/AuthRoutes.js @@ -11,6 +11,7 @@ router.delete('/auth/logout', AuthController.logout) router.delete('/auth/delAccount', AuthController.delAccount) router.post('/auth/validatePassword', AuthController.validatePassword); router.put('/auth/updatePassword', AuthController.updatePassword); +router.put('/session/updateNbNodes', AuthController.UpdateNbNodesIndices); router.get('/auth/getAllUsers', AuthController.getUsers) router.get('/auth/games', AuthController.getGames) @@ -25,6 +26,7 @@ router.post('/session/addHardEnigmaStats', SessionController.addHardEnigmaStats) router.post('/session/addOnlineStats', SessionController.addOnlineStats); router.put('/session/updatePseudo', SessionController.UpdatePseudo); + // Routes pour le daily scoreboard router.get('/scoreboard/getDailyMastermind', ScoreboardController.getDailyMastermind); router.get('/scoreboard/getDailyEasyEnigma', ScoreboardController.getDailyEasyEnigma); diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index c1947cd..55e5362 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -78,7 +78,6 @@ let cptHistory = 0 let lastNodes: NodePerson[] = [] let cptEndgame = 0 let endgame= false -let firstHistory = true let cptSquare = 0 let cptOnAskedWrong = 0 let cptPlayerLeft = 0 @@ -89,6 +88,7 @@ let testTemps = 0 let testFirst = false let gameStartTmp = true let index = 0 +let firstHistory = true 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, setChangeGraph, lang}) => { let cptTour: number = 1 @@ -112,6 +112,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS const [netEnigme, setNetEnigme] = useState[]> | null>(null) const [downloaded, setDownloaded] = useState(false) + const [updateHistory, setUpdateHistory] = useState<() => void>(() => {}) + useEffect(() => { if (testFirst){ testTemps = 0 @@ -192,7 +194,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS gameStartTmp=gameStart if (gameStartTmp){ setGameStartData(false) - console.log(gameStart) setLastIndex(turnPlayerIndex) setPlayerIndex(playerIndex) } @@ -418,6 +419,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS link.click(); URL.revokeObjectURL(url); } + useEffect(() => { @@ -436,11 +438,16 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setIndicesData(choosenIndices) const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice()) setDailyEnigmeData(map) - addToHistory("<----- [Tour " + 1 +"/"+networkPerson.getPersons().length + "] ----->"); + if (solo && (difficulty === "intermediate" || !isDaily)){ + addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) +" " + 1 +"/"+networkPerson.getPersons().length + "] ----->"); + } + else{ + choosenIndices.forEach((indice, index) => { + addToHistory(intl.formatMessage({ id: 'indice' }) + positionToEmoji(index, true) + " : " + indice.ToString(lang)) + }) + } changecptTour(1) testTemps=0 - - } useEffect(() => { @@ -496,6 +503,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } } }; + const networkData = { nodes: nodes, edges: graph.edges }; const network = new Network(container, networkData, initialOptions); @@ -503,6 +511,17 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setNetwork(network) setSeedData(network.getSeed()) + if (solo){ + if (solo && (difficulty === "intermediate" || !isDaily)){ + addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) +" " + 1 +"/"+networkData.nodes.length + "] ----->"); + } + else{ + indices.forEach((indice, index) => { + addToHistory(intl.formatMessage({ id: 'indice' }) + positionToEmoji(index, true) + " : " + indice.ToString(lang)) + }) + } + } + if (isDaily){ setNetworkEnigme(dailyEnigme) setNetEnigme(dailyEnigme) @@ -521,15 +540,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS }) }); } - else if (difficulty === "easy"){ - if (firstHistory){ - firstHistory=false - indices.forEach((indice, index) => { - addToHistory(intl.formatMessage({ id: 'indice' }) + positionToEmoji(index, true) + " : " + indice.ToString(lang)) - }) - } - - } } socket.on("give network", (playerId) => { @@ -620,7 +630,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setPlayerIndex(index) setLastIndex(index) if (actualPlayerIndex==index){ - handleTurnBarTextChange(intl.formatMessage({ id: 'game.yourTurn' })) handleShowTurnBar(true) } }) @@ -901,6 +910,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setLastIndex(-1) setPlayerTouched(-1) setWinnerData(winner) + firstHistory=true first = true @@ -909,7 +919,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS setAskedWrong(false) askedWrongBot=false endgame = true - firstHistory=true cptBug=0 try{ if(isLoggedIn){ @@ -935,6 +944,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } finally{ setElapsedTime(0) + putCorrectBackground() socket.off("end game") socket.off("asked all") socket.off("opacity activated") @@ -951,24 +961,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } }) - - - personNetwork.getPersons().forEach(p => { - let a = 0 - for (let i of indices){ - let tester = IndiceTesterFactory.Create(i) - if (tester.Works(p)){ - a++ - } - } - if (a==indices.length){ - //networkData.nodes.update({id: p.getId(), label: p.getName() + "\n🔵"}) - //console.log(p) - } - - }); - - // Gérer le changement entre la physique et le déplacement manuel network.on("dragging", (params) => { if (params.nodes.length > 0) { @@ -1104,15 +1096,14 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS const personTest = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0]) //person sélectionnée const node = nodes.get().find((n: any) => params.nodes[0] == n.id) if(node == undefined)return; - if (personTest != undefined && !node.label.includes(positionToEmoji(index, true)) && !node.label.includes(positionToEmoji(index, false))){ //si la personne existe et que le noeud n'a pas déjà été cliqué + if (node.label.includes(colorToEmoji(positionToColor(0), true)) || node.label.includes(colorToEmoji(positionToColor(0), false))) return + if (personTest != undefined){ //si la personne existe et que le noeud n'a pas déjà été cliqué let index =0 - let works = true - const statsTime = elapsedTime; for (const i of indices){ const tester = IndiceTesterFactory.Create(i) const test = tester.Works(personTest) //@ts-ignore - if (node!=undefined){ + if (node!=undefined && !node.label.includes(positionToEmoji(index, true)) && !node.label.includes(positionToEmoji(index, false))){ const nodeNode = nodes.get().find((n: any) => params.nodes[0] == n.id) if(nodeNode == undefined)return; networkData.nodes.update({id: params.nodes[0], label: nodeNode.label + positionToEmoji(index, test)}) diff --git a/cryptide_project/src/Components/PlayerList.tsx b/cryptide_project/src/Components/PlayerList.tsx index 7bbf279..0062bba 100644 --- a/cryptide_project/src/Components/PlayerList.tsx +++ b/cryptide_project/src/Components/PlayerList.tsx @@ -8,6 +8,7 @@ import Person from '../res/img/Person.png' import BotImg from '../res/img/bot.png' import { socket } from '../SocketConfig'; +import { FormattedMessage } from 'react-intl'; //@ts-ignore @@ -69,7 +70,7 @@ const PlayerList: React.FC = ({ players, playerTouched, setPlay textAlign: "center", color: "white", padding: "10px"}} - onClick={() => askEveryone()}>Ask everyone + onClick={() => askEveryone()}> ): ( + onClick={() => askEveryone()}> ) } diff --git a/cryptide_project/src/Components/ScoreBoard.css b/cryptide_project/src/Components/ScoreBoard.css index 2272e63..0946e44 100644 --- a/cryptide_project/src/Components/ScoreBoard.css +++ b/cryptide_project/src/Components/ScoreBoard.css @@ -12,4 +12,17 @@ } /* Personnalisez davantage selon vos préférences */ - \ No newline at end of file + + .carousselButton{ + border:none; + background-color:darkgray; + color:white; + opacity: 60%; + width: 50px; + height: 70px; + font-size: 40px; + border-radius: 5px; + padding: 5px; + margin: 5px; + cursor: pointer; + } \ No newline at end of file diff --git a/cryptide_project/src/Components/ScoreBoard.tsx b/cryptide_project/src/Components/ScoreBoard.tsx index c93d639..4ff44ab 100644 --- a/cryptide_project/src/Components/ScoreBoard.tsx +++ b/cryptide_project/src/Components/ScoreBoard.tsx @@ -94,6 +94,19 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { const intl = useIntl(); + + //@ts-ignore + const CustomPrevButton = ({ previousSlide }) => ( + + ); + + //@ts-ignore + const CustomNextButton = ({ nextSlide }) => ( + + ); + + + return ( = ({ Player }) => { title={intl.formatMessage({ id: 'score.tab.stat' })} disabled={!Player.pseudo.startsWith("Guest_") ? false : true}> - + } + renderCenterRightControls={({ nextSlide }) => } + adaptiveHeight + wrapAround + slidesToShow={1} + cellSpacing={10} + key={carouselKey} + >

@@ -151,7 +172,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { - +
@@ -257,7 +278,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { - +
diff --git a/cryptide_project/src/Error/ErrorPage.tsx b/cryptide_project/src/Error/ErrorPage.tsx index d0f57c0..d0a6522 100644 --- a/cryptide_project/src/Error/ErrorPage.tsx +++ b/cryptide_project/src/Error/ErrorPage.tsx @@ -28,7 +28,7 @@ function ErrorPage({ code = "", msg = "Something is wrong"}) {
- +
); diff --git a/cryptide_project/src/Pages/EndGame.css b/cryptide_project/src/Pages/EndGame.css index 03fd3f5..dc1a765 100644 --- a/cryptide_project/src/Pages/EndGame.css +++ b/cryptide_project/src/Pages/EndGame.css @@ -1,124 +1,90 @@ - -.head{ +/* Styles for the Winner and Indice section */ +.head { display: flex; justify-content: center; - flex-direction: column; - align-items: center; -} - -.leaderboard-header{ - display: flex; - justify-content: center; - flex-direction: column; align-items: center; - - width: fit-content; - - border-radius: 0px 0px 30px 30px; - border: solid; - border-width: 0 5px; - + } + + .leaderboard-header { + border: 2px solid; + border-color: #0064E0; padding: 20px; -} - -.bottomEnd{ + text-align: center; + border-radius: 0px 0px 10px 10px; + } + + /* Styles for the Winner's details */ + .winner-details { display: flex; - justify-content: space-around; -} - -.winner{ - display: flex; - justify-content: center; - flex-direction: column; align-items: center; -} - -.playersContainer { - display: flex; - flex-direction: column; - align-items: center; - /* padding-left: "5px"; */ - - width: 100px; - background-color: red; -} - -.playerContainer{ - /* display: flex; - align-items: center; */ - /* flex-direction: column; */ - - /* width: 300px; */ - width: 30%; - margin-bottom: 20px; - /* margin-bottom: 10px; */ - - border: solid 1px whitesmoke; - border-radius: 15px; - - background-color: white; -} - -.losingPlayersContainer{ + justify-content: center; + } + + .winner-details img { + width: 75px; + height: 75px; + border-radius: 50%; + margin-right: 10px; + } + + /* Styles for the Indice Display */ + .indiceDisplay { + border: 2px solid whitesmoke; + border-radius: 10px; + margin: 5px; /* Réduire la marge */ + padding: 8px; /* Réduire le rembourrage */ + box-shadow: 3px 3px 3px rgb(246, 246, 246); /* Réduire l'ombre */ + } + + /* Styles for the Losing Players Container */ + .losingPlayersContainer { display: flex; flex-wrap: wrap; justify-content: space-evenly; - - margin: 10px 0; - - max-width: 50%; - - overflow-y: scroll; - max-height: 200px; - /* background-color: yellow; */ -} - -.indiceDisplay{ - border: solid 2px whitesmoke; - border-radius: 10px; - margin: 0 15px 0 15px; - padding: 10px; - box-shadow: 5px 5px 5px rgb(246, 246, 246); -} - -.SoloContainer{ + margin: 5px; + } + + /* Styles for individual Player Containers */ + .playerContainer { display: flex; flex-direction: column; align-items: center; - - border: solid 1px whitesmoke; + margin-top: 30px; + margin-bottom: 30px; + border: 1px solid whitesmoke; border-radius: 15px; background-color: white; + } - max-width: 50%; -} - -.indicesolo{ + .soloContainer { display: flex; - flex-wrap: wrap; - justify-content: space-evenly; - - /* margin: 10px 0; */ - /* max-height: 200px; */ -} - -.solostat{ - display: flex; - justify-content: space-between; - width: 70%; -} - -.solostat p { + justify-content: center; + align-items: center; + width: 100%; /* Ajoutez cette ligne pour occuper toute la largeur */ + } + + .solostat{ border: solid 1px whitesmoke; border-radius: 15px; background-color: white; - padding: 10px; -} + margin: 5px; + width: fit-content; /* Ajoutez cette ligne pour ajuster la largeur au contenu */ + } + + .center { + display: flex; + justify-content: center; + flex-direction: column; + align-items: center; + } + -#vis-graph { + /* Styles for the Graph Container */ + #vis-graph { height: 500px; - margin: 50px; + margin: 5px; border: 2px solid #ccc; - overflow: hidden; -} + overflow: hidden; + } + \ No newline at end of file diff --git a/cryptide_project/src/Pages/EndGame.tsx b/cryptide_project/src/Pages/EndGame.tsx index 83fcef1..125a565 100644 --- a/cryptide_project/src/Pages/EndGame.tsx +++ b/cryptide_project/src/Pages/EndGame.tsx @@ -35,7 +35,7 @@ import Player from '../model/Player'; import { useGame } from '../Contexts/GameContext'; /* Boostrap */ -import { Button } from 'react-bootstrap'; +import { Button, Col, Container, Row } from 'react-bootstrap'; import Bot from '../model/Bot'; import {basePath} from "../AdressSetup" @@ -147,77 +147,191 @@ function EndGame({lang}: {lang: string}) { }, 2000); }; return ( -
+
{playTurnSound &&