fix delete campaign participant in another war
This commit is contained in:
parent
f408707588
commit
115ddf8d50
1 changed files with 8 additions and 4 deletions
|
|
@ -234,11 +234,13 @@ class War:
|
|||
return camp
|
||||
raise KeyError(f"Sector {sector_id} not found in any Campaign")
|
||||
|
||||
def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign:
|
||||
def get_campaign_by_campaign_participant(
|
||||
self, participant_id: str
|
||||
) -> Campaign | None:
|
||||
for camp in self.campaigns:
|
||||
if camp.has_participant(participant_id):
|
||||
return camp
|
||||
raise KeyError(f"Participant {participant_id} not found in any Campaign")
|
||||
return None
|
||||
|
||||
def update_campaign(self, campaign_id: str, *, name: str, month: int) -> None:
|
||||
if self.is_over:
|
||||
|
|
@ -351,11 +353,13 @@ class War:
|
|||
self, participant_id: str, *, leader: str, theme: str
|
||||
) -> None:
|
||||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
||||
camp.update_campaign_participant(participant_id, leader=leader, theme=theme)
|
||||
if camp is not None:
|
||||
camp.update_campaign_participant(participant_id, leader=leader, theme=theme)
|
||||
|
||||
def remove_campaign_participant(self, participant_id: str) -> None:
|
||||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
||||
camp.remove_campaign_participant(participant_id)
|
||||
if camp is not None:
|
||||
camp.remove_campaign_participant(participant_id)
|
||||
|
||||
# Round methods
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue