detect campaign tie
This commit is contained in:
parent
7c9c941864
commit
60d8e6ca15
9 changed files with 203 additions and 116 deletions
|
|
@ -3,7 +3,7 @@ from typing import List
|
|||
|
||||
from warchron.constants import ContextType
|
||||
from warchron.model.exception import ForbiddenOperation
|
||||
from warchron.model.tie_manager import TieResolver
|
||||
from warchron.model.result_checker import ResultChecker
|
||||
from warchron.model.war_event import InfluenceGained
|
||||
from warchron.model.war import War
|
||||
from warchron.model.campaign import Campaign
|
||||
|
|
@ -35,7 +35,7 @@ class ClosureService:
|
|||
base_winner = None
|
||||
if battle.winner_id is not None:
|
||||
base_winner = campaign.participants[battle.winner_id].war_participant_id
|
||||
effective_winner = TieResolver.get_effective_winner_id(
|
||||
effective_winner = ResultChecker.get_effective_winner_id(
|
||||
war,
|
||||
ContextType.BATTLE,
|
||||
battle.sector_id,
|
||||
|
|
@ -60,28 +60,17 @@ class ClosureService:
|
|||
# Campaign methods
|
||||
|
||||
@staticmethod
|
||||
def close_campaign(campaign: Campaign) -> List[str]:
|
||||
def check_campaign_closable(campaign: Campaign) -> None:
|
||||
if campaign.is_over:
|
||||
raise ForbiddenOperation("Campaign already closed")
|
||||
if not campaign.all_rounds_finished():
|
||||
raise RuntimeError("All rounds must be finished to close their campaign")
|
||||
ties: List[str] = []
|
||||
# for round in campaign.rounds:
|
||||
# # compute score
|
||||
# # if participants have same score
|
||||
# ties.append(
|
||||
# ResolutionContext(
|
||||
# context_type=ContextType.CAMPAIGN,
|
||||
# context_id=campaign.id,
|
||||
# participant_ids=[
|
||||
# # TODO ref to War.participants at some point
|
||||
# campaign.participants[campaign_participant_id],
|
||||
# campaign.participants[campaign_participant_id],
|
||||
# ],
|
||||
# )
|
||||
# )
|
||||
if ties:
|
||||
return ties
|
||||
raise ForbiddenOperation(
|
||||
"All rounds must be closed to close their campaign"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def finalize_campaign(campaign: Campaign) -> None:
|
||||
campaign.is_over = True
|
||||
return []
|
||||
|
||||
# War methods
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue