Add [BATTLE] debug logging to trace battle animation lifecycle

Logs battle additions, removals (both Eagle and Shardok paths),
and outstanding battles at round/phase transitions to diagnose
why battle animations persist during PlayerCommands phase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 18:39:51 -07:00
co-authored by Claude Opus 4.6
parent 85b620b644
commit 6ba59f65c9
@@ -449,11 +449,14 @@ namespace eagle {
// because RemovedBattleIds in the Eagle diff may arrive late or not
// at all for auto-resolved battles the player never entered.
foreach (var endedGameId in endedGames) {
Debug.Log($"[BATTLE] Shardok game ended: {endedGameId}");
_currentModel.ShardokGameModels.TryRemove(endedGameId, out _);
_shardokResultCounts.TryRemove(endedGameId, out _);
for (int i = _currentModel.ShardokBattles.Count - 1; i >= 0; i--) {
if (_currentModel.ShardokBattles[i].ShardokGameId == endedGameId) {
Debug.Log(
$"[BATTLE] Removed from ShardokBattles via Shardok end path: {endedGameId}");
_currentModel.ShardokBattles.RemoveAt(i);
}
}
@@ -901,9 +904,21 @@ namespace eagle {
if (entry.NewRoundId is {} newRoundId) {
_currentModel.GsView.CurrentRoundId = newRoundId;
if (_currentModel.ShardokBattles.Count > 0) {
Debug.Log(
$"[BATTLE] New round {newRoundId}, " +
$"{_currentModel.ShardokBattles.Count} outstanding battles: " +
$"[{string.Join(", ", _currentModel.ShardokBattles.Select(b => b.ShardokGameId))}]");
}
}
if (entry.NewPhase is {} newPhase) {
_currentModel.GsView.CurrentPhase = newPhase.Value;
if (_currentModel.ShardokBattles.Count > 0) {
Debug.Log(
$"[BATTLE] Phase → {newPhase.Value}, " +
$"{_currentModel.ShardokBattles.Count} outstanding battles: " +
$"[{string.Join(", ", _currentModel.ShardokBattles.Select(b => b.ShardokGameId))}]");
}
}
if (entry.NewDate is {} newDate) {
@@ -935,9 +950,16 @@ namespace eagle {
_currentModel.ActiveFactions.Remove(fid);
}
foreach (ShardokBattleView bv in entry.NewBattles) _currentModel.ShardokBattles.Add(bv);
foreach (ShardokBattleView bv in entry.NewBattles) {
_currentModel.ShardokBattles.Add(bv);
Debug.Log(
$"[BATTLE] Added battle {bv.ShardokGameId} " +
$"defender={bv.DefenderProvince} " +
$"players=[{string.Join(",", bv.PlayerInfos.Select(p => p.EagleFactionId))}]");
}
foreach (string rb in entry.RemovedBattleIds) {
Debug.Log($"[BATTLE] RemovedBattleIds contains {rb}");
// If there's an active ShardokGameModel for this battle, mark it as ended
// so the UI knows to return to Eagle. This handles the race condition where
// the Eagle update removing the battle arrives before the Shardok Victory update.