diff --git a/cryptide_project/server/server.js b/cryptide_project/server/server.js index 46b2b64..3c1c3ec 100644 --- a/cryptide_project/server/server.js +++ b/cryptide_project/server/server.js @@ -33,17 +33,22 @@ io.on('connection', (socket) => { socket.join(room) } if (map.get(room) == undefined){ - map.set(room, [{type: player.type, id: player.id, name: player.name}]) + map.set(room, [{type: player.type, id: socket.id, name: player.name}]) } else{ const tab = map.get(room) for(let i = 0; i} /> } /> } /> - } /> + }/> } /> + {/* }/> */} diff --git a/cryptide_project/src/Components/ColoredIndices.tsx b/cryptide_project/src/Components/ColoredIndices.tsx new file mode 100644 index 0000000..e8f8c4a --- /dev/null +++ b/cryptide_project/src/Components/ColoredIndices.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Link } from 'react-router-dom'; +import '../Style/Global.css'; +import { FormattedMessage } from 'react-intl'; + +import { useTheme } from '../Style/ThemeContext'; + +//@ts-ignore +function ColoredIndices({ letter, color}) { + + const theme = useTheme(); + + // const mystyle = { + // backgroundColor: "#0064E0", + // }; + + return ( +
+ Indice Letter +
+ ); +} + +export default ColoredIndices; diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 36ae66a..21932f1 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -21,6 +21,7 @@ import { useGame } from "../Contexts/GameContext"; import { socket } from "../SocketConfig" import { colorToEmoji, positionToColor } from "../ColorHelper"; import { ColorToHexa } from "../model/EnumExtender"; +import Bot from "../model/Bot"; interface MyGraphComponentProps { @@ -29,6 +30,8 @@ interface MyGraphComponentProps { handleTurnBarTextChange: (newTurnBarText: string) => void setPlayerTouched: (newPlayerTouch: number) => void; playerTouched: number + changecptTour: (newcptTour : number) => void + solo : boolean } let lastAskingPlayer = 0 @@ -40,14 +43,14 @@ let mapIndexPersons: Map = new Map() let touchedPlayer = -1 -const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched}) => { +const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo}) => { +let cptTour: number = 0 const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setWinnerData } = useGame(); const params = new URLSearchParams(window.location.search); - const solotmp = params.get('solo'); + const navigate = useNavigate(); - console.log(person) useEffect(() =>{ touchedPlayer=playerTouched @@ -78,12 +81,9 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } let thisPlayerIndex = index - + if (first){ first = false - if (solotmp == "false"){ - solo=false - } if (!solo){ for(let i = 0; i = ({onNodeClick, handleS if (node != undefined){ for(let i=0; i = ({onNodeClick, handleS }) - - personNetwork.getPersons().forEach(p => { - let a = 0 - for (let i of indices){ - let tester = IndiceTesterFactory.Create(i) - if (tester.Works(p)){ - a++ + + 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) - } + 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) { - // Un nœud a été cliqué - initialOptions.physics.enabled = false; - network.setOptions(initialOptions); - } - }); + // Gérer le changement entre la physique et le déplacement manuel + network.on("dragging", (params) => { + if (params.nodes.length > 0) { + // Un nœud a été cliqué + initialOptions.physics.enabled = false; + network.setOptions(initialOptions); + } + }); network.on("click", async (params) => { @@ -327,10 +326,15 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } } } - else if(touchedPlayer != - 1 && playerIndex == actualPlayerIndex && touchedPlayer p.id === socket.id, actualPlayerIndex)) - socket.emit("put correct background", socket.id) - touchedPlayer=-1 + else if(touchedPlayer != -1 && playerIndex == actualPlayerIndex && touchedPlayer p.id === socket.id, actualPlayerIndex)) + socket.emit("put correct background", socket.id) + touchedPlayer=-1 + } } else if(playerIndex == actualPlayerIndex && touchedPlayer==players.length){ const person = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0]) @@ -392,6 +396,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } index++ } + cptTour ++; // On Incrémente le nombre de tour du joueur + changecptTour(cptTour); // On le transmet a la page précédente avec la fonction } } } diff --git a/cryptide_project/src/Components/TurnBar.tsx b/cryptide_project/src/Components/TurnBar.tsx index dae6c18..53df6d4 100644 --- a/cryptide_project/src/Components/TurnBar.tsx +++ b/cryptide_project/src/Components/TurnBar.tsx @@ -16,6 +16,6 @@ const TurnBar: React.FC = ({text})=> {

{text}

); - }; - - export default TurnBar; \ No newline at end of file +}; + +export default TurnBar; \ No newline at end of file diff --git a/cryptide_project/src/Pages/InGame.css b/cryptide_project/src/Pages/InGame.css index 9e12155..600710e 100644 --- a/cryptide_project/src/Pages/InGame.css +++ b/cryptide_project/src/Pages/InGame.css @@ -60,6 +60,22 @@ top :50px; } +.nbLaps{ /*nombre de tour*/ + position: absolute; + z-index: 1; + left: 10px; + top :50px; + + margin: 10px 20px; + padding: 20px; + border-radius: 15px; + border: solid 2px; + + font-size: 30px; + color: #fff; +} + + #endgamebutton{ position: absolute; z-index: 1; diff --git a/cryptide_project/src/Pages/InGame.tsx b/cryptide_project/src/Pages/InGame.tsx index 73bccaf..53a6a65 100644 --- a/cryptide_project/src/Pages/InGame.tsx +++ b/cryptide_project/src/Pages/InGame.tsx @@ -10,6 +10,7 @@ import ChoiceBar from '../Components/ChoiceBar'; import ButtonImgNav from '../Components/ButtonImgNav'; import PersonStatus from '../Components/PersonStatus'; import PlayerList from '../Components/PlayerList'; +import TurnBar from '../Components/TurnBar'; /* Icon */ import Leave from "../res/icon/leave.png"; @@ -32,50 +33,67 @@ import { HiLanguage } from 'react-icons/hi2'; import { Nav, NavDropdown } from 'react-bootstrap'; import { FormattedMessage } from 'react-intl'; import Color from '../model/Color'; -import TurnBar from '../Components/TurnBar'; import { useGame } from '../Contexts/GameContext'; //@ts-ignore const InGame = ({locale, changeLocale}) => { - + const theme = useTheme(); - - const [showChoiceBar, setShowChoiceBar] = useState(false); - const [showTurnBar, setShowTurnBar] = useState(false); - const [turnBarText, setTurnBarText] = useState(""); - const [playerTouched, setPlayerTouched] = useState(-2) - const handleNodeClick = (shouldShowChoiceBar: boolean) => { - setShowChoiceBar(shouldShowChoiceBar); - }; + + const params = new URLSearchParams(window.location.search); + + //* Gestion solo + let IsSolo: boolean = true + const solotmp = params.get('solo'); + if (solotmp == "false"){ + IsSolo=false + } + + + const [showChoiceBar, setShowChoiceBar] = useState(false); + const [showTurnBar, setShowTurnBar] = useState(false); + const [turnBarText, setTurnBarText] = useState(""); + const [playerTouched, setPlayerTouched] = useState(-2) + + const handleNodeClick = (shouldShowChoiceBar: boolean) => { + setShowChoiceBar(shouldShowChoiceBar); + }; const handleSetPlayerTouched = (newPlayerTouched: number) => { setPlayerTouched(newPlayerTouched); }; - const handleShowTurnBar = (shouldShowTurnBar: boolean) => { - setShowTurnBar(shouldShowTurnBar); - }; - - const handleTurnBarTextChange = (newTurnBarText: string) =>{ - setTurnBarText(newTurnBarText) - } - - /* offcanvas */ - //? faire une fonction pour close et show en fonction de l'etat du canva ? - //? comment faire pour eviter la recopie de tout le code a chaque canvas boostrap ? - const [show, setShow] = useState(false); - const handleClose = () => setShow(false); - const handleShow = () => setShow(true); - - const [showP, setShowP] = useState(false); - const handleCloseP = () => setShowP(false); - const handleShowP = () => setShowP(true); + const handleShowTurnBar = (shouldShowTurnBar: boolean) => { + setShowTurnBar(shouldShowTurnBar); + }; - const [showS, setShowS] = useState(false); - const handleCloseS = () => setShowS(false); - const handleShowS = () => setShowS(true); + const handleTurnBarTextChange = (newTurnBarText: string) =>{ + setTurnBarText(newTurnBarText) + } + + /* offcanvas */ + //? faire une fonction pour close et show en fonction de l'etat du canva ? + //? comment faire pour eviter la recopie de tout le code a chaque canvas boostrap ? + const [show, setShow] = useState(false); + const handleClose = () => setShow(false); + const handleShow = () => setShow(true); + + const [showP, setShowP] = useState(false); + const handleCloseP = () => setShowP(false); + const handleShowP = () => setShowP(true); + + const [showS, setShowS] = useState(false); + const handleCloseS = () => setShowS(false); + const handleShowS = () => setShowS(true); + + const [cptTour, setcptTour] = useState(0); + + //@ts-ignore + const changecptTour = (newcptTour) => { + setcptTour(newcptTour); + }; const handleChange = () => { if (show){ @@ -119,9 +137,20 @@ const InGame = ({locale, changeLocale}) => {
{showTurnBar && }
- +
+ + {IsSolo && +
+ Tour : {cptTour} +
+ } + +
+
+ +
+ + + + {/* */} + + + + + + +
+ + {/* + + Joueurs +

Il y a {players.length} joueurs

+
+ + + +
*/} + + + + Indice + + + {/* Possède les cheveux noir ou joue au basket */} + {indice?.ToString(locale)} + + + + { + //* canva pour les paramètres + } + + + param Paramètres + + + + + + + + +
+ {showChoiceBar && } +
+ {/* +
{/* tmp + +
+ */} +
+ ); +}; + + +export default SoloGame; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..41b488d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "Cryptid", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}