This commit is contained in:
Ryan Barlow
2026-01-29 21:47:15 +00:00
parent 0803b71e81
commit d453ebf2e1
4 changed files with 15 additions and 10 deletions
+1 -1
View File
@@ -28,8 +28,8 @@ export interface ServerConfig {
turnstileSiteKey(): string;
turnstileSecretKey(): string;
turnIntervalMs(): number;
ticksPerSecond(): number;
spawnPhaseTicks(gameType: GameType): number;
spawnPhaseSeconds(gameType: GameType): number;
gameCreationRate(): number;
numWorkers(): number;
workerIndex(gameID: GameID): number;
+3
View File
@@ -123,6 +123,9 @@ export abstract class DefaultServerConfig implements ServerConfig {
spawnPhaseTicks(gameType: GameType): number {
return gameType === GameType.Singleplayer ? 100 : 300;
}
spawnPhaseSeconds(gameType: GameType): number {
return this.spawnPhaseTicks(gameType) / this.ticksPerSecond();
}
gameCreationRate(): number {
return 60 * 1000;
}
+9 -7
View File
@@ -182,15 +182,17 @@ export function buildPreview(
const winner = parseWinner(publicInfo?.info?.winner, players);
const duration = publicInfo?.info?.duration;
const gameType = lobby?.gameConfig?.gameType ?? config.gameType;
const spawnPhaseSeconds =
serverConfig.spawnPhaseTicks(
gameType === GameType.Singleplayer
? GameType.Singleplayer
: GameType.Public,
) / serverConfig.ticksPerSecond();
const adjustedDuration =
typeof duration === "number"
? Math.max(0, duration - spawnPhaseSeconds)
? Math.max(
0,
duration -
serverConfig.spawnPhaseSeconds(
gameType === GameType.Singleplayer
? GameType.Singleplayer
: GameType.Public,
),
)
: undefined;
// Normalize map name to match filesystem (lowercase, no spaces or special chars)
+2 -2
View File
@@ -46,10 +46,10 @@ export class TestServerConfig implements ServerConfig {
turnIntervalMs(): number {
throw new Error("Method not implemented.");
}
ticksPerSecond(): number {
spawnPhaseTicks(gameType: GameType): number {
throw new Error("Method not implemented.");
}
spawnPhaseTicks(gameType: GameType): number {
spawnPhaseSeconds(gameType: GameType): number {
throw new Error("Method not implemented.");
}
gameCreationRate(): number {