fix war tie campaign sorted unwanted participant
This commit is contained in:
parent
e7d3b962ca
commit
e64d9ff43b
2 changed files with 10 additions and 10 deletions
|
|
@ -149,7 +149,6 @@ class WarController:
|
||||||
for pid in active
|
for pid in active
|
||||||
]
|
]
|
||||||
counters = [war.get_influence_tokens(pid) for pid in active]
|
counters = [war.get_influence_tokens(pid) for pid in active]
|
||||||
# TODO fix sorted participants included in tie-break after campaign ranking
|
|
||||||
dialog = TieDialog(
|
dialog = TieDialog(
|
||||||
parent=self.app.view,
|
parent=self.app.view,
|
||||||
players=players,
|
players=players,
|
||||||
|
|
|
||||||
|
|
@ -87,19 +87,20 @@ class TieResolver:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_war_ties(war: War) -> List[TieContext]:
|
def find_war_ties(war: War) -> List[TieContext]:
|
||||||
|
from warchron.model.result_checker import ResultChecker
|
||||||
|
|
||||||
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
|
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
|
||||||
buckets: DefaultDict[int, List[str]] = defaultdict(list)
|
ranking = ResultChecker.get_effective_ranking(
|
||||||
for pid, score in scores.items():
|
war, ContextType.WAR, war.id, scores
|
||||||
buckets[score.victory_points].append(pid)
|
)
|
||||||
ties: List[TieContext] = []
|
ties: List[TieContext] = []
|
||||||
for score_value, participants in buckets.items():
|
for _, group, _ in ranking:
|
||||||
if len(participants) <= 1:
|
if len(group) <= 1:
|
||||||
continue
|
continue
|
||||||
|
score_value = scores[group[0]].victory_points
|
||||||
if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id, score_value):
|
if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id, score_value):
|
||||||
continue
|
continue
|
||||||
if not TieResolver.can_tie_be_resolved(
|
if not TieResolver.can_tie_be_resolved(war, ContextType.WAR, war.id, group):
|
||||||
war, ContextType.WAR, war.id, participants
|
|
||||||
):
|
|
||||||
war.events.append(
|
war.events.append(
|
||||||
TieResolved(None, ContextType.WAR, war.id, score_value)
|
TieResolved(None, ContextType.WAR, war.id, score_value)
|
||||||
)
|
)
|
||||||
|
|
@ -108,7 +109,7 @@ class TieResolver:
|
||||||
TieContext(
|
TieContext(
|
||||||
context_type=ContextType.WAR,
|
context_type=ContextType.WAR,
|
||||||
context_id=war.id,
|
context_id=war.id,
|
||||||
participants=participants,
|
participants=group,
|
||||||
score_value=score_value,
|
score_value=score_value,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue