From 4615ca9b8b1989d315ae2322556697b97161b97b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 17 Sep 2025 19:08:58 +0900 Subject: feat(frontend): apply effect for high score --- frontend/app/components/Gaming/Score.tsx | 38 ++++++++++++++++++++++ .../GolfWatchApps/GolfWatchAppGaming1v1.tsx | 9 +++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 frontend/app/components/Gaming/Score.tsx (limited to 'frontend') diff --git a/frontend/app/components/Gaming/Score.tsx b/frontend/app/components/Gaming/Score.tsx new file mode 100644 index 0000000..9b6283f --- /dev/null +++ b/frontend/app/components/Gaming/Score.tsx @@ -0,0 +1,38 @@ +import { useEffect, useState } from "react"; + +type Props = { + status: string | null; + score: number | null; +}; + +export default function Score({ status, score }: Props) { + const [displayScore, setDisplayScore] = useState(score); + + useEffect(() => { + let intervalId = null; + + if (status === "running") { + intervalId = setInterval(() => { + const maxValue = Math.pow(10, String(score).length) - 1; + const minValue = Math.pow(10, String(score).length - 1); + const randomValue = + Math.floor(Math.random() * (maxValue - minValue + 1)) + minValue; + setDisplayScore(randomValue); + }, 50); + } else { + setDisplayScore(score); + } + + return () => { + if (intervalId) { + clearInterval(intervalId); + } + }; + }, [status, score]); + + return ( + + {displayScore} + + ); +} diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx index f06728d..4a9cf92 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx @@ -13,6 +13,7 @@ import CodeBlock from "../Gaming/CodeBlock"; import LeftTime from "../Gaming/LeftTime"; import ProblemColumnContent from "../Gaming/ProblemColumnContent"; import RankingTable from "../Gaming/RankingTable"; +import Score from "../Gaming/Score"; import ScoreBar from "../Gaming/ScoreBar"; import SubmitStatusLabel from "../SubmitStatusLabel"; import ThreeColumnLayout from "../ThreeColumnLayout"; @@ -82,7 +83,9 @@ export default function GolfWatchAppGaming1v1({ {playerProfileA?.displayName} -
{scoreA}
+
+ +
{gameDisplayName}
@@ -99,7 +102,9 @@ export default function GolfWatchAppGaming1v1({ )}
-
{scoreB}
+
+ +
{playerProfileB?.displayName} -- cgit v1.2.3-70-g09d2