From 11997698b920a2bece93a57bbd7062ae809c5329 Mon Sep 17 00:00:00 2001 From: amanasati01 Date: Tue, 14 May 2024 23:22:24 +0530 Subject: [PATCH] make ui of top, down bar and timer more attractive --- apps/frontend/src/screens/Game.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/screens/Game.tsx b/apps/frontend/src/screens/Game.tsx index e83fdabf..eba5c3a2 100644 --- a/apps/frontend/src/screens/Game.tsx +++ b/apps/frontend/src/screens/Game.tsx @@ -214,6 +214,9 @@ export const Game = () => { const getTimer = (timeConsumed: number) => { const timeLeftMs = GAME_TIME_MS - timeConsumed; + if (timeLeftMs <= 0) { + return
Time's up!
; + } const minutes = Math.floor(timeLeftMs / (1000 * 60)); const remainingSeconds = Math.floor((timeLeftMs % (1000 * 60)) / 1000); @@ -237,23 +240,15 @@ export const Game = () => { gameResult={result} > )} - {started && ( -
- {(user.id === gameMetadata?.blackPlayer?.id ? 'b' : 'w') === - chess.turn() - ? 'Your turn' - : "Opponent's turn"} -
- )}
-
+
{started && ( -
+
{ : gameMetadata?.whitePlayer?.name ?? '' } /> +
+ {(user.id === gameMetadata?.blackPlayer?.id ? 'b' : 'w') === + chess.turn() + ? 'Your turn' + : "Opponent's turn"} +
+ {getTimer( user.id === gameMetadata?.whitePlayer?.id ? player2TimeConsumed @@ -287,7 +289,7 @@ export const Game = () => {
{started && ( -
+
{
); -}; +}; \ No newline at end of file