Skip to content

Commit

Permalink
Changes to adapt to e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uo288347 committed Apr 2, 2024
1 parent 983f0a8 commit ced2a0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion webapp/src/pages/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Game = () => {
setQuestionCountdownRunning(false);
updateStatistics();
}
}, [round]);
}, [round, updateStatistics]);

// stablish if the confetti must show or not
React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/pages/Homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Homepage = () => {

//if online mode -> change link to go to online room
const changeGameLink = (index) => {
if(info[index].nombre == "ONLINE MODE") {
if(info[index].nombre === "ONLINE MODE") {
setGameLink("/multiplayerRoom")
} else {
setGameLink("/game")
Expand Down
17 changes: 8 additions & 9 deletions webapp/src/pages/MultiplayerGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import axios from 'axios';

import { Container, Button, CssBaseline, Grid, Typography, CircularProgress } from '@mui/material';
import { PlayArrow, Pause } from '@mui/icons-material';
import CheckIcon from '@mui/icons-material/Check';
import ClearIcon from '@mui/icons-material/Clear';
import { useNavigate } from 'react-router-dom';
Expand All @@ -19,7 +18,7 @@ const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000
const socketEndpoint = process.env.MULTIPLAYER_ENDPOINT || 'ws://localhost:5010';

const Game = () => {
const navigate = useNavigate();
//const navigate = useNavigate();
const MAX_ROUNDS = 3;
const SUCCESS_SOUND_ROUTE = "/sounds/success_sound.mp3";
const FAILURE_SOUND_ROUTE = "/sounds/wrong_sound.mp3";
Expand Down Expand Up @@ -61,7 +60,7 @@ const Game = () => {
setWinnerCorrect(winnerCorrect);
setWinnerTime(winnerTime);
}))
}, []);
}, [roomCode, username]);

React.useEffect(() => {
let timer;
Expand All @@ -85,16 +84,16 @@ const Game = () => {
setShouldRedirect(true);
setQuestionCountdownRunning(false);
}
}, [round]);
}, [round, startNewRound]);

// stablish if the confetti must show or not
React.useEffect(() => {
if (winnerPlayer == username) {
if (winnerPlayer === username) {
setShowConfetti(true);
} else {
setShowConfetti(false);
}
}, [winnerPlayer]);
}, [winnerPlayer, username]);


// gets a random question from the database and initializes button states to null
Expand Down Expand Up @@ -183,7 +182,7 @@ const Game = () => {
));
};

const togglePause = () => {
/*const togglePause = () => {
setTimerRunning(!timerRunning);
setQuestionCountdownRunning(!timerRunning);
if (timerRunning) {
Expand All @@ -193,7 +192,7 @@ const Game = () => {
// Si el juego estaba pausado y se reanuda, habilitar los botones
setButtonStates(new Array(questionData.options.length).fill(null));
}
}
}*/


// circular loading
Expand Down Expand Up @@ -244,7 +243,7 @@ if (shouldRedirect) {
marginBottom: '50px', // Espaciado inferior
}}
>
{winnerPlayer == "" ? "Waiting for players end..." : "Game Over"}
{winnerPlayer === "" ? "Waiting for players end..." : "Game Over"}
</Typography>
<div>
<Typography variant="h6">Correct Answers: {correctlyAnsweredQuestions}</Typography>
Expand Down

0 comments on commit ced2a0a

Please sign in to comment.