fix remove round used in sector

This commit is contained in:
Maxime Réaux 2026-02-06 11:13:29 +01:00
parent 6cd3a060c7
commit 701f6b3292
7 changed files with 15 additions and 9 deletions

View file

@ -269,10 +269,13 @@ class Campaign:
def remove_round(self, round_id: str) -> None:
rnd = next((r for r in self.rounds if r.id == round_id), None)
for sect in self.sectors.values():
if sect.round_id == round_id:
sect.round_id = None
if rnd:
self.rounds.remove(rnd)
def get_round_index(self, round_id: str) -> int:
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):

View file

@ -380,7 +380,9 @@ class Model:
return rnd
raise KeyError("Round not found")
def get_round_index(self, round_id: str) -> int:
def get_round_index(self, round_id: str | None) -> int | None:
if round_id is None:
return None
camp = self.get_campaign_by_round(round_id)
return camp.get_round_index(round_id)

View file

@ -7,14 +7,14 @@ class Sector:
def __init__(
self,
name: str,
round_id: str,
round_id: str | None,
major_id: str | None,
minor_id: str | None,
influence_id: str | None,
):
self.id: str = str(uuid4())
self.name: str = name
self.round_id: str = round_id
self.round_id: str | None = round_id
self.major_objective_id: str | None = major_id # ref to War.objectives
self.minor_objective_id: str | None = minor_id # ref to War.objectives
self.influence_objective_id: str | None = influence_id # ref to War.objectives