Show fresh player capacity on Fleet cards

This commit is contained in:
2026-10-07 20:16:42 -04:00
parent 5b3e8cb1a3
commit 6146bef51d
14 changed files with 234 additions and 7 deletions
+18
View File
@@ -0,0 +1,18 @@
import type { PlayerCapacityObservation } from '../../server-capacity.js';
import { monitoringStatus } from './health-observations.js';
import { MonitoringSnapshot } from './monitoring-snapshot.js';
/** Read only the accepted, current-instance sample; never dispatch a probe. */
export function observedPlayerCapacity(server: string, snapshot: MonitoringSnapshot): PlayerCapacityObservation {
const game = monitoringStatus(server, snapshot)?.game;
const capacity = game?.result.ok ? game.result.status.capacity : null;
return typeof capacity === 'number' && Number.isSafeInteger(capacity) && capacity > 0
? { capacity, capacity_observed_at: game!.observedAt }
: { capacity: null, capacity_observed_at: null };
}
/** One joined identity read for a fleet, or a single server on a detail route. */
export function playerCapacityReader(serverName?: string) {
const snapshot = new MonitoringSnapshot(serverName);
return (server: string) => observedPlayerCapacity(server, snapshot);
}