feat(game-engine): Implement AI arena session logic with session initialization and behavior rules for main scene gameplay

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-04-10 19:26:53 -07:00
parent 5980926b84
commit e3fd056a94

View file

@ -4,6 +4,7 @@ extends Node
const DEFAULT_THEME: String = "age-of-dwarves"
const MAIN_MENU_PATH: String = "res://engine/scenes/menus/main_menu.tscn"
const LOADING_SCREEN_PATH: String = "res://engine/scenes/menus/loading_screen.tscn"
const TreasuryTabScene: PackedScene = preload(
"res://engine/scenes/treasury/treasury_tab.tscn"
)
@ -27,9 +28,37 @@ func _ready() -> void:
_crafting_modal = CraftingCompleteModalScene.instantiate() as CanvasLayer
add_child(_crafting_modal)
if EnvConfig.get_bool("AI_ARENA"):
_start_arena_session()
return
change_scene(MAIN_MENU_PATH)
func _start_arena_session() -> void:
## Skip the main menu / game-setup flow when running in spectator arena
## mode. The orchestrator script provides seed, turn limit, and player
## names through environment variables; we synthesize a settings dict
## here that mirrors what game_setup.gd would produce for a 1v1 duel.
var seed: int = EnvConfig.get_int("AI_ARENA_SEED", randi())
var turn_limit: int = EnvConfig.get_int("AI_ARENA_TURN_LIMIT", 150)
var settings: Dictionary = {
"map_size": "duel",
"map_type": "pangaea",
"map_wrap": "sphere",
"difficulty": "normal",
"game_speed": "standard",
"num_players": 2,
"turn_limit": turn_limit,
"turn_limit_enabled": true,
"seed": seed,
"era_difficulty_correlation": true,
}
GameState.initialize_game(settings)
GameState.map_seed = seed
change_scene(LOADING_SCREEN_PATH)
func get_treasury_tab() -> CanvasLayer:
return _treasury_tab