mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 17:56:39 +00:00
fix the embedded url times
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
||||
Difficulty,
|
||||
Game,
|
||||
GameMode,
|
||||
GameType,
|
||||
Gold,
|
||||
Player,
|
||||
PlayerInfo,
|
||||
@@ -25,6 +24,7 @@ import { Config, GameEnv, NukeMagnitude, ServerConfig, Theme } from "./Config";
|
||||
import { Env } from "./Env";
|
||||
import { PastelTheme } from "./PastelTheme";
|
||||
import { PastelThemeDark } from "./PastelThemeDark";
|
||||
import { spawnPhaseTurns } from "./Timing";
|
||||
|
||||
const DEFENSE_DEBUFF_MIDPOINT = 150_000;
|
||||
const DEFENSE_DEBUFF_DECAY_RATE = Math.LN2 / 50000;
|
||||
@@ -542,7 +542,7 @@ export class DefaultConfig implements Config {
|
||||
return 3;
|
||||
}
|
||||
numSpawnPhaseTurns(): number {
|
||||
return this._gameConfig.gameType === GameType.Singleplayer ? 100 : 300;
|
||||
return spawnPhaseTurns(this._gameConfig.gameType);
|
||||
}
|
||||
numBots(): number {
|
||||
return this.bots();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { GameType } from "../game/Game";
|
||||
|
||||
export const TICKS_PER_SECOND = 10;
|
||||
export const SPAWN_PHASE_TICKS = {
|
||||
singleplayer: 100,
|
||||
multiplayer: 300,
|
||||
} as const;
|
||||
|
||||
export type GameTypeLike = GameType | string | undefined;
|
||||
|
||||
export function spawnPhaseTurns(gameType: GameTypeLike): number {
|
||||
return gameType === GameType.Singleplayer
|
||||
? SPAWN_PHASE_TICKS.singleplayer
|
||||
: SPAWN_PHASE_TICKS.multiplayer;
|
||||
}
|
||||
|
||||
export function spawnPhaseSeconds(gameType: GameTypeLike): number {
|
||||
return spawnPhaseTurns(gameType) / TICKS_PER_SECOND;
|
||||
}
|
||||
@@ -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