Compare commits

..

No commits in common. "3717240ce9b9f9777c4a95b790703e9d4fa49dfc" and "a7d644e787b421584607a62565f4d3bf06bdb7be" have entirely different histories.

5 changed files with 29 additions and 29 deletions

View File

@ -5,24 +5,24 @@ import { motion } from "framer-motion";
export default function AnimatedPage({ children, className }) { export default function AnimatedPage({ children, className }) {
const location = useLocation(); const location = useLocation();
// const isNext = location.state && location.state.isNext; const isNext = location.state && location.state.isNext;
// const isPrev = location.state && location.state.isPrev; const isPrev = location.state && location.state.isPrev;
// const isGoingNext = location.state && location.state.isGoingNext; const isGoingNext = location.state && location.state.isGoingNext;
// function getAnimationParameters() { function getAnimationParameters() {
// const animationParameters = { animate: { x: "0%", opacity: 1 } }; const animationParameters = { animate: { x: "0%", opacity: 1 } };
// if (isNext === true) { if (isNext === true) {
// animationParameters.initial = { x: "50%", opacity: 0 }; animationParameters.initial = { x: "50%", opacity: 0 };
// } else { } else {
// animationParameters.initial = { x: "-50%", opacity: 0 }; animationParameters.initial = { x: "-50%", opacity: 0 };
// } }
// if (isGoingNext === true) { if (isGoingNext === true) {
// animationParameters.exit = { x: "-50%", opacity: 0 }; animationParameters.exit = { x: "-50%", opacity: 0 };
// } else { } else {
// animationParameters.exit = { x: "50%", opacity: 0 }; animationParameters.exit = { x: "50%", opacity: 0 };
// } }
// return animationParameters; return animationParameters;
// } }
// const animationParameters = getAnimationParameters(); // const animationParameters = getAnimationParameters();
const animationParameters = { const animationParameters = {
initial: { x: "50%", opacity: 0 }, initial: { x: "50%", opacity: 0 },

View File

@ -13,7 +13,7 @@ export default function GameContainer({ gameId }) {
const [isDragging, setIsDragging] = useState(false); const [isDragging, setIsDragging] = useState(false);
const [startX, setStartX] = useState(0); const [startX, setStartX] = useState(0);
const { contextGameDatas, setContextGameDatas, isGameComplete } = useGame(); const { contextGameDatas, setContextGameDatas, isGameComplete, score } = useGame();
useEffect(() => { useEffect(() => {
if (!gameDatas || gameDatas.error) return; if (!gameDatas || gameDatas.error) return;

View File

@ -15,7 +15,7 @@ export default function Timer() {
// setCurrentTime(currentTime); // setCurrentTime(currentTime);
return () => clearInterval(intervalId); return () => clearInterval(intervalId);
}, [hasCheckedTutorial, gameTime, isTimeRuning, setGameTime]); }, [hasCheckedTutorial, gameTime, isTimeRuning]);
const gameFormatedTime = formatCurrentTime(gameTime); const gameFormatedTime = formatCurrentTime(gameTime);

View File

@ -1,4 +1,4 @@
import { createContext, useEffect, useState, useCallback } from "react"; import { createContext, useEffect, useState } from "react";
// import chantierAtmopshere from "../assets/sounds/chantier_1.mp3"; // import chantierAtmopshere from "../assets/sounds/chantier_1.mp3";
import GameAnswerExplanation from "../components/game/GameAnswerExplanation.jsx"; import GameAnswerExplanation from "../components/game/GameAnswerExplanation.jsx";
import { useUser } from "../hooks/useUser.jsx"; import { useUser } from "../hooks/useUser.jsx";
@ -32,7 +32,13 @@ export function GameContextProvider({ children }) {
const [isGameComplete, setIsGameComplete] = useState(false); const [isGameComplete, setIsGameComplete] = useState(false);
// ##### INIT DATAS ##### // ##### INIT DATAS #####
const initAnswers = useCallback(() => { useEffect(() => {
if (!contextGameDatas) return;
initAnswers();
setRemainingQuestionsAmount(contextGameDatas.gameObjects.length);
}, [contextGameDatas]);
function initAnswers() {
const answersArray = contextGameDatas.gameObjects.map((object, key) => { const answersArray = contextGameDatas.gameObjects.map((object, key) => {
return { return {
correctAnswer: object.attrs.behaviourType ? object.attrs.behaviourType : "unsafe", correctAnswer: object.attrs.behaviourType ? object.attrs.behaviourType : "unsafe",
@ -41,13 +47,7 @@ export function GameContextProvider({ children }) {
}; };
}); });
setAnswers(answersArray); setAnswers(answersArray);
}, [contextGameDatas]); }
useEffect(() => {
if (!contextGameDatas) return;
initAnswers();
setRemainingQuestionsAmount(contextGameDatas.gameObjects.length);
}, [contextGameDatas, initAnswers]);
function answerQuestion(answerKey, answer) { function answerQuestion(answerKey, answer) {
if (!answer || answerKey === null) return; if (!answer || answerKey === null) return;

View File

@ -40,7 +40,7 @@ export function UserContextProvider({ children }) {
(countryJson) => countryJson.alpha2 === country.iso.toLowerCase() (countryJson) => countryJson.alpha2 === country.iso.toLowerCase()
); );
setCountry({ ...country, label: currentCountry[language.toLowerCase()] }); setCountry({ ...country, label: currentCountry[language.toLowerCase()] });
}, [language, country]); }, [language]);
function changeUserLanguage(newLanguage) { function changeUserLanguage(newLanguage) {
setLanguage(newLanguage); setLanguage(newLanguage);