combat testing and polishing in the dev console, many bug fixes
This commit is contained in:
@@ -349,14 +349,32 @@ class CombatEncounter:
|
||||
return None
|
||||
|
||||
def advance_turn(self) -> None:
|
||||
"""Advance to the next combatant's turn."""
|
||||
self.current_turn_index += 1
|
||||
"""Advance to the next alive combatant's turn, skipping dead combatants."""
|
||||
# Track starting position to detect full cycle
|
||||
start_index = self.current_turn_index
|
||||
rounds_advanced = 0
|
||||
|
||||
# If we've cycled through all combatants, start a new round
|
||||
if self.current_turn_index >= len(self.turn_order):
|
||||
self.current_turn_index = 0
|
||||
self.round_number += 1
|
||||
self.log_action("round_start", None, f"Round {self.round_number} begins")
|
||||
while True:
|
||||
self.current_turn_index += 1
|
||||
|
||||
# If we've cycled through all combatants, start a new round
|
||||
if self.current_turn_index >= len(self.turn_order):
|
||||
self.current_turn_index = 0
|
||||
self.round_number += 1
|
||||
rounds_advanced += 1
|
||||
self.log_action("round_start", None, f"Round {self.round_number} begins")
|
||||
|
||||
# Get the current combatant
|
||||
current = self.get_current_combatant()
|
||||
|
||||
# If combatant is alive, their turn starts
|
||||
if current and current.is_alive():
|
||||
break
|
||||
|
||||
# Safety check: if we've gone through all combatants twice without finding
|
||||
# someone alive, break to avoid infinite loop (combat should end)
|
||||
if rounds_advanced >= 2:
|
||||
break
|
||||
|
||||
def start_turn(self) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user