fix unique participant in war & campaign
This commit is contained in:
parent
49bf6d7ea8
commit
87670329c2
3 changed files with 15 additions and 10 deletions
|
|
@ -54,11 +54,16 @@ class Campaign:
|
|||
def has_participant(self, participant_id: str) -> bool:
|
||||
return participant_id in self.participants
|
||||
|
||||
def has_war_participant(self, war_participant_id: str) -> bool:
|
||||
return any(
|
||||
part.war_participant_id == war_participant_id
|
||||
for part in self.participants.values()
|
||||
)
|
||||
|
||||
def add_campaign_participant(
|
||||
self, war_participant_id: str, leader: str, theme: str
|
||||
) -> CampaignParticipant:
|
||||
## TODO change lookup id target
|
||||
if war_participant_id in self.participants:
|
||||
if self.has_war_participant(war_participant_id):
|
||||
raise ValueError("Player already registered in this campaign")
|
||||
participant = CampaignParticipant(
|
||||
war_participant_id=war_participant_id, leader=leader, theme=theme
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue