Skip to content

Commit 998e47f

Browse files
Merge pull request #136 from CSSLab/copilot/fix-135
Fix GameClock to display Maia strength level (e.g., "Maia 1100")
2 parents 0aa2cd5 + f1a6abf commit 998e47f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/components/Board/GameClock.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ export const GameClock: React.FC<Props> = (
1313
props: React.PropsWithChildren<Props>,
1414
) => {
1515
const { user } = useContext(AuthContext)
16-
const { player, toPlay, whiteClock, blackClock, lastMoveTime } = useContext(
17-
PlayControllerContext,
18-
)
16+
const { player, toPlay, whiteClock, blackClock, lastMoveTime, maiaVersion } =
17+
useContext(PlayControllerContext)
1918

2019
const [referenceTime, setReferenceTime] = useState<number>(Date.now())
2120

22-
const playerClock = props.player == 'white' ? whiteClock : blackClock
23-
const active = toPlay == props.player
21+
const playerClock = props.player === 'white' ? whiteClock : blackClock
22+
const active = toPlay === props.player
2423

2524
const clock = Math.max(
2625
active && lastMoveTime > 0
@@ -29,6 +28,11 @@ export const GameClock: React.FC<Props> = (
2928
0,
3029
)
3130

31+
// Convert maiaVersion (e.g., "maia_kdd_1100") to display name (e.g., "Maia 1100")
32+
const getMaiaDisplayName = (version: string): string => {
33+
return version.replace('maia_kdd_', 'Maia ')
34+
}
35+
3236
useEffect(() => {
3337
setReferenceTime(Date.now())
3438

@@ -51,8 +55,10 @@ export const GameClock: React.FC<Props> = (
5155
className={`flex items-center justify-between bg-background-1 md:items-start md:justify-start ${active ? 'opacity-100' : 'opacity-50'} flex-row md:flex-col`}
5256
>
5357
<div className="px-4 py-2">
54-
{props.player == 'black' ? '●' : '○'}{' '}
55-
{player == props.player ? user?.displayName : 'Maia'}
58+
{props.player === 'black' ? '●' : '○'}{' '}
59+
{player === props.player
60+
? user?.displayName
61+
: getMaiaDisplayName(maiaVersion)}
5662
</div>
5763
<div className="inline-flex self-start px-4 py-2 md:text-3xl">
5864
{minutes}:{('00' + seconds).slice(-2)}

0 commit comments

Comments
 (0)