improve draw & battle display

This commit is contained in:
Maxime Réaux 2026-02-12 10:07:03 +01:00
parent 93aae78f0d
commit a9cd4c9e27
19 changed files with 281 additions and 150 deletions

View file

@ -40,9 +40,20 @@ class Battle:
def set_comment(self, new_comment: str | None) -> None:
self.comment = new_comment
# TODO improve draw detection
def is_draw(self) -> bool:
return self.winner_id is None and self.score is not None
if self.winner_id is not None:
return False
# Case 1: score entered → interpreted as unresolved outcome
if self.score and self.score.strip():
return True
# Case 2: explicit draw mention
if self.victory_condition:
if "draw" in self.victory_condition.casefold():
return True
return False
def is_finished(self) -> bool:
return self.winner_id is not None or self.is_draw()
def toDict(self) -> Dict[str, Any]:
return {