refactor war participant ID + fix campaign participant
This commit is contained in:
parent
ac01568c2f
commit
49bf6d7ea8
4 changed files with 55 additions and 26 deletions
|
|
@ -87,7 +87,7 @@ class War:
|
|||
def add_war_participant(self, player_id: str, faction: str) -> WarParticipant:
|
||||
if player_id in self.participants:
|
||||
raise ValueError("Player already registered in this war")
|
||||
participant = WarParticipant(player_id, faction)
|
||||
participant = WarParticipant(player_id=player_id, faction=faction)
|
||||
self.participants[participant.id] = participant
|
||||
return participant
|
||||
|
||||
|
|
@ -99,6 +99,7 @@ class War:
|
|||
|
||||
def update_war_participant(self, player_id: str, *, faction: str):
|
||||
part = self.get_war_participant(player_id)
|
||||
# Can't change referred Model.players
|
||||
part.set_faction(faction)
|
||||
|
||||
def remove_war_participant(self, player_id: str):
|
||||
|
|
@ -319,12 +320,16 @@ class Objective:
|
|||
|
||||
|
||||
class WarParticipant:
|
||||
def __init__(self, player_id: str, faction: str):
|
||||
self.id: str = player_id # ref to Model.players
|
||||
def __init__(self, *, player_id: str, faction: str):
|
||||
self.id: str = str(uuid4())
|
||||
self.player_id: str = player_id # ref to WarModel.players
|
||||
self.faction: str = faction
|
||||
|
||||
def set_id(self, new_id: str):
|
||||
self.id = new_id
|
||||
|
||||
def set_player(self, new_player: str):
|
||||
self.player_id = new_player
|
||||
|
||||
def set_faction(self, new_faction: str):
|
||||
self.faction = new_faction
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue