improve draw & battle display
This commit is contained in:
parent
93aae78f0d
commit
a9cd4c9e27
19 changed files with 281 additions and 150 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue