mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 23:16:06 +00:00
fix the embedded url times
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user