Fix variant-aware fleet card map labels (Refs #150)
CI / checks (push) Successful in 5m47s

This commit is contained in:
2026-10-12 19:55:26 -04:00
parent 106d3a5ded
commit bcd3b99ee4
5 changed files with 220 additions and 10 deletions
+3 -1
View File
@@ -66,7 +66,9 @@ export function freshServer(server: FleetServer, now: number): boolean {
);
}
export function fleetIdentity(server: FleetServer) {
export function fleetIdentity(
server: Pick<FleetServer, 'name' | 'game' | 'map' | 'map_slug' | 'game_mode' | 'last_map'>
) {
const parsed = parseServerName(server.name);
const game = server.game ?? parsed?.game ?? '';
const mode = server.game_mode ?? parsed?.gameMode;
+19 -3
View File
@@ -5,7 +5,8 @@
import type { RosterPlayer, Health } from '$ui/stores/servers.js';
import { telemetryByServer, uiNow } from '$ui/stores/servers.js';
import { elapsedSince } from '$ui/duration.js';
import { mapTitle, serverIdentity, serverTitle } from '$ui/server-labels.js';
import { serverIdentity, serverTitle } from '$ui/server-labels.js';
import { fleetIdentity } from '$lib/fleet-overview.js';
import { decodeRconError, rconFixHint } from '$ui/rconError.js';
import Card from './primitives/Card.svelte';
import Badge from './primitives/Badge.svelte';
@@ -20,6 +21,9 @@
name: string;
players?: number | null;
map?: string | null;
game?: string | null;
mapSlug?: string | null;
gameMode?: string | null;
gametype?: string | null;
roster?: RosterPlayer[] | null;
health?: Health;
@@ -45,6 +49,9 @@
name,
players = null,
map = null,
game: serverGame = null,
mapSlug = null,
gameMode = null,
roster = null,
health = 'offline',
lastSeenAt = null,
@@ -76,8 +83,17 @@
const compact = $derived(compactEmpty && health === 'online' && players === 0 && !restarting);
const state = $derived(restarting ? 'restarting' : compact ? 'ready' : health);
const error = $derived(decodeRconError(lastError));
const mapLabel = $derived(mapTitle(map));
const showMap = $derived(mapLabel !== '—' && mapLabel !== title);
const mapLabel = $derived(
fleetIdentity({
name,
game: serverGame,
map,
last_map: null,
map_slug: mapSlug,
game_mode: gameMode
}).map
);
const showMap = $derived(map !== null && mapLabel !== '—' && mapLabel !== title);
const topRoster = $derived(
(roster ?? [])
.slice()
+5 -6
View File
@@ -7,13 +7,12 @@ export function gameTitle(game: string | null | undefined, compact = false): str
}
export function mapTitle(map: string | null | undefined): string {
return (
[...T5_ZOMBIE_MAPS, ...T6_ZOMBIE_MAPS].find(
(entry) => entry.canonical === map?.toLowerCase()
)?.friendly ??
map ??
'—'
const matches = [...T5_ZOMBIE_MAPS, ...T6_ZOMBIE_MAPS].filter(
(entry) => entry.canonical === map?.toLowerCase()
);
// Engine identifiers alone cannot distinguish selections such as Town and TranZit.
if (matches.length > 1) return `${map} (variant unknown)`;
return matches[0]?.friendly ?? map ?? '—';
}
export function serverTitle(name: string): string {