enigme intermédiaire + overlay qui se barre
continuous-integration/drone/push Build is passing Details

changeGraphSize
Thomas Chazot 1 year ago
parent c5aa5ea930
commit 94219e01d3

@ -35,7 +35,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
@ -90,7 +90,7 @@ let testFirst = false
let testFirst2 = true
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, nbNodes, setChangeGraph}) => {
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, nbNodes, setChangeGraph}) => {
let cptTour: number = 1
//* Gestion du temps :
@ -451,7 +451,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
@ -464,7 +466,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
});
}
else{
else if (difficulty === "easy"){
if (firstHistory){
firstHistory=false
indices.forEach((indice, index) => {
@ -757,7 +759,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
else {
if (firstLap){
firstLap=false
if (!isDaily){
if (solo && (difficulty === "intermediate" || !isDaily)){
addToHistory("<----- [Tour " + 1 +"/"+networkData.nodes.length + "] ----->");
}
}
@ -1082,9 +1084,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);
}
@ -1114,10 +1118,29 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`)
}
else{
addToHistory(personTest.getName() + " n'est pas le coupable !"); //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
if (isDaily){
if (difficulty==="intermediate"){
addToHistory(personTest.getName() + " n'est pas le coupable !"); //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
}
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() + " n'est pas le coupable !"); //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
}
}
}
}

@ -37,7 +37,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
@ -131,7 +131,7 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
setOnlyFalse(newOnlyFalse)
}
const setWinnerData = (winner: Player) =>{
const setWinnerData = (winner: Player | null) =>{
setWinner(winner)
}

@ -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)
@ -360,7 +361,7 @@ const InGame = ({locale, changeLocale}) => {
addToHistory={addToHistory}
solo={IsSolo}
isDaily={isDaily}
isEasy={isEasy}
difficulty={difficulty}
setPlayerTouched={handleSetPlayerTouched}
playerTouched={playerTouched}
setNetwork={setNetworkData}
@ -386,7 +387,7 @@ const InGame = ({locale, changeLocale}) => {
{playTurnSound && <audio src={turnSound} autoPlay />}
{IsSolo && !isDaily &&
{IsSolo && (!isDaily || difficulty !== "hard") &&
<div className='nbLaps' style={{
backgroundColor: theme.colors.primary,
borderColor: theme.colors.secondary
@ -395,7 +396,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>

@ -50,6 +50,7 @@ function NewPlay() {
cptNavigation++
if (cptNavigation % 2 == 0){
if (navigationType.toString() == "POP"){
first=true
socket.emit("player quit")
}
}
@ -162,7 +163,26 @@ function NewPlay() {
setIndicesData(choosenIndices)
setIndicesData(choosenIndices)
navigate(`${basePath}/game?solo=true&daily=true&easy=true`);
navigate(`${basePath}/game?solo=true&daily=true&difficulty=easy`);
setShowOverlay(false);
};
const handleStartMediumGame = () => {
//* Mode facile
//todo différencier les deux
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30)
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
setIndicesData(choosenIndices)
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);
};
@ -180,7 +200,7 @@ function NewPlay() {
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);
};
@ -205,7 +225,7 @@ function NewPlay() {
<div className='NewbuttonGroupVertical'>
<button onClick={launchMastermind} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Jouer seul </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'>
<Overlay show={showOverlay} target={target.current} placement="bottom" rootClose={true} rootCloseEvent='click' onHide={() => setShowOverlay(false)}>
{({ placement, arrowProps, show: _show, popper, ...props }) => (
<div
{...props}
@ -218,6 +238,7 @@ function NewPlay() {
<ButtonGroup aria-label="difficulty">
<Button onClick={handleStartEasyGame}>Facile</Button>
<Button onClick={handleStartMediumGame}>Intermédiaire</Button>
<Button onClick={handleStartHardGame}>Difficile</Button>
</ButtonGroup>
</div>

Loading…
Cancel
Save