diff --git a/src/lib/Room.svelte b/src/lib/Room.svelte index 1385e50..4325088 100644 --- a/src/lib/Room.svelte +++ b/src/lib/Room.svelte @@ -7,6 +7,13 @@ import type { Room } from './types'; let { room }: { room: Room } = $props(); + + let secondsRemaining = $state(room.secondsRemaining); + + const interval = setInterval(() => { + if (secondsRemaining <= 0 || room.finished) clearInterval(interval); + secondsRemaining--; + }, 1000);
@@ -24,6 +31,9 @@ room battle rank {room.roomBattleRank}

+ {#if !room.finished} +

seconds remaining {secondsRemaining}s

+ {/if}
diff --git a/src/lib/server/fetchData.ts b/src/lib/server/fetchData.ts index 0de436c..dacd46e 100644 --- a/src/lib/server/fetchData.ts +++ b/src/lib/server/fetchData.ts @@ -25,6 +25,8 @@ function toRoom(apiRoom: APIRoom): Room { createdAt: new Date(apiRoom.updatedAt), gameVersion: apiRoom.dataVersion, roomBattleRank: apiRoom.roomRanking, + secondsRemaining: apiRoom.restMSec, + finished: apiRoom.isFinished, players: apiRoom.matchingMemberInfoList.map((apiPlayer) => toPlayer(apiPlayer)) }; } diff --git a/src/lib/types.ts b/src/lib/types.ts index 74c21f8..f30c67a 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -60,6 +60,8 @@ export interface Room { createdAt: Date; gameVersion: string; roomBattleRank: number; + secondsRemaining: number; + finished: boolean; players: Player[]; } @@ -69,7 +71,7 @@ export interface APIRoom { dataVersion: string; romVersion: string; roomRanking: number; - roomMSec: number; + restMSec: number; isFull: boolean; matchingMemberInfoList: APIPlayer[]; isFinished: boolean;