fix the embedded url times

This commit is contained in:
Ryan Barlow
2026-01-25 19:51:11 +00:00
parent de3794313d
commit 1a9ccc6415
3 changed files with 30 additions and 3 deletions
+9 -1
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { GameInfo } from "../core/Schemas";
import { spawnPhaseSeconds } from "../core/configuration/Timing";
import { GameMode } from "../core/game/Game";
export const PlayerInfoSchema = z.object({
@@ -179,6 +180,11 @@ export function buildPreview(
const winner = parseWinner(publicInfo?.info?.winner, players);
const duration = publicInfo?.info?.duration;
const gameType = lobby?.gameConfig?.gameType ?? config.gameType;
const adjustedDuration =
typeof duration === "number"
? Math.max(0, duration - spawnPhaseSeconds(gameType))
: undefined;
// Normalize map name to match filesystem (lowercase, no spaces or special chars)
const normalizedMap = map ? map.toLowerCase().replace(/[\s.()]+/g, "") : null;
@@ -211,7 +217,9 @@ export function buildPreview(
const detailParts: string[] = [];
const playerCountLabel = `${activePlayers} ${activePlayers === 1 ? "player" : "players"}`;
detailParts.push(playerCountLabel);
if (duration !== undefined) detailParts.push(`${formatDuration(duration)}`);
if (adjustedDuration !== undefined) {
detailParts.push(`${formatDuration(adjustedDuration)}`);
}
if (matchTimestamp !== undefined) {
const dateTime = formatDateTimeParts(matchTimestamp);
detailParts.push(`${dateTime.date}`);