fix unique participant in war & campaign
This commit is contained in:
parent
49bf6d7ea8
commit
87670329c2
3 changed files with 15 additions and 10 deletions
|
|
@ -81,11 +81,14 @@ class War:
|
|||
def get_all_war_participants_ids(self) -> set[str]:
|
||||
return set(self.participants.keys())
|
||||
|
||||
def has_participant(self, player_id: str) -> bool:
|
||||
return player_id in self.participants
|
||||
def has_participant(self, participant_id: str) -> bool:
|
||||
return participant_id in self.participants
|
||||
|
||||
def has_player(self, player_id: str) -> bool:
|
||||
return any(part.player_id == player_id for part in self.participants.values())
|
||||
|
||||
def add_war_participant(self, player_id: str, faction: str) -> WarParticipant:
|
||||
if player_id in self.participants:
|
||||
if self.has_player(player_id):
|
||||
raise ValueError("Player already registered in this war")
|
||||
participant = WarParticipant(player_id=player_id, faction=faction)
|
||||
self.participants[participant.id] = participant
|
||||
|
|
@ -207,7 +210,7 @@ class War:
|
|||
return [
|
||||
part
|
||||
for part in self.participants.values()
|
||||
if not camp.has_participant(part.id)
|
||||
if not camp.has_war_participant(part.id)
|
||||
]
|
||||
|
||||
def add_campaign_participant(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue