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 }) {
const location = useLocation();
// const isNext = location.state && location.state.isNext;
// const isPrev = location.state && location.state.isPrev;
// const isGoingNext = location.state && location.state.isGoingNext;
const isNext = location.state && location.state.isNext;
const isPrev = location.state && location.state.isPrev;
const isGoingNext = location.state && location.state.isGoingNext;
// function getAnimationParameters() {
// const animationParameters = { animate: { x: "0%", opacity: 1 } };
// if (isNext === true) {
// animationParameters.initial = { x: "50%", opacity: 0 };
// } else {
// animationParameters.initial = { x: "-50%", opacity: 0 };
// }
// if (isGoingNext === true) {
// animationParameters.exit = { x: "-50%", opacity: 0 };
// } else {
// animationParameters.exit = { x: "50%", opacity: 0 };
// }
// return animationParameters;
// }
function getAnimationParameters() {
const animationParameters = { animate: { x: "0%", opacity: 1 } };
if (isNext === true) {
animationParameters.initial = { x: "50%", opacity: 0 };
} else {
animationParameters.initial = { x: "-50%", opacity: 0 };
}
if (isGoingNext === true) {
animationParameters.exit = { x: "-50%", opacity: 0 };
} else {
animationParameters.exit = { x: "50%", opacity: 0 };
}
return animationParameters;
}
// const animationParameters = getAnimationParameters();
const animationParameters = {
initial: { x: "50%", opacity: 0 },

View File

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

View File

@ -15,7 +15,7 @@ export default function Timer() {
// setCurrentTime(currentTime);
return () => clearInterval(intervalId);
}, [hasCheckedTutorial, gameTime, isTimeRuning, setGameTime]);
}, [hasCheckedTutorial, gameTime, isTimeRuning]);
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 GameAnswerExplanation from "../components/game/GameAnswerExplanation.jsx";
import { useUser } from "../hooks/useUser.jsx";
@ -32,7 +32,13 @@ export function GameContextProvider({ children }) {
const [isGameComplete, setIsGameComplete] = useState(false);
// ##### INIT DATAS #####
const initAnswers = useCallback(() => {
useEffect(() => {
if (!contextGameDatas) return;
initAnswers();
setRemainingQuestionsAmount(contextGameDatas.gameObjects.length);
}, [contextGameDatas]);
function initAnswers() {
const answersArray = contextGameDatas.gameObjects.map((object, key) => {
return {
correctAnswer: object.attrs.behaviourType ? object.attrs.behaviourType : "unsafe",
@ -41,13 +47,7 @@ export function GameContextProvider({ children }) {
};
});
setAnswers(answersArray);
}, [contextGameDatas]);
useEffect(() => {
if (!contextGameDatas) return;
initAnswers();
setRemainingQuestionsAmount(contextGameDatas.gameObjects.length);
}, [contextGameDatas, initAnswers]);
}
function answerQuestion(answerKey, answer) {
if (!answer || answerKey === null) return;

View File

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