Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #284 from Arquisoft/FixTimer
Browse files Browse the repository at this point in the history
Fixed timer
  • Loading branch information
RubenFern committed Apr 23, 2024
2 parents 2f55e13 + 7611886 commit 33bc69f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions webapp/src/components/game/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const Game = ({finishFunction, name, tags}) => {
const [loading, setLoading] = useState(true);
const [time , setTime] = useState(undefined);
const [remTime, setRemTime] = useState(0);
const [percentage, setPercentage] = useState(0);
const location = useLocation();

const againstClockFinish = async () => {
Expand Down Expand Up @@ -173,7 +174,8 @@ export const Game = ({finishFunction, name, tags}) => {

percentage = (trans/total) * 100;
invertedPercentage = 100 - Number(percentage);


setPercentage(invertedPercentage)
setRemTime((invertedPercentage/100)*gameTime);
}else{
gameTime = basicGameSetting.durationQuestion ;
Expand All @@ -183,9 +185,9 @@ export const Game = ({finishFunction, name, tags}) => {
percentage = (trans/total) * 100;
invertedPercentage = 100 - Number(percentage);

setPercentage(invertedPercentage)
setRemTime((invertedPercentage/100)*gameTime);
}

if(percentage > 100){
comprobarPregunta("");
time = undefined;
Expand Down Expand Up @@ -330,7 +332,7 @@ export const Game = ({finishFunction, name, tags}) => {
}}
className="text-black dark:text-white "
>
<LinearProgress color='inherit' variant={loading? "indeterminate" : "determinate"} value={remTime} />
<LinearProgress color='inherit' variant={loading? "indeterminate" : "determinate"} value={percentage} />
</Box>
</Container>
</Container>
Expand Down

0 comments on commit 33bc69f

Please sign in to comment.