|
|
@ -1,4 +1,4 @@
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
|
|
|
|
|
|
|
|
|
|
/* Context */
|
|
|
|
/* Context */
|
|
|
|
import { useAuth } from '../Contexts/AuthContext';
|
|
|
|
import { useAuth } from '../Contexts/AuthContext';
|
|
|
@ -28,6 +28,13 @@ import Stub from '../model/Stub';
|
|
|
|
import SessionService from '../services/SessionService';
|
|
|
|
import SessionService from '../services/SessionService';
|
|
|
|
import { loadImageAsync } from '../ImageHelper';
|
|
|
|
import { loadImageAsync } from '../ImageHelper';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Overlay, ToggleButton, ToggleButtonGroup } from 'react-bootstrap';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import Button from 'react-bootstrap/Button';
|
|
|
|
|
|
|
|
import ButtonGroup from 'react-bootstrap/ButtonGroup';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Play() {
|
|
|
|
function Play() {
|
|
|
|
let first = true
|
|
|
|
let first = true
|
|
|
|
|
|
|
|
|
|
|
@ -35,6 +42,9 @@ function Play() {
|
|
|
|
const {isLoggedIn, login, user, setUserData, manager } = useAuth();
|
|
|
|
const {isLoggedIn, login, user, setUserData, manager } = useAuth();
|
|
|
|
const {setDailyEnigmeData} = useGame()
|
|
|
|
const {setDailyEnigmeData} = useGame()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const target = useRef(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchUserInformation = async () => {
|
|
|
|
const fetchUserInformation = async () => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -124,17 +134,11 @@ function Play() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function launchEngimeJour(){
|
|
|
|
function launchEngimeJour(){
|
|
|
|
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30)
|
|
|
|
//* overlay
|
|
|
|
setPersonData(choosenPerson)
|
|
|
|
|
|
|
|
setPersonNetworkData(networkPerson)
|
|
|
|
if (!showOverlay)setShowOverlay(true)
|
|
|
|
setIndicesData(choosenIndices)
|
|
|
|
else setShowOverlay(true)
|
|
|
|
setIndicesData(choosenIndices)
|
|
|
|
|
|
|
|
if (first){
|
|
|
|
|
|
|
|
first = false
|
|
|
|
|
|
|
|
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
|
|
|
|
|
|
|
|
setDailyEnigmeData(map)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
navigate('/game?solo=true&daily=true');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -160,6 +164,53 @@ function Play() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [room, navigate]);
|
|
|
|
}, [room, navigate]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [showOverlay, setShowOverlay] = useState(false);
|
|
|
|
|
|
|
|
const [selectedDifficulty, setSelectedDifficulty] = useState(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
|
|
|
const handleDifficultyChange = (value) => {
|
|
|
|
|
|
|
|
setSelectedDifficulty(value);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleStartEasyGame = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//* Mode facile
|
|
|
|
|
|
|
|
//todo différencier les deux
|
|
|
|
|
|
|
|
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30)
|
|
|
|
|
|
|
|
setPersonData(choosenPerson)
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
setShowOverlay(false);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleStartHardGame = () => {
|
|
|
|
|
|
|
|
//* Mode difficile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//todo différencier les deux
|
|
|
|
|
|
|
|
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30)
|
|
|
|
|
|
|
|
setPersonData(choosenPerson)
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
setShowOverlay(false);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|
|
|
|
|
|
|
|
<div className="MainContainer">
|
|
|
|
<div className="MainContainer">
|
|
|
@ -182,7 +233,29 @@ function Play() {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='buttonGroupVertical'>
|
|
|
|
<div className='buttonGroupVertical'>
|
|
|
|
<button onClick={launchMastermind} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Jouer seul </button>
|
|
|
|
<button onClick={launchMastermind} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Jouer seul </button>
|
|
|
|
<button onClick={launchEngimeJour} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Résoudre une énigme</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button ref={target} onClick={launchEngimeJour} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Résoudre une énigme</button>
|
|
|
|
|
|
|
|
<Overlay show={showOverlay} target={target.current} placement="bottom" rootClose={true} rootCloseEvent='click'>
|
|
|
|
|
|
|
|
{({ placement, arrowProps, show: _show, popper, ...props }) => (
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
{...props}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
backgroundColor: theme.colors.secondary,
|
|
|
|
|
|
|
|
padding: '2px 10px',
|
|
|
|
|
|
|
|
borderRadius: 3,
|
|
|
|
|
|
|
|
...props.style,
|
|
|
|
|
|
|
|
}}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ButtonGroup aria-label="difficulty">
|
|
|
|
|
|
|
|
<Button onClick={handleStartEasyGame}>Facile</Button>
|
|
|
|
|
|
|
|
<Button onClick={handleStartHardGame}>Difficile</Button>
|
|
|
|
|
|
|
|
</ButtonGroup>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</Overlay>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button onClick={createLobby} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Créer une partie </button>
|
|
|
|
<button onClick={createLobby} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Créer une partie </button>
|
|
|
|
<button className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button>
|
|
|
|
<button className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button>
|
|
|
|
|
|
|
|
|
|
|
|