fix mismatch part_id in choice event + fix revert events on sector/participant removal
This commit is contained in:
parent
42ad708e77
commit
db78c6dacc
6 changed files with 145 additions and 53 deletions
|
|
@ -186,12 +186,13 @@ class Pairing:
|
|||
campaign = war.get_campaign_by_round(round.id)
|
||||
if campaign is None:
|
||||
raise DomainError("Campaign not found for round {round.id}")
|
||||
war_participants = [
|
||||
campaign.campaign_to_war_part_id(pid) for pid in participants
|
||||
]
|
||||
context = TieContext(
|
||||
context_type=ContextType.CHOICE,
|
||||
context_id=round.id,
|
||||
participants=[
|
||||
campaign.campaign_to_war_part_id(pid) for pid in participants
|
||||
],
|
||||
participants=war_participants,
|
||||
score_value=score_value,
|
||||
score_kind=ScoreKind.VP,
|
||||
sector_id=sector_id,
|
||||
|
|
@ -212,6 +213,7 @@ class Pairing:
|
|||
score_kind=context.score_kind,
|
||||
sector_id=context.sector_id,
|
||||
)
|
||||
# natural or unbreakable draw
|
||||
if not TieResolver.can_tie_be_resolved(
|
||||
war, context, current_context.participants
|
||||
):
|
||||
|
|
@ -220,7 +222,7 @@ class Pairing:
|
|||
None,
|
||||
context.context_type,
|
||||
context.context_id,
|
||||
participants,
|
||||
participants=context.participants,
|
||||
tie_id=tie_id,
|
||||
score_value=score_value,
|
||||
sector_id=sector_id,
|
||||
|
|
@ -254,7 +256,6 @@ class Pairing:
|
|||
for group in ranked_groups:
|
||||
shuffled_group = list(group)
|
||||
# TODO improve tie break with history parsing
|
||||
# TODO avoid rematch
|
||||
random.shuffle(shuffled_group)
|
||||
ordered.extend(
|
||||
campaign.war_to_campaign_part_id(pid) for pid in shuffled_group
|
||||
|
|
@ -266,6 +267,7 @@ class Pairing:
|
|||
round: Round,
|
||||
remaining: List[str],
|
||||
) -> None:
|
||||
# TODO avoid rematch
|
||||
for pid in list(remaining):
|
||||
available = round.get_battles_with_places()
|
||||
if not available:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue