24 lines
713 B
Python
24 lines
713 B
Python
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
|