fix(@projects/@magic-civilization): 🐛 fix victory check_all race condition
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
88cced5ede
commit
319fbc80e8
1 changed files with 11 additions and 2 deletions
|
|
@ -621,9 +621,18 @@ func _process(_delta: float) -> void:
|
|||
if not _victory:
|
||||
var vm: RefCounted = TurnManager._victory_manager
|
||||
if vm != null and vm.has_method("check_all"):
|
||||
print("AutoPlay: invoking score-victory fallback at T%d" % _turn_count)
|
||||
# Bump GameState.turn_number to >= turn_limit so
|
||||
# vm.check_all's score-fallback branch fires. Without
|
||||
# this, GameState.turn_number can lag _turn_count by 1
|
||||
# (depends on whether mid-round next_player has wrapped),
|
||||
# causing check_all to skip the score victory and
|
||||
# leave outcome=max_turns with winner_index=-1.
|
||||
var prev_turn: int = GameState.turn_number
|
||||
if prev_turn < _max_turns:
|
||||
GameState.turn_number = _max_turns
|
||||
print("AutoPlay: invoking score-victory fallback (turn_number %d→%d, limit %d)" % [prev_turn, GameState.turn_number, _max_turns])
|
||||
vm.check_all(GameState.get_game_map())
|
||||
print("AutoPlay: fallback complete, victory=%s" % _victory)
|
||||
print("AutoPlay: fallback complete, victory=%s winner=%d" % [_victory, _victory_winner])
|
||||
_screenshot("final_turn_%03d" % _turn_count)
|
||||
print("AutoPlay: finished — %d turns, victory=%s" % [_turn_count, _victory])
|
||||
_outcome = "victory" if _victory else "max_turns"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue