Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Arquisoft/wiq_es05c
Browse files Browse the repository at this point in the history
  • Loading branch information
uo282189 committed May 1, 2024
2 parents 5f70380 + 9f43b58 commit 9c7513b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 35 deletions.
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"jest": "^29.7.0",
"react-router-dom": "^6.22.3",
"react-router-dom": "^6.23.0",
"resize-observer-polyfill": "^1.5.1"
}
}
18 changes: 11 additions & 7 deletions webapp/src/components/game/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,20 @@ function Game({darkMode,gameMode=new BasicGame()}) {
} else if (gameModeRef.current.questions.length>0){//comprobar que no sea vacia para que le ljuego no finalize al empezar
console.log("use effect finish");
setIsFinished(true);
//poner el tiepo que tardo
console.log("tiempo total tardado en acabar ",totalTime);
gameModeRef.current.setTiempoTotal(totalTime);
gameModeRef.current.finishGame();
gameModeRef.current.sendHistory({correctas: correctAnswers, incorrectas: incorrectAnswers, tiempoTotal: totalTime});
}

}


}, [correctAnswers, incorrectAnswers,totalTime, isFinished]);//<-cambiar el array de depencias error despliegue

//para aseguarte que el historial se envie una vez lo separas
useEffect(() => {
if (isFinished) {
console.log("tiempo total tardado en acabar ", totalTime);
gameModeRef.current.setTiempoTotal(totalTime);
gameModeRef.current.finishGame();
gameModeRef.current.sendHistory({correctas: correctAnswers, incorrectas: incorrectAnswers, tiempoTotal: totalTime});
}
}, [isFinished]);
const handleTimeout = () => {
handleAnswerSelect(false);
};
Expand Down
10 changes: 8 additions & 2 deletions webapp/src/components/history/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ export function History({darkMode}){
console.log(partidas);

if(partidas.error || partidas.length === 0 ){
console.log('neverPlayer a true en useEffect en partidas');
setNeverPlayer(true);
setIsLoadingGames(false);
}
else{
act(() => {
console.log('neverPlayer a false en useEffect en partidas');
console.log('setAllGames ', Object.values(partidas));
let gamesArray = Object.values(partidas);
setAllGames(gamesArray);
setIsLoadingGames(false);
Expand All @@ -53,14 +56,17 @@ export function History({darkMode}){
fetch(statisticsEndpoint)
.then(response => response.json())
.then(estadisticas => {
//console.log("Estadísticas: ");
//console.log(estadisticas);
console.log("Estadísticas: ");
console.log(estadisticas);
if(estadisticas.error || estadisticas.length === 0 ){
console.log('neverPlayer a true en useEffect en estadisticas');
setNeverPlayer(true);
setIsLoadingStats(false);
}
else{
act(() => {
//console.log('neverPlayer a false en useEffect en estadisticas');
//console.log('setAllGames ', Object.values(estadisticas));
setStatistics(estadisticas);
setIsLoadingStats(false);
});
Expand Down

0 comments on commit 9c7513b

Please sign in to comment.