From f293c31d07b17c41b4dfb410ae7a07ea278dc00c Mon Sep 17 00:00:00 2001 From: Natalie Date: Wed, 24 Jun 2026 20:10:14 -0400 Subject: [PATCH] =?UTF-8?q?test(@projects/@magic-civilization):=20?= =?UTF-8?q?=F0=9F=90=9B=20update=20stale=20Rust=20tests=20for=20DeclareWar?= =?UTF-8?q?=20action=20+=20player=5Findex=20capping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - full_game_transcript: add the missing `Action::DeclareWar { target }` arm to the signature_of match (the tactical AI gained DeclareWar so AI-vs-AI leaves perpetual peace — non-exhaustive match broke compilation). - ai_controller: player_index_to_slot now caps out-of-range indices to the last slot (graceful degradation for >MAX_PLAYERS games) instead of erroring; assert the cap. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/simulator/api-gdext/tests/ai_controller.rs | 10 +++++++--- .../crates/mc-player-api/tests/full_game_transcript.rs | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/simulator/api-gdext/tests/ai_controller.rs b/src/simulator/api-gdext/tests/ai_controller.rs index c70eaa4a..c702e809 100644 --- a/src/simulator/api-gdext/tests/ai_controller.rs +++ b/src/simulator/api-gdext/tests/ai_controller.rs @@ -27,9 +27,13 @@ fn constructor_smoke_player_index_bounds() { player_index_to_slot((MAX_PLAYERS - 1) as i64).unwrap(), MAX_PLAYERS - 1 ); - assert!( - player_index_to_slot(MAX_PLAYERS as i64).is_err(), - "player_index >= MAX_PLAYERS must error" + // Out-of-range indices cap to the last slot (graceful degradation for games + // with more players than MAX_PLAYERS, e.g. the 5-clan demo) rather than + // erroring and taking no actions — see player_index_to_slot in ai.rs. + assert_eq!( + player_index_to_slot(MAX_PLAYERS as i64).unwrap(), + MAX_PLAYERS - 1, + "player_index >= MAX_PLAYERS must cap to the last slot" ); } diff --git a/src/simulator/crates/mc-player-api/tests/full_game_transcript.rs b/src/simulator/crates/mc-player-api/tests/full_game_transcript.rs index 38d42169..27e21a6f 100644 --- a/src/simulator/crates/mc-player-api/tests/full_game_transcript.rs +++ b/src/simulator/crates/mc-player-api/tests/full_game_transcript.rs @@ -1372,6 +1372,7 @@ fn ai_action_signature(action: &mc_ai::tactical::Action) -> String { A::DeploySiege { .. } => "deploy_siege".into(), A::PackSiege { .. } => "pack_siege".into(), A::Bombard { .. } => "bombard".into(), + A::DeclareWar { target } => format!("declare_war:{target}"), } }