update from feedback

This commit is contained in:
Ryan Barlow
2026-01-28 00:28:01 +00:00
parent 865e5e5500
commit 97b9f3a60a
3 changed files with 37 additions and 23 deletions
+29
View File
@@ -89,6 +89,35 @@ export type UpdateGameConfigIntent = z.infer<
export type Turn = z.infer<typeof TurnSchema>;
export type GameConfig = z.infer<typeof GameConfigSchema>;
const TICKS_PER_SECOND = 10;
const SPAWN_PHASE_TICKS = {
singleplayer: 100,
multiplayer: 300,
} as const;
export function spawnPhaseTurns(
configOrGameType:
| Pick<GameConfig, "gameType">
| GameType
| string
| undefined,
): number {
return (typeof configOrGameType === "object"
? configOrGameType?.gameType
: configOrGameType) === GameType.Singleplayer
? SPAWN_PHASE_TICKS.singleplayer
: SPAWN_PHASE_TICKS.multiplayer;
}
export function spawnPhaseSeconds(
configOrGameType:
| Pick<GameConfig, "gameType">
| GameType
| string
| undefined,
): number {
return spawnPhaseTurns(configOrGameType) / TICKS_PER_SECOND;
}
export type ClientMessage =
| ClientSendWinnerMessage
+7 -21
View File
@@ -4,7 +4,6 @@ import {
Difficulty,
Game,
GameMode,
GameType,
Gold,
Player,
PlayerInfo,
@@ -18,7 +17,12 @@ import {
import { TileRef } from "../game/GameMap";
import { PlayerView } from "../game/GameView";
import { UserSettings } from "../game/UserSettings";
import { GameConfig, GameID, TeamCountConfig } from "../Schemas";
import {
GameConfig,
GameID,
spawnPhaseTurns,
TeamCountConfig,
} from "../Schemas";
import { NukeType } from "../StatsSchemas";
import { assertNever, sigmoid, simpleHash, within } from "../Util";
import { Config, GameEnv, NukeMagnitude, ServerConfig, Theme } from "./Config";
@@ -26,24 +30,6 @@ import { Env } from "./Env";
import { PastelTheme } from "./PastelTheme";
import { PastelThemeDark } from "./PastelThemeDark";
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;
}
const DEFENSE_DEBUFF_MIDPOINT = 150_000;
const DEFENSE_DEBUFF_DECAY_RATE = Math.LN2 / 50000;
@@ -560,7 +546,7 @@ export class DefaultConfig implements Config {
return 3;
}
numSpawnPhaseTurns(): number {
return spawnPhaseTurns(this._gameConfig.gameType);
return spawnPhaseTurns(this._gameConfig);
}
numBots(): number {
return this.bots();
+1 -2
View File
@@ -1,6 +1,5 @@
import { z } from "zod";
import { GameInfo } from "../core/Schemas";
import { spawnPhaseSeconds } from "../core/configuration/DefaultConfig";
import { GameInfo, spawnPhaseSeconds } from "../core/Schemas";
import { GameMode } from "../core/game/Game";
export const PlayerInfoSchema = z.object({