detect campaign tie
This commit is contained in:
parent
7c9c941864
commit
60d8e6ca15
9 changed files with 203 additions and 116 deletions
24
src/warchron/model/result_checker.py
Normal file
24
src/warchron/model/result_checker.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from warchron.constants import ContextType
|
||||
from warchron.model.war import War
|
||||
from warchron.model.war_event import TieResolved
|
||||
|
||||
|
||||
class ResultChecker:
|
||||
@staticmethod
|
||||
def get_effective_winner_id(
|
||||
war: War,
|
||||
context_type: ContextType,
|
||||
context_id: str,
|
||||
base_winner_id: str | None,
|
||||
) -> str | None:
|
||||
if base_winner_id is not None:
|
||||
return base_winner_id
|
||||
for ev in reversed(war.events):
|
||||
if (
|
||||
isinstance(ev, TieResolved)
|
||||
and ev.context_type == context_type
|
||||
and ev.context_id == context_id
|
||||
):
|
||||
return ev.participant_id # None if confirmed draw
|
||||
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue