1
0

Updated the Game.jsx

This commit is contained in:
Mathias Wagner 2023-11-21 10:37:10 +01:00
parent 06569399eb
commit 9a6fc17a71
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -12,7 +12,7 @@ export const Game = () => {
const {groups, allGroups} = useContext(GroupContext); const {groups, allGroups} = useContext(GroupContext);
const [currentState, setCurrentState] = useState("hint"); const [currentState, setCurrentState] = useState("hint");
const [currentRound, setCurrentRound] = useState(0);
const {musicEnabled} = useContext(MusicContext); const {musicEnabled} = useContext(MusicContext);
@ -24,6 +24,10 @@ export const Game = () => {
return () => clearTimeout(timeout); return () => clearTimeout(timeout);
}, []); }, []);
useEffect(() => {
if (currentState === "waiting") setCurrentRound(current => current + 1);
}, [currentState]);
if (groups.length === 0 && allGroups.length === 0) if (groups.length === 0 && allGroups.length === 0)
return <Navigate to="/"/>; return <Navigate to="/"/>;
@ -37,7 +41,7 @@ export const Game = () => {
</h2> </h2>
</>} </>}
{currentState === "waiting" && <Waiting setState={setCurrentState}/>} {currentState === "waiting" && <Waiting setState={setCurrentState}/>}
{currentState === "calculate" && <Calculate setState={setCurrentState}/>} {currentState === "calculate" && <Calculate setState={setCurrentState} currentRound={currentRound}/>}
</div> </div>
) )
} }