Skip to content

Commit

Permalink
Merged PR 4249: Bug fix for Double rolling animation
Browse files Browse the repository at this point in the history
This is a fix for the double-rolling animation. The animation played twice when a player was waiting for other players.

QA:
- start a game and let one player roll the dice and press the ready button
- One other player must do nothing and let the time run out.
- check if the rolling dice animation is not displaying

Related work items: #18857
  • Loading branch information
Mautjee committed May 17, 2023
1 parent 66a8798 commit 6687dd9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 3 additions & 8 deletions frontend/src/components/roll-dice/roll-dice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FadeTransition } from "../page-transition";
import { Timer } from "../timer";
import { PrimaryButton } from "../../molecules";
import { useClientTimer } from "../../hooks";
import { WaitingForPlayers } from "./waiting-for-players";

export const RollDice: FC = () => {
const { sendMatchState } = useMatch();
Expand All @@ -26,7 +27,7 @@ export const RollDice: FC = () => {
const isPlayerReady = useStore((state) => state.isPlayerReady);
const dice = useStore((state) => state.diceValue);

const { count } = useClientTimer(hasRolledDice);
useClientTimer(hasRolledDice);

if (!localPlayer) return <ErrorView />;

Expand All @@ -45,13 +46,7 @@ export const RollDice: FC = () => {
};

// In case of timeout player shouldn't be see this view.
if (hasRolledDice && isPlayerReady && count !== 0) {
return (
<BottomButtonWrapper>
<MatchHeading headingOne={text.powerUps.timeToWait} headingTwo={text.powerUps.waitForPlayers} isAnimated />
</BottomButtonWrapper>
);
}
if (isPlayerReady) return <WaitingForPlayers />;

return (
<FadeTransition>
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/components/roll-dice/waiting-for-players.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { text } from "../../assets";
import { BottomButtonWrapper } from "../../atoms";
import { MatchHeading } from "../match-heading";

export const WaitingForPlayers = () => {
return (
<BottomButtonWrapper>
<MatchHeading headingOne={text.powerUps.timeToWait} headingTwo={text.powerUps.waitForPlayers} isAnimated />
</BottomButtonWrapper>
);
};
6 changes: 4 additions & 2 deletions frontend/src/service/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ export const useMatch = () => {

const delayBroadcastPlayerReady = (delay: number) => {
setSpinnerVisibility(true);
setPlayerReady(true);

const timeout = setTimeout(() => broadcastPlayerReady(), delay);
const timeout = setTimeout(() => {
setPlayerReady(true);
broadcastPlayerReady();
}, delay);
return () => clearTimeout(timeout);
};

Expand Down

0 comments on commit 6687dd9

Please sign in to comment.