fix round tie loop + improve tie ranking
This commit is contained in:
parent
60d8e6ca15
commit
f339498f97
6 changed files with 99 additions and 110 deletions
|
|
@ -96,6 +96,7 @@ class AppController:
|
|||
self.navigation.refresh_players_view()
|
||||
self.navigation.refresh_wars_view()
|
||||
self.update_window_title()
|
||||
# TODO refresh details view if wars tab selected
|
||||
|
||||
def open_file(self) -> None:
|
||||
if self.is_dirty:
|
||||
|
|
@ -116,6 +117,7 @@ class AppController:
|
|||
self.navigation.refresh_players_view()
|
||||
self.navigation.refresh_wars_view()
|
||||
self.update_window_title()
|
||||
# TODO refresh details view if wars tab selected
|
||||
|
||||
def save(self) -> None:
|
||||
if not self.current_file:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ from typing import TYPE_CHECKING
|
|||
if TYPE_CHECKING:
|
||||
from warchron.controller.app_controller import AppController
|
||||
|
||||
from warchron.model.war_event import TieResolved
|
||||
from warchron.model.war import War
|
||||
from warchron.model.campaign import Campaign
|
||||
from warchron.model.round import Round
|
||||
|
|
@ -23,22 +22,8 @@ class RoundClosureWorkflow(ClosureWorkflow):
|
|||
ClosureService.check_round_closable(round)
|
||||
ties = TieResolver.find_battle_ties(war, round.id)
|
||||
while ties:
|
||||
resolvable = []
|
||||
bids_map = self.app.rounds.resolve_ties(war, ties)
|
||||
for tie in ties:
|
||||
if TieResolver.can_tie_be_resolved(war, tie.participants):
|
||||
resolvable.append(tie)
|
||||
else:
|
||||
war.events.append(
|
||||
TieResolved(
|
||||
participant_id=None, # draw confirmed
|
||||
context_type=tie.context_type,
|
||||
context_id=tie.context_id,
|
||||
)
|
||||
)
|
||||
if not resolvable:
|
||||
break
|
||||
bids_map = self.app.rounds.resolve_ties(war, resolvable)
|
||||
for tie in resolvable:
|
||||
bids = bids_map[tie.context_id]
|
||||
TieResolver.apply_bids(
|
||||
war,
|
||||
|
|
@ -46,11 +31,8 @@ class RoundClosureWorkflow(ClosureWorkflow):
|
|||
tie.context_id,
|
||||
bids,
|
||||
)
|
||||
TieResolver.try_tie_break(
|
||||
war,
|
||||
tie.context_type,
|
||||
tie.context_id,
|
||||
tie.participants,
|
||||
TieResolver.resolve_tie_state(
|
||||
war, tie.context_type, tie.context_id, tie.participants, bids
|
||||
)
|
||||
ties = TieResolver.find_battle_ties(war, round.id)
|
||||
for battle in round.battles.values():
|
||||
|
|
@ -64,22 +46,8 @@ class CampaignClosureWorkflow(ClosureWorkflow):
|
|||
ClosureService.check_campaign_closable(campaign)
|
||||
ties = TieResolver.find_campaign_ties(war, campaign.id)
|
||||
while ties:
|
||||
resolvable = []
|
||||
bids_map = self.app.campaigns.resolve_ties(war, ties)
|
||||
for tie in ties:
|
||||
if TieResolver.can_tie_be_resolved(war, tie.participants):
|
||||
resolvable.append(tie)
|
||||
else:
|
||||
war.events.append(
|
||||
TieResolved(
|
||||
participant_id=None,
|
||||
context_type=tie.context_type,
|
||||
context_id=tie.context_id,
|
||||
)
|
||||
)
|
||||
if not resolvable:
|
||||
break
|
||||
bids_map = self.app.campaigns.resolve_ties(war, resolvable)
|
||||
for tie in resolvable:
|
||||
bids = bids_map[tie.context_id]
|
||||
TieResolver.apply_bids(
|
||||
war,
|
||||
|
|
@ -87,7 +55,7 @@ class CampaignClosureWorkflow(ClosureWorkflow):
|
|||
tie.context_id,
|
||||
bids,
|
||||
)
|
||||
TieResolver.try_tie_break(
|
||||
TieResolver.resolve_tie_state(
|
||||
war,
|
||||
tie.context_type,
|
||||
tie.context_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue