compute campaign points from rounds

This commit is contained in:
Maxime Réaux 2026-02-19 14:17:42 +01:00
parent 45c1d69a3f
commit 7c9c941864
9 changed files with 165 additions and 75 deletions

View file

@ -284,6 +284,22 @@ class Campaign:
return rnd
raise KeyError(f"Round {round_id} not found")
def get_round_index(self, round_id: str | None) -> int | None:
if round_id is None:
return None
for index, rnd in enumerate(self.rounds, start=1):
if rnd.id == round_id:
return index
raise KeyError("Round not found in campaign")
# TODO replace multiloops by internal has_* method
def get_round_by_battle(self, sector_id: str) -> Round:
for rnd in self.rounds:
for bat in rnd.battles.values():
if bat.sector_id == sector_id:
return rnd
raise KeyError(f"Battle {sector_id} not found in any Round")
def get_all_rounds(self) -> List[Round]:
return list(self.rounds)
@ -309,14 +325,6 @@ class Campaign:
if rnd:
self.rounds.remove(rnd)
def get_round_index(self, round_id: str | None) -> int | None:
if round_id is None:
return None
for index, rnd in enumerate(self.rounds, start=1):
if rnd.id == round_id:
return index
raise KeyError("Round not found in campaign")
# Choice methods
def create_choice(self, round_id: str, participant_id: str) -> Choice: