mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 16:50:15 +00:00
update
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user