Default lobby cards to four-player capacity
This commit is contained in:
@@ -65,7 +65,8 @@
|
|||||||
const currentRound = $derived(!gameEndedAt ? (round !== undefined ? round : reportedRound) : null);
|
const currentRound = $derived(!gameEndedAt ? (round !== undefined ? round : reportedRound) : null);
|
||||||
const gameElapsed = $derived(gameStartedAt && !gameEndedAt ? elapsedSince(gameStartedAt, $uiNow) : null);
|
const gameElapsed = $derived(gameStartedAt && !gameEndedAt ? elapsedSince(gameStartedAt, $uiNow) : null);
|
||||||
const emptyElapsed = $derived(elapsedSince(inactiveSince, $uiNow));
|
const emptyElapsed = $derived(elapsedSince(inactiveSince, $uiNow));
|
||||||
const knownCapacity = $derived(capacity !== null && Number.isFinite(capacity) && capacity > 0 ? capacity : null);
|
// These lobbies have four slots when the live status omits the limit.
|
||||||
|
const displayCapacity = $derived(capacity !== null && Number.isSafeInteger(capacity) && capacity > 0 ? capacity : 4);
|
||||||
const cardStyle = $derived(`view-transition-name: server-${name.replace(/[^a-z0-9_-]/gi, '-')};`);
|
const cardStyle = $derived(`view-transition-name: server-${name.replace(/[^a-z0-9_-]/gi, '-')};`);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
{#if showMap}<p class="map-note">{health === 'online' ? 'Current map' : 'Last map'}: {mapLabel}</p>{/if}
|
{#if showMap}<p class="map-note">{health === 'online' ? 'Current map' : 'Last map'}: {mapLabel}</p>{/if}
|
||||||
{#if health === 'online'}
|
{#if health === 'online'}
|
||||||
<dl class="metrics">
|
<dl class="metrics">
|
||||||
<div><dt>Players</dt><dd title={knownCapacity === null ? 'Capacity unavailable' : `${knownCapacity} player capacity`}>{players ?? '—'}<span class="capacity">/{knownCapacity ?? '?'}</span></dd></div>
|
<div><dt>Players</dt><dd title={`${displayCapacity} player capacity`}>{players ?? '—'}<span class="capacity">/{displayCapacity}</span></dd></div>
|
||||||
<div><dt>Round</dt><dd>{currentRound ?? '—'}</dd></div>
|
<div><dt>Round</dt><dd>{currentRound ?? '—'}</dd></div>
|
||||||
<div><dt>Match time</dt><dd>{gameElapsed ?? '—'}</dd></div>
|
<div><dt>Match time</dt><dd>{gameElapsed ?? '—'}</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -29,11 +29,14 @@ describe('compact server cards', () => {
|
|||||||
expect(body).not.toMatch(/Last seen|Last reported|Zombies Classic|>Active</);
|
expect(body).not.toMatch(/Last seen|Last reported|Zombies Classic|>Active</);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps capacity unknown when unavailable and never invents a four-player limit', () => {
|
it('defaults to four lobby slots when capacity is unavailable, while preserving a reported limit', () => {
|
||||||
const body = html({ players: 2, capacity: null });
|
for (const capacity of [null, undefined, 0, -1, 4.5, NaN, Infinity]) {
|
||||||
expect(body).toContain('title="Capacity unavailable"');
|
const body = html({ players: 2, capacity });
|
||||||
expect(body).toMatch(/>2<span[^>]*>\/\?<\/span>/);
|
expect(body).toContain('title="4 player capacity"');
|
||||||
expect(body).not.toContain('/4');
|
expect(body).toMatch(/>2<span[^>]*>\/4<\/span>/);
|
||||||
|
expect(body).not.toContain('/?');
|
||||||
|
}
|
||||||
|
expect(html({ players: 2, capacity: 8 })).toMatch(/>2<span[^>]*>\/8<\/span>/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the newest fresh report while respecting explicit round data and match boundaries', () => {
|
it('uses the newest fresh report while respecting explicit round data and match boundaries', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user