feat: show room timer
This commit is contained in:
parent
ded50f8780
commit
3a71072bc9
@ -7,6 +7,13 @@
|
|||||||
import type { Room } from './types';
|
import type { Room } from './types';
|
||||||
|
|
||||||
let { room }: { room: Room } = $props();
|
let { room }: { room: Room } = $props();
|
||||||
|
|
||||||
|
let secondsRemaining = $state(room.secondsRemaining);
|
||||||
|
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
if (secondsRemaining <= 0 || room.finished) clearInterval(interval);
|
||||||
|
secondsRemaining--;
|
||||||
|
}, 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-8 rounded-lg bg-medium p-6">
|
<div class="flex flex-col gap-8 rounded-lg bg-medium p-6">
|
||||||
@ -24,6 +31,9 @@
|
|||||||
room battle rank <Separator />
|
room battle rank <Separator />
|
||||||
{room.roomBattleRank}
|
{room.roomBattleRank}
|
||||||
</p>
|
</p>
|
||||||
|
{#if !room.finished}
|
||||||
|
<p class="flex items-center gap-2">seconds remaining <Separator /> {secondsRemaining}s</p>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ function toRoom(apiRoom: APIRoom): Room {
|
|||||||
createdAt: new Date(apiRoom.updatedAt),
|
createdAt: new Date(apiRoom.updatedAt),
|
||||||
gameVersion: apiRoom.dataVersion,
|
gameVersion: apiRoom.dataVersion,
|
||||||
roomBattleRank: apiRoom.roomRanking,
|
roomBattleRank: apiRoom.roomRanking,
|
||||||
|
secondsRemaining: apiRoom.restMSec,
|
||||||
|
finished: apiRoom.isFinished,
|
||||||
players: apiRoom.matchingMemberInfoList.map((apiPlayer) => toPlayer(apiPlayer))
|
players: apiRoom.matchingMemberInfoList.map((apiPlayer) => toPlayer(apiPlayer))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ export interface Room {
|
|||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
gameVersion: string;
|
gameVersion: string;
|
||||||
roomBattleRank: number;
|
roomBattleRank: number;
|
||||||
|
secondsRemaining: number;
|
||||||
|
finished: boolean;
|
||||||
players: Player[];
|
players: Player[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +71,7 @@ export interface APIRoom {
|
|||||||
dataVersion: string;
|
dataVersion: string;
|
||||||
romVersion: string;
|
romVersion: string;
|
||||||
roomRanking: number;
|
roomRanking: number;
|
||||||
roomMSec: number;
|
restMSec: number;
|
||||||
isFull: boolean;
|
isFull: boolean;
|
||||||
matchingMemberInfoList: APIPlayer[];
|
matchingMemberInfoList: APIPlayer[];
|
||||||
isFinished: boolean;
|
isFinished: boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user