pull/109/head
Pierre Ferreira 1 year ago
commit f2d6b89d03

@ -42,7 +42,7 @@ steps:
IMAGENAME: mysql:latest
CONTAINERNAME: mysql
COMMAND: create
OVERWRITE: true
#OVERWRITE: true
PRIVATE: false
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
from_secret: MYSQL_ROOT_PASSWORD
@ -53,6 +53,9 @@ steps:
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
from_secret: MYSQL_PASSWORD
ADMINS: thomaschazot2,pierreferreira,baptistemarcel
when:
branch:
- CI/CD
- name: container-web
image: plugins/docker
@ -70,7 +73,7 @@ steps:
#depends_on: [ build ]
when:
branch:
- master
- CI/CD
#container deployment

@ -1,7 +1,6 @@
{
"name": "cryptide",
"version": "1.0.0",
"homepage": "/containers/Crypteam-website/",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",

@ -9,7 +9,7 @@ const tmp2 = ADRESSE_WEBSERVER
const ADRESSE_WEBSITE = ""
const basePath = process.env.REACT_APP_BASE_PATH || '/containers/Crypteam-website';
const basePath = process.env.REACT_APP_BASE_PATH || '';
const tmp3 = basePath

@ -21,6 +21,9 @@ import { json } from "body-parser";
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
import {basePath} from "../AdressSetup"
import GameCreator from "../model/GameCreator";
import Stub from "../model/Stub";
import EnigmeDuJourCreator from "../model/EnigmeDuJourCreator";
import { useIntl } from "react-intl";
interface MyGraphComponentProps {
@ -33,7 +36,7 @@ interface MyGraphComponentProps {
addToHistory: (message : string) => void
solo : boolean
isDaily : boolean
isEasy: boolean
difficulty: string
setNetwork: (network: Network) => void
showLast: boolean
setNetworkEnigme: (networkEnigme: Map<number, Pair<Indice, boolean>[]>) => void
@ -51,12 +54,15 @@ interface MyGraphComponentProps {
putGreyBackground : () => void
putCorrectBackground : () => void
putImposssibleGrey : () => void
setChangeGraph : (func: (nbNodes: number, nbIndices: number) => void) => void
handleTurn :() => void
lang: string
}
let askedWrongBot = false
let lastSocketId= ""
let lastAskingPlayer = 0
let lastNodeId = -1
let first = true
@ -64,14 +70,10 @@ let askedWrongLocal = false
let mapIndexPersons: Map<number, Person[]> = new Map<number, Person[]>()
let touchedPlayer = -1
let botIndex = -1
let askedWrongBot = false
let lastSocketId= ""
let firstLap = true
let cptHistory = 0
let lastNodes: NodePerson[] = []
let cptEndgame = 0
let firstEnigme = true
let firstIndex = true
let endgame= false
let firstHistory = true
let cptSquare = 0
@ -79,14 +81,14 @@ let cptOnAskedWrong = 0
let cptPlayerLeft = 0
let firstPlayer = 0
let cptBug = 0
let cptUseEffect = 0
let testPlayers: Player[] = []
let testTemps = 0
let testFirst = false
let gameStartTmp = true
let index = 0
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({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, lang}) => {
let cptTour: number = 0
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({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
//* Gestion du temps :
let initMtn = 0
@ -97,7 +99,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
const {isLoggedIn, user, manager} = useAuth();
const { indices, indice, person, personNetwork, setNodeIdData, players, setPlayersData, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData, dailyEnigme, setNbCoupData, settempsData, setNetworkDataData, setSeedData, nodesC, temps} = useGame();
const { indices, indice, person, personNetwork, setNodeIdData, players, setPlayersData, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setIndicesData, setWinnerData, dailyEnigme, setNbCoupData, settempsData, setNetworkDataData, setSeedData, nodesC, temps, setPersonData, setPersonNetworkData, setDailyEnigmeData, gameStart, setGameStartData} = useGame();
const params = new URLSearchParams(window.location.search);
const navigate = useNavigate();
@ -117,10 +119,12 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
settempsData(testTemps)
testTemps += 0.5
cptBug ++
if (cptBug > 10){
cptBug = 0
socket.emit("who plays", room)
if (!solo){
cptBug ++
if (cptBug > 10){
cptBug = 0
socket.emit("who plays", room)
}
}
@ -138,12 +142,10 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
useEffect(() => {
testPlayers = players
console.log(testPlayers)
}, [players])
useEffect(() =>{
touchedPlayer=playerTouched
console.log(playerTouched)
if (touchedPlayer == -1){
if (!askedWrongLocal){
putCorrectBackground()
@ -182,17 +184,45 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
let playerIndex: number = turnPlayerIndex
if (firstIndex){
firstIndex=false
setPlayerIndex(playerIndex)
}
let index = 0
for (let i=0; i<players.length; i++){
if(players[i].id == socket.id){
index=i
break
useEffect(() => {
gameStartTmp=gameStart
if (gameStartTmp){
setGameStartData(false)
console.log(gameStart)
setLastIndex(turnPlayerIndex)
setPlayerIndex(playerIndex)
}
}
for (let i=0; i<players.length; i++){
if(players[i].id == socket.id){
index=i
break
}
}
first = false
endgame= false
if (!solo){
for(let i = 0; i<indices.length; i++){
mapIndexPersons.set(i, [])
}
if (actualPlayerIndex==0){
players.forEach((p, index) =>{
if (p instanceof Bot && personNetwork!=null){
p.index=index
p.initiateMap(personNetwork)
}
})
}
setActualPlayerIndexData(index)
if (playerIndex == actualPlayerIndex){
handleTurnBarTextChange(intl.formatMessage({ id: 'game.yourTurn' }))
handleShowTurnBar(true)
}
}
}, [gameStart])
useEffect(() =>{
//* Gestion du sound des tours :
@ -309,31 +339,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
}, [lastIndex])
if (first){
first = false
endgame= false
if (!solo){
for(let i = 0; i<indices.length; i++){
mapIndexPersons.set(i, [])
}
if (actualPlayerIndex==0){
players.forEach((p, index) =>{
if (p instanceof Bot && personNetwork!=null){
p.index=index
p.initiateMap(personNetwork)
}
})
}
setActualPlayerIndexData(index)
if (playerIndex == actualPlayerIndex){
handleTurnBarTextChange(intl.formatMessage({ id: 'game.yourTurn' }))
handleShowTurnBar(true)
}
}
}
useEffect(() => {
if (importToPdf){
setImportToPdf(false)
@ -372,10 +377,29 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
}, [importToJSON])
const changeGraph = (nbNodes: number, nbIndices: number) => {
//todo différencier les deux
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(nbIndices, nbNodes)
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
setDailyEnigmeData(map)
addToHistory("<----- [Tour " + 1 +"/"+networkPerson.getPersons().length + "] ----->");
changecptTour(1)
testTemps=0
}
useEffect(() => {
if (personNetwork == null){
return
}
if (solo){
setChangeGraph(() => changeGraph)
}
const graph = GraphCreator.CreateGraph(personNetwork)
let n = graph.nodesPerson;
@ -430,7 +454,9 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({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
@ -443,7 +469,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
});
}
else{
else if (difficulty === "easy"){
if (firstHistory){
firstHistory=false
indices.forEach((indice, index) => {
@ -573,7 +599,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
socket.on("node checked",(id, works, askedIndex, newPlayerIndex, socketId) => {
console.log("coucou")
cptBug=0
//@ts-ignore
const node = nodes.get().find((n) => id == n.id)
@ -582,7 +607,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
playerIndex = newPlayerIndex
setPlayerIndex(playerIndex)
setLastIndex(newPlayerIndex)
console.log(newPlayerIndex)
//@ts-ignore
if (mapIndexPersons.get(askedIndex)?.find((p) => p.getId() == id) == undefined){
//@ts-ignore
@ -736,7 +760,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
else {
if (firstLap){
firstLap=false
if (!isDaily){
if (solo && (difficulty === "intermediate" || !isDaily)){
addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) +" " + 1 +"/"+networkData.nodes.length + "] ----->");
}
}
@ -1061,9 +1085,11 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({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);
}
@ -1093,11 +1119,29 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`)
}
else{
addToHistory(personTest.getName() + intl.formatMessage({ id: 'history.NotCoupable' }));
cptTour ++; // On Incrémente le nombre de tour du joueur
const tour = cptTour+1;
addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) + " " + tour +"/"+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() + intl.formatMessage({ id: 'history.NotCoupable' }));
cptTour ++; // On Incrémente le nombre de tour du joueur
addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) + " " + 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() + intl.formatMessage({ id: 'history.NotCoupable' })); //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
}
}
}
}
@ -1109,7 +1153,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setPlayerTouched(-1)
}
});
}, []); // Le tableau vide signifie que cela ne s'exécutera qu'une fois après le premier rendu
}, [personNetwork]); // Le tableau vide signifie que cela ne s'exécutera qu'une fois après le premier rendu
return (
<>

@ -26,6 +26,8 @@ interface GameContextProps {
networkData: any
seed: number | string;
nodesC: NodePerson[]
gameStart: boolean
setGameStartData : (newStart: boolean) => void
setIndicesData: (newIndices: Indice[]) => void;
setIndiceData: (newIndice: Indice) => void;
setPersonData: (newPerson: Person) => void;
@ -37,7 +39,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<number, Pair<Indice, boolean>[]>) => void
setNbCoupData: (newNbCoup : number) => void
@ -72,8 +74,13 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
const [networkData, setNetworkData] = useState<any>(null);
const [seed, setSeed] = useState<number | string>(0);
const [nodesC, setNodes] = useState<NodePerson[]>([]);
const [gameStart, setGameStart] = useState<boolean>(true)
const setGameStartData = (newStart: boolean) => {
setGameStart(newStart)
}
const setNodesData = (nodes: NodePerson[]) => {
setNodes(nodes)
}
@ -131,7 +138,7 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
setOnlyFalse(newOnlyFalse)
}
const setWinnerData = (winner: Player) =>{
const setWinnerData = (winner: Player | null) =>{
setWinner(winner)
}
@ -165,7 +172,7 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
}
return (
<GameContext.Provider value={{ indices, setIndicesData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, nodeId, setNodeIdData, askedPersons, setAskedPersonsData, actualPlayerIndex, setActualPlayerIndexData, turnPlayerIndex, setTurnPlayerIndexData, room, setRoomData, onlyFalse, setOnlyFalseData, winner, setWinnerData, reset, dailyEnigme, setDailyEnigmeData, nbCoup, setNbCoupData, temps, settempsData, setNetworkDataData, networkData, seed, setSeedData, nodesC, setNodesData}}>
<GameContext.Provider value={{ indices, setIndicesData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, nodeId, setNodeIdData, askedPersons, setAskedPersonsData, actualPlayerIndex, setActualPlayerIndexData, turnPlayerIndex, setTurnPlayerIndexData, room, setRoomData, onlyFalse, setOnlyFalseData, winner, setWinnerData, reset, dailyEnigme, setDailyEnigmeData, nbCoup, setNbCoupData, temps, settempsData, setNetworkDataData, networkData, seed, setSeedData, nodesC, setNodesData, gameStart, setGameStartData}}>
{children}
</GameContext.Provider>
);

@ -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<string[]>([]);
const [showLast, setShowLast] = useState(false)
@ -107,6 +108,8 @@ const InGame = ({locale, changeLocale}) => {
const [putCorrectBackground, setPutCorrectBackground] = useState<() => void>(() => {});
const [putGreyBackgroud, setPutGreyBackground] = useState<() => void>(() => {});
const [putImposssibleGrey, setPutImposssibleGrey] = useState<() => void>(() => {});
const [changeGraph, setChangeGraph] = useState<(nbNodes: number, nbIndices: number) => void>(() => {});
const setPutCorrectBackgroundData = (func: () => void) => {
@ -121,6 +124,10 @@ const InGame = ({locale, changeLocale}) => {
setPutImposssibleGrey(func)
}
const setChangeGraphData = (func: (nbNodes: number, nbIndices: number) => void) => {
setChangeGraph(func)
}
const setImportToJSONData = (imp: boolean) => {
setImportToJSON(imp)
}
@ -255,7 +262,7 @@ const InGame = ({locale, changeLocale}) => {
const handleCloseS = () => setShowS(false);
const handleShowS = () => setShowS(true);
const [cptTour, setcptTour] = useState(0);
const [cptTour, setcptTour] = useState(1);
const [LastVisible, setLastVisible] = useState(false);
@ -317,6 +324,22 @@ const InGame = ({locale, changeLocale}) => {
const [playTurnSound, setPlayTurnSound] = useState(false);
const [soundPreference, setSoundPreference] = useState(true); // utilisateur
const [enteredNumber, setEnteredNumber] = useState(25);
const [enteredNumberIndices, setEnteredNumberIndices] = useState(3);
//@ts-ignore
const handleNumberChange = (event) => {
const newNumber = Math.max(20, Math.min(50, parseInt(event.target.value, 10)));
setEnteredNumber(newNumber);
};
//@ts-ignore
const handleNumberIndicesChange = (event) => {
const newNumber = Math.max(3, Math.min(6, parseInt(event.target.value, 10)));
setEnteredNumberIndices(newNumber);
};
const handleSoundPreferenceChange = () => {
setSoundPreference(!soundPreference);
console.log("changement des options du son : "+ soundPreference)
@ -346,7 +369,7 @@ const InGame = ({locale, changeLocale}) => {
addToHistory={addToHistory}
solo={IsSolo}
isDaily={isDaily}
isEasy={isEasy}
difficulty={difficulty}
setPlayerTouched={handleSetPlayerTouched}
playerTouched={playerTouched}
setNetwork={setNetworkData}
@ -366,12 +389,13 @@ const InGame = ({locale, changeLocale}) => {
putGreyBackground={putGreyBackgroud}
putImposssibleGrey={putImposssibleGrey}
handleTurn={handleTurn}
lang={locale}/>
lang={locale}
setChangeGraph={setChangeGraphData}/>
</div>
{playTurnSound && <audio src={turnSound} autoPlay />}
{IsSolo && !isDaily &&
{IsSolo && (!isDaily || difficulty !== "hard") &&
<div className='nbLaps' style={{
backgroundColor: theme.colors.primary,
borderColor: theme.colors.secondary
@ -380,7 +404,7 @@ const InGame = ({locale, changeLocale}) => {
</div>
}
{(!isDaily || (isDaily && isEasy)) &&
{(!isDaily || (isDaily && (difficulty==="easy" || difficulty==="intermediate"))) &&
<div className='historique' id="history-container">
{history.map((item, index) => (
<div key={index}>{item}</div>
@ -402,6 +426,7 @@ const InGame = ({locale, changeLocale}) => {
<div className='menuGame'>
<div className='resetDiv'>
<button className='button'
style={{
@ -423,6 +448,8 @@ const InGame = ({locale, changeLocale}) => {
</button>
</div>
@ -514,15 +541,67 @@ const InGame = ({locale, changeLocale}) => {
<Offcanvas show={showS}
onHide={handleCloseS}
placement='top'
style={{height: '30%', width: '30%', left: '70%' }}>
style={{height: '60%', width: '30%', left: '70%' }}>
<Offcanvas.Header closeButton>
<Offcanvas.Title><img src={Param} alt='param'/> <FormattedMessage id='param'/></Offcanvas.Title>
</Offcanvas.Header>
<Offcanvas.Body>
<label style={{ display:'flex'}}>
<Switch checked={soundPreference} onChange={handleSoundPreferenceChange}/>
<p style={{ marginLeft:'20px'}}><FormattedMessage id='sfx'/></p>
</label>
<Offcanvas.Body >
<div style={{display: "flex", justifyContent: "center", flexDirection: "column", alignItems: "center"}}>
<label style={{ display:'flex'}}>
<Switch checked={soundPreference} onChange={handleSoundPreferenceChange}/>
<p style={{ marginLeft:'20px'}}><FormattedMessage id='sfx'/></p>
</label>
{IsSolo &&
<div className='nbNodeDiv'>
<label htmlFor="numberInput">Sélectionner le nombre de noeuds (entre 20 et 50) :</label>
<div>
<button className='valuebutton' onClick={() => { if (enteredNumber>20) setEnteredNumber(enteredNumber-1)}}
style={{borderColor:theme.colors.secondary}}> - </button>
<input
// type="number"
style={{textAlign:'center'}}
id="numberInput"
disabled
value={enteredNumber}
onChange={handleNumberChange}
min={20}
max={60}/>
<button className='valuebutton' onClick={() => { if (enteredNumber<50) setEnteredNumber(enteredNumber+1)}}
style={{borderColor:theme.colors.secondary}}> + </button>
</div>
<button onClick={() => {setHistory([]); changeGraph(enteredNumber, enteredNumberIndices)}}
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary,
}}>Valider</button>
</div>}
{IsSolo &&
<div className='nbNodeDiv'>
<label htmlFor="numberInput">Sélectionner le nombre d'indices (entre 3 et 6) :</label>
<div>
<button className='valuebutton' onClick={() => { if (enteredNumberIndices>3) setEnteredNumberIndices(enteredNumberIndices-1)}}
style={{borderColor:theme.colors.secondary}}> - </button>
<input
// type="number"
style={{textAlign:'center'}}
id="numberInput"
disabled
value={enteredNumberIndices}
onChange={handleNumberIndicesChange}
min={3}
max={6}/>
<button className='valuebutton' onClick={() => { if (enteredNumberIndices<6) setEnteredNumberIndices(enteredNumberIndices+1)}}
style={{borderColor:theme.colors.secondary}}> + </button>
</div>
<button onClick={() => {setHistory([]); changeGraph(enteredNumber, enteredNumberIndices)}}
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary,
}}>Valider</button>
</div>}
</div>
</Offcanvas.Body>
</Offcanvas>
</div>

@ -58,7 +58,7 @@ function Lobby() {
const theme=useTheme();
const navigate = useNavigate();
const { indices, setIndicesData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, setActualPlayerIndexData, setTurnPlayerIndexData, setRoomData, setNodesData } = useGame();
const { indices, setIndicesData, setGameStartData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, setActualPlayerIndexData, setTurnPlayerIndexData, setRoomData, setNodesData } = useGame();
const {user, setUserData, manager, login} = useAuth()
let first = true
@ -139,6 +139,7 @@ function Lobby() {
setPersonData(choosenOne)
setPersonNetworkData(network)
setIndicesData(choosenIndices)
setGameStartData(true)
first = true
gameStarted = true
//socket.off("player left")
@ -177,6 +178,7 @@ function Lobby() {
setPersonData(choosenOne)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
setGameStartData(true)
first = true
gameStarted = true
navigate(`${basePath}/game?solo=false&daily=false`)
@ -187,7 +189,6 @@ function Lobby() {
for (const p of tab.tab){
tmpTab.push(JSONParser.JSONToPlayer(p))
}
console.log(tmpTab);
setPlayersData(tmpTab);
});
@ -209,7 +210,6 @@ function Lobby() {
for (const p of tab.tab){
tmpTab.push(JSONParser.JSONToPlayer(p))
}
console.log(tmpTab)
setPlayersData(tmpTab)
})

@ -43,7 +43,7 @@ function NewPlay() {
const theme=useTheme()
const {isLoggedIn, login, user, setUserData, manager } = useAuth();
const {setDailyEnigmeData, setIndicesData, setPersonData, setPersonNetworkData } = useGame()
const {setDailyEnigmeData, setIndicesData, setPersonData, setPersonNetworkData, setGameStartData } = useGame()
const target = useRef(null);
@ -51,6 +51,7 @@ function NewPlay() {
cptNavigation++
if (cptNavigation % 2 == 0){
if (navigationType.toString() == "POP"){
first=true
socket.emit("player quit")
}
}
@ -100,6 +101,7 @@ function NewPlay() {
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
setIndicesData(choosenIndices)
setGameStartData(true)
navigate(`${basePath}/game?solo=true&daily=false`);
}
@ -162,8 +164,28 @@ function NewPlay() {
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
setIndicesData(choosenIndices)
setGameStartData(true)
navigate(`${basePath}/game?solo=true&daily=true&difficulty=easy`);
setShowOverlay(false);
};
const handleStartMediumGame = () => {
navigate(`${basePath}/game?solo=true&daily=true&easy=true`);
//* Mode facile
//todo différencier les deux
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30)
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
setGameStartData(true)
navigate(`${basePath}/game?solo=true&daily=true&difficulty=intermediate`);
if (first){
first = false
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
setDailyEnigmeData(map)
}
setShowOverlay(false);
};
@ -175,13 +197,13 @@ function NewPlay() {
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
setIndicesData(choosenIndices)
setGameStartData(true)
if (first){
first = false
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
setDailyEnigmeData(map)
}
navigate(`${basePath}/game?solo=true&daily=true&easy=false`);
navigate(`${basePath}/game?solo=true&daily=true&difficulty=hard`);
setShowOverlay(false);
};
@ -206,7 +228,7 @@ function NewPlay() {
<div className='NewbuttonGroupVertical'>
<button onClick={launchMastermind} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> <FormattedMessage id="play.jouerseul"/> </button>
<button ref={target} onClick={launchEngimeJour} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> <FormattedMessage id="play.enigme"/> </button>
<Overlay show={showOverlay} target={target.current} placement="bottom" rootClose={true} rootCloseEvent='click'>
<Overlay show={showOverlay} target={target.current} placement="bottom" rootClose={true} rootCloseEvent='click' onHide={() => setShowOverlay(false)}>
{({ placement, arrowProps, show: _show, popper, ...props }) => (
<div
{...props}
@ -219,7 +241,7 @@ function NewPlay() {
<ButtonGroup aria-label="difficulty">
<Button onClick={handleStartEasyGame}><FormattedMessage id='play.enigme.easy'/></Button>
<Button onClick={handleStartEasyGame}><FormattedMessage id='play.enigme.medium'/></Button>
<Button onClick={handleStartMediumGame}><FormattedMessage id='play.enigme.medium'/></Button>
<Button onClick={handleStartHardGame}><FormattedMessage id='play.enigme.hard'/></Button>
</ButtonGroup>
</div>

@ -29,7 +29,7 @@ class EnigmeDuJourCreator{
possibleIndices.forEach((possibleIndice, index) =>{
const tester = IndiceTesterFactory.Create(possibleIndice)
if (tester.Works(person)){
const t = veryTmpIndice.findIndex((tmpIndice) => tmpIndice.getId() == possibleIndice.getId())
const t = veryTmpIndice.findIndex((tmpIndice) => tmpIndice.getId() == possibleIndice.getId())
if (t != -1){
veryTmpIndice.splice(t, 1)
}
@ -58,10 +58,7 @@ class EnigmeDuJourCreator{
}
possibleIndices = [...tmpPossibleIndices]
modifiedPersons.push(choosenPair)
console.log(possibleIndices)
}
console.log("choosenIndice => " + choosenIndice.ToString("fr"))
console.log("possibleIndices => " + possibleIndices[0].ToString("fr"))
modifiedPersons.forEach((pair) =>{
map.get(pair.first.getId())?.push(new Pair(choosenIndice, pair.second))
})

Loading…
Cancel
Save