Move arena runtime configuration into GameCore

- Replace FightSystem runtime properties with shared GameConfig
- Update dependent modules, commands, states, and tests
This commit is contained in:
2026-07-24 12:51:03 +02:00
parent f8cda32119
commit 12e085600e
45 changed files with 216 additions and 265 deletions
@@ -11,7 +11,6 @@
package de.steamwar.gamecore
import de.steamwar.gamecore.config.GameRuntimeProperties
import java.util.Collections
import java.util.EnumSet
@@ -50,16 +49,6 @@ enum class ArenaMode {
@JvmField val NotOnBau: Set<ArenaMode> = complement(TEST, CHECK, PREPARE, REPLAY)
@JvmField val SeriousFight: Set<ArenaMode> = complement(TEST, CHECK, REPLAY)
@JvmStatic
fun from(properties: GameRuntimeProperties): ArenaMode = when {
properties.checkSchematicId != 0 -> CHECK
properties.prepareSchematicId != 0 -> PREPARE
properties.fightId >= 1 -> EVENT
properties.fightId == -1 -> TEST
properties.replayId != 0 -> REPLAY
else -> NORMAL
}
private fun complement(vararg modes: ArenaMode): Set<ArenaMode> =
immutable(EnumSet.complementOf(EnumSet.copyOf(modes.toSet())))
@@ -0,0 +1,65 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
package de.steamwar.gamecore
import java.util.UUID
/**
* Runtime configuration shared by all GameCore game modes.
*
* The values are supplied as JVM system properties by the game server launcher.
*/
object GameConfig {
@JvmField
val CheckSchemID: Int = System.getProperty("checkSchemID", "0").toInt()
@JvmField
val PrepareSchemID: Int = System.getProperty("prepareSchemID", "0").toInt()
@JvmField
val ReplayID: Int = System.getProperty("replay", "0").toInt()
@JvmField
val ConfigFile: String = System.getProperty("config", "config.yml")
@JvmField
val EventKampfID: Int = System.getProperty("fightID", "0").toInt()
@JvmField
val BlueLeader: UUID? = System.getProperty("blueLeader")?.let(UUID::fromString)
@JvmField
val RedLeader: UUID? = System.getProperty("redLeader")?.let(UUID::fromString)
@JvmField
val mode: ArenaMode = resolveArenaMode(CheckSchemID, PrepareSchemID, EventKampfID, ReplayID)
@JvmStatic
fun test(): Boolean = ArenaMode.Test.contains(mode)
@JvmStatic
fun replayserver(): Boolean = ReplayID < 0
internal fun resolveArenaMode(
checkSchemID: Int,
prepareSchemID: Int,
eventKampfID: Int,
replayID: Int,
): ArenaMode = when {
checkSchemID != 0 -> ArenaMode.CHECK
prepareSchemID != 0 -> ArenaMode.PREPARE
eventKampfID >= 1 -> ArenaMode.EVENT
eventKampfID == -1 -> ArenaMode.TEST
replayID != 0 -> ArenaMode.REPLAY
else -> ArenaMode.NORMAL
}
}
@@ -1,63 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
package de.steamwar.gamecore.config
import java.util.Properties
import java.util.UUID
/**
* Typed view of every JVM system property historically consumed by FightSystem.
*
* Other game modes use the same names and parser, so launch behavior is
* consistent across the complete GameCore family.
*/
data class GameRuntimeProperties(
val checkSchematicId: Int,
val prepareSchematicId: Int,
val replayId: Int,
val configFile: String,
val fightId: Int,
val blueLeader: UUID?,
val redLeader: UUID?,
) {
val isReplayServer: Boolean
get() = replayId < 0
companion object {
const val CHECK_SCHEMATIC_ID = "checkSchemID"
const val PREPARE_SCHEMATIC_ID = "prepareSchemID"
const val REPLAY_ID = "replay"
const val CONFIG_FILE = "config"
const val FIGHT_ID = "fightID"
const val BLUE_LEADER = "blueLeader"
const val RED_LEADER = "redLeader"
@JvmStatic
@JvmOverloads
fun load(properties: Properties = System.getProperties()): GameRuntimeProperties =
GameRuntimeProperties(
checkSchematicId = properties.int(CHECK_SCHEMATIC_ID),
prepareSchematicId = properties.int(PREPARE_SCHEMATIC_ID),
replayId = properties.int(REPLAY_ID),
configFile = properties.getProperty(CONFIG_FILE, "config.yml"),
fightId = properties.int(FIGHT_ID),
blueLeader = properties.uuid(BLUE_LEADER),
redLeader = properties.uuid(RED_LEADER),
)
private fun Properties.int(name: String): Int =
getProperty(name, "0").toInt()
private fun Properties.uuid(name: String): UUID? =
getProperty(name)?.let(UUID::fromString)
}
}