raise exception on choice/battle constrained update/delete

This commit is contained in:
Maxime Réaux 2026-03-19 11:25:40 +01:00
parent 4396b15c3a
commit f5ad45f671
2 changed files with 67 additions and 22 deletions

View file

@ -47,15 +47,6 @@ class Pairing:
raise DomainError(
"There are not enough sectors for all participants to battle"
)
for pid, choice in round.choices.items():
if choice is not None and not choice.priority_sector_id:
raise ForbiddenOperation(
f"Missing priority choice for participant {pid}"
)
if choice is not None and not choice.secondary_sector_id:
raise ForbiddenOperation(
f"Missing secondary choice for participant {pid}"
)
def cleanup() -> None:
for bat in round.battles.values():
@ -74,6 +65,15 @@ class Pairing:
"Do you want to continue?",
action=cleanup,
)
for pid, choice in round.choices.items():
if choice is not None and not choice.priority_sector_id:
raise ForbiddenOperation(
f"Missing priority choice for participant {pid}"
)
if choice is not None and not choice.secondary_sector_id:
raise ForbiddenOperation(
f"Missing secondary choice for participant {pid}"
)
@staticmethod
def assign_battles_to_participants(
@ -226,10 +226,6 @@ class Pairing:
)
or len(active) <= places
):
print(
f"Natural or acceptable draw for sector {sector_id} with participants:\n",
context.participants,
)
war.events.append(
TieResolved(
None,
@ -246,10 +242,6 @@ class Pairing:
bids = bids_map[current_context.key()]
# confirmed draw if current bids are 0
if bids is not None and not any(bids.values()):
print(
f"Confirmed draw for sector {sector_id} with participants:\n",
context.participants,
)
war.events.append(
TieResolved(
None,