refactor campaign participant ID
This commit is contained in:
parent
fbb1c913ba
commit
ac01568c2f
4 changed files with 221 additions and 129 deletions
|
|
@ -182,7 +182,7 @@ class Controller:
|
||||||
self.view.display_campaign_sectors(sectors_for_display)
|
self.view.display_campaign_sectors(sectors_for_display)
|
||||||
participants = camp.get_all_campaign_participants()
|
participants = camp.get_all_campaign_participants()
|
||||||
participants_for_display = [
|
participants_for_display = [
|
||||||
(self.model.get_player_name(p.id), p.leader, p.theme, p.id)
|
(self.model.get_player_name(p.war_participant_id), p.leader, p.theme, p.id)
|
||||||
for p in participants
|
for p in participants
|
||||||
]
|
]
|
||||||
self.view.display_campaign_participants(participants_for_display)
|
self.view.display_campaign_participants(participants_for_display)
|
||||||
|
|
@ -392,7 +392,7 @@ class Controller:
|
||||||
self.refresh(RefreshScope.CAMPAIGN_DETAILS)
|
self.refresh(RefreshScope.CAMPAIGN_DETAILS)
|
||||||
elif item_type == ItemType.CAMPAIGN_PARTICIPANT:
|
elif item_type == ItemType.CAMPAIGN_PARTICIPANT:
|
||||||
part = self.model.get_campaign_participant(item_id)
|
part = self.model.get_campaign_participant(item_id)
|
||||||
player = self.model.get_player(part.id)
|
player = self.model.get_player(part.war_participant_id)
|
||||||
part_opt = [ParticipantOption(id=player.id, name=player.name)]
|
part_opt = [ParticipantOption(id=player.id, name=player.name)]
|
||||||
dialog = CampaignParticipantDialog(
|
dialog = CampaignParticipantDialog(
|
||||||
self.view,
|
self.view,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from uuid import uuid4
|
||||||
|
|
||||||
from warchron.model.round import Round, Choice, Battle
|
from warchron.model.round import Round, Choice, Battle
|
||||||
|
|
||||||
|
|
||||||
class Campaign:
|
class Campaign:
|
||||||
def __init__(self, name: str, month: int):
|
def __init__(self, name: str, month: int):
|
||||||
self.id: str = str(uuid4())
|
self.id: str = str(uuid4())
|
||||||
|
|
@ -32,7 +33,7 @@ class Campaign:
|
||||||
"month": self.month,
|
"month": self.month,
|
||||||
# "participants" : self.participants,
|
# "participants" : self.participants,
|
||||||
"rounds": [rnd.toDict() for rnd in self.rounds],
|
"rounds": [rnd.toDict() for rnd in self.rounds],
|
||||||
"is_over": self.is_over
|
"is_over": self.is_over,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -51,34 +52,48 @@ class Campaign:
|
||||||
return set(self.participants.keys())
|
return set(self.participants.keys())
|
||||||
|
|
||||||
def has_participant(self, player_id: str) -> bool:
|
def has_participant(self, player_id: str) -> bool:
|
||||||
|
##TODO change lookup id target
|
||||||
return player_id in self.participants
|
return player_id in self.participants
|
||||||
|
|
||||||
def add_campaign_participant(self, player_id: str, leader: str, theme: str) -> CampaignParticipant:
|
def add_campaign_participant(
|
||||||
if player_id in self.participants:
|
self, war_participant_id: str, leader: str, theme: str
|
||||||
|
) -> CampaignParticipant:
|
||||||
|
## TODO change lookup id target
|
||||||
|
if war_participant_id in self.participants:
|
||||||
raise ValueError("Player already registered in this campaign")
|
raise ValueError("Player already registered in this campaign")
|
||||||
participant = CampaignParticipant(player_id, leader, theme)
|
participant = CampaignParticipant(
|
||||||
|
war_participant_id=war_participant_id, leader=leader, theme=theme
|
||||||
|
)
|
||||||
self.participants[participant.id] = participant
|
self.participants[participant.id] = participant
|
||||||
return participant
|
return participant
|
||||||
|
|
||||||
def get_campaign_participant(self, id: str) -> CampaignParticipant:
|
def get_campaign_participant(self, participant_id: str) -> CampaignParticipant:
|
||||||
return self.participants[id]
|
try:
|
||||||
|
return self.participants[participant_id]
|
||||||
|
except KeyError:
|
||||||
|
raise KeyError(f"Participant {participant_id} not in campaign {self.id}")
|
||||||
|
|
||||||
def get_all_campaign_participants(self) -> list[CampaignParticipant]:
|
def get_all_campaign_participants(self) -> list[CampaignParticipant]:
|
||||||
return list(self.participants.values())
|
return list(self.participants.values())
|
||||||
|
|
||||||
def update_campaign_participant(self, player_id: str, *, leader: str, theme: str):
|
def update_campaign_participant(
|
||||||
part = self.get_campaign_participant(player_id)
|
self, participant_id: str, *, leader: str, theme: str
|
||||||
|
):
|
||||||
|
part = self.get_campaign_participant(participant_id)
|
||||||
|
# Can't change referred War.participant
|
||||||
part.set_leader(leader)
|
part.set_leader(leader)
|
||||||
part.set_theme(theme)
|
part.set_theme(theme)
|
||||||
|
|
||||||
def remove_campaign_participant(self, player_id: str):
|
def remove_campaign_participant(self, participant_id: str):
|
||||||
# TODO manage choices referring to it
|
# TODO manage choices referring to it
|
||||||
# TODO manage battles referring to it
|
# TODO manage battles referring to it
|
||||||
del self.participants[player_id]
|
del self.participants[participant_id]
|
||||||
|
|
||||||
# Sector methods
|
# Sector methods
|
||||||
|
|
||||||
def add_sector(self, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str) -> Sector:
|
def add_sector(
|
||||||
|
self, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str
|
||||||
|
) -> Sector:
|
||||||
sect = Sector(name, round_id, major_id, minor_id, influence_id)
|
sect = Sector(name, round_id, major_id, minor_id, influence_id)
|
||||||
self.sectors[sect.id] = sect
|
self.sectors[sect.id] = sect
|
||||||
return sect
|
return sect
|
||||||
|
|
@ -95,7 +110,16 @@ class Campaign:
|
||||||
return list(self.sectors.values())
|
return list(self.sectors.values())
|
||||||
|
|
||||||
# TODO manage choices referring to it (round order!)
|
# TODO manage choices referring to it (round order!)
|
||||||
def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
|
def update_sector(
|
||||||
|
self,
|
||||||
|
sector_id: str,
|
||||||
|
*,
|
||||||
|
name: str,
|
||||||
|
round_id: str,
|
||||||
|
major_id: str,
|
||||||
|
minor_id: str,
|
||||||
|
influence_id: str,
|
||||||
|
):
|
||||||
sect = self.get_sector(sector_id)
|
sect = self.get_sector(sector_id)
|
||||||
sect.set_name(name)
|
sect.set_name(name)
|
||||||
sect.set_round(round_id)
|
sect.set_round(round_id)
|
||||||
|
|
@ -109,10 +133,7 @@ class Campaign:
|
||||||
del self.sectors[sector_id]
|
del self.sectors[sector_id]
|
||||||
|
|
||||||
def get_sectors_in_round(self, round_id: str) -> list[Sector]:
|
def get_sectors_in_round(self, round_id: str) -> list[Sector]:
|
||||||
sectors = [
|
sectors = [s for s in self.sectors.values() if s.round_id == round_id]
|
||||||
s for s in self.sectors.values()
|
|
||||||
if s.round_id == round_id
|
|
||||||
]
|
|
||||||
return sectors
|
return sectors
|
||||||
|
|
||||||
# Round methods
|
# Round methods
|
||||||
|
|
@ -161,14 +182,18 @@ class Campaign:
|
||||||
rnd = self.get_round(round_id)
|
rnd = self.get_round(round_id)
|
||||||
return rnd.create_choice(participant_id)
|
return rnd.create_choice(participant_id)
|
||||||
|
|
||||||
def update_choice(self,
|
def update_choice(
|
||||||
|
self,
|
||||||
round_id: str,
|
round_id: str,
|
||||||
participant_id: str,
|
participant_id: str,
|
||||||
priority_sector_id: str | None,
|
priority_sector_id: str | None,
|
||||||
secondary_sector_id: str | None,
|
secondary_sector_id: str | None,
|
||||||
comment: str | None):
|
comment: str | None,
|
||||||
|
):
|
||||||
rnd = self.get_round(round_id)
|
rnd = self.get_round(round_id)
|
||||||
rnd.update_choice(participant_id, priority_sector_id, secondary_sector_id, comment)
|
rnd.update_choice(
|
||||||
|
participant_id, priority_sector_id, secondary_sector_id, comment
|
||||||
|
)
|
||||||
|
|
||||||
def remove_choice(self, round_id: str, participant_id: str) -> Choice:
|
def remove_choice(self, round_id: str, participant_id: str) -> Choice:
|
||||||
rnd = self.get_round(round_id)
|
rnd = self.get_round(round_id)
|
||||||
|
|
@ -180,7 +205,8 @@ class Campaign:
|
||||||
rnd = self.get_round(round_id)
|
rnd = self.get_round(round_id)
|
||||||
return rnd.create_battle(sector_id)
|
return rnd.create_battle(sector_id)
|
||||||
|
|
||||||
def update_battle(self,
|
def update_battle(
|
||||||
|
self,
|
||||||
round_id: str,
|
round_id: str,
|
||||||
sector_id: str,
|
sector_id: str,
|
||||||
player_1_id: str | None,
|
player_1_id: str | None,
|
||||||
|
|
@ -188,31 +214,48 @@ class Campaign:
|
||||||
winner_id: str | None,
|
winner_id: str | None,
|
||||||
score: str | None,
|
score: str | None,
|
||||||
victory_condition: str | None,
|
victory_condition: str | None,
|
||||||
comment: str | None):
|
comment: str | None,
|
||||||
|
):
|
||||||
rnd = self.get_round(round_id)
|
rnd = self.get_round(round_id)
|
||||||
rnd.update_battle(sector_id, player_1_id, player_2_id, winner_id, score, victory_condition, comment)
|
rnd.update_battle(
|
||||||
|
sector_id,
|
||||||
|
player_1_id,
|
||||||
|
player_2_id,
|
||||||
|
winner_id,
|
||||||
|
score,
|
||||||
|
victory_condition,
|
||||||
|
comment,
|
||||||
|
)
|
||||||
|
|
||||||
def remove_battle(self, round_id: str, sector_id: str) -> Battle:
|
def remove_battle(self, round_id: str, sector_id: str) -> Battle:
|
||||||
rnd = self.get_round(round_id)
|
rnd = self.get_round(round_id)
|
||||||
rnd.remove_battle(sector_id)
|
rnd.remove_battle(sector_id)
|
||||||
|
|
||||||
|
|
||||||
class CampaignParticipant:
|
class CampaignParticipant:
|
||||||
def __init__(self, player_id: str, leader: str, theme: str):
|
def __init__(self, *, war_participant_id: str, leader: str, theme: str):
|
||||||
self.id: str = player_id # ref to War.participants
|
self.id: str = str(uuid4())
|
||||||
|
self.war_participant_id: str = war_participant_id # ref to War.participants
|
||||||
self.leader: str = leader
|
self.leader: str = leader
|
||||||
self.theme: str = theme
|
self.theme: str = theme
|
||||||
|
|
||||||
def set_id(self, new_id: str):
|
def set_id(self, new_id: str):
|
||||||
self.id = new_id
|
self.id = new_id
|
||||||
|
|
||||||
|
def set_war_participant(self, new_participant: str):
|
||||||
|
self.war_participant_id = new_participant
|
||||||
|
|
||||||
def set_leader(self, new_faction: str):
|
def set_leader(self, new_faction: str):
|
||||||
self.leader = new_faction
|
self.leader = new_faction
|
||||||
|
|
||||||
def set_theme(self, new_theme: str):
|
def set_theme(self, new_theme: str):
|
||||||
self.theme = new_theme
|
self.theme = new_theme
|
||||||
|
|
||||||
|
|
||||||
class Sector:
|
class Sector:
|
||||||
def __init__(self, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
|
def __init__(
|
||||||
|
self, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str
|
||||||
|
):
|
||||||
self.id: str = str(uuid4())
|
self.id: str = str(uuid4())
|
||||||
self.name: str = name
|
self.name: str = name
|
||||||
self.round_id: str = round_id
|
self.round_id: str = round_id
|
||||||
|
|
|
||||||
|
|
@ -126,11 +126,17 @@ class Model:
|
||||||
# TODO don't use this method as participant with same ID (player) can be in several wars!
|
# TODO don't use this method as participant with same ID (player) can be in several wars!
|
||||||
def get_war_by_war_participant(self, participant_id: str) -> War:
|
def get_war_by_war_participant(self, participant_id: str) -> War:
|
||||||
for war in self.wars.values():
|
for war in self.wars.values():
|
||||||
for part in war.participants.values():
|
if war.has_participant(participant_id):
|
||||||
if part.id == participant_id:
|
|
||||||
return war
|
return war
|
||||||
raise KeyError(f"Participant {participant_id} not found in any War")
|
raise KeyError(f"Participant {participant_id} not found in any War")
|
||||||
|
|
||||||
|
def get_war_by_campaign_participant(self, participant_id: str) -> Campaign:
|
||||||
|
for war in self.wars.values():
|
||||||
|
camp = war.get_campaign_by_campaign_participant(participant_id)
|
||||||
|
if camp is not None:
|
||||||
|
return war
|
||||||
|
raise KeyError(f"Participant {participant_id} not found")
|
||||||
|
|
||||||
def update_war(self, war_id: str, *, name: str, year: int):
|
def update_war(self, war_id: str, *, name: str, year: int):
|
||||||
war = self.get_war(war_id)
|
war = self.get_war(war_id)
|
||||||
war.set_name(name)
|
war.set_name(name)
|
||||||
|
|
@ -218,7 +224,6 @@ class Model:
|
||||||
return camp
|
return camp
|
||||||
raise KeyError(f"Round {round_id} not found")
|
raise KeyError(f"Round {round_id} not found")
|
||||||
|
|
||||||
# TODO don't use this method as participant with same ID (player) can be in several campaigns!
|
|
||||||
def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign:
|
def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign:
|
||||||
for war in self.wars.values():
|
for war in self.wars.values():
|
||||||
camp = war.get_campaign_by_campaign_participant(participant_id)
|
camp = war.get_campaign_by_campaign_participant(participant_id)
|
||||||
|
|
@ -308,14 +313,18 @@ class Model:
|
||||||
raise KeyError("Participant not found")
|
raise KeyError("Participant not found")
|
||||||
|
|
||||||
def update_campaign_participant(
|
def update_campaign_participant(
|
||||||
self, participant_id: str, *, leader: str, theme: str
|
self,
|
||||||
|
participant_id: str,
|
||||||
|
*,
|
||||||
|
leader: str,
|
||||||
|
theme: str,
|
||||||
):
|
):
|
||||||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
war = self.get_war_by_campaign_participant(participant_id)
|
||||||
camp.update_campaign_participant(participant_id, leader=leader, theme=theme)
|
war.update_campaign_participant(participant_id, leader=leader, theme=theme)
|
||||||
|
|
||||||
def remove_campaign_participant(self, participant_id: str):
|
def remove_campaign_participant(self, participant_id: str):
|
||||||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
war = self.get_war_by_campaign_participant(participant_id)
|
||||||
camp.remove_campaign_participant(participant_id)
|
war.remove_campaign_participant(participant_id)
|
||||||
|
|
||||||
# Round methods
|
# Round methods
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class War:
|
||||||
"year": self.year,
|
"year": self.year,
|
||||||
# "participants" : self.participants,
|
# "participants" : self.participants,
|
||||||
"campaigns": [camp.toDict() for camp in self.campaigns],
|
"campaigns": [camp.toDict() for camp in self.campaigns],
|
||||||
"is_over": self.is_over
|
"is_over": self.is_over,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -111,9 +111,7 @@ class War:
|
||||||
return any(c.id == campaign_id for c in self.campaigns)
|
return any(c.id == campaign_id for c in self.campaigns)
|
||||||
|
|
||||||
def get_default_campaign_values(self) -> dict:
|
def get_default_campaign_values(self) -> dict:
|
||||||
return {
|
return {"month": datetime.now().month}
|
||||||
"month": datetime.now().month
|
|
||||||
}
|
|
||||||
|
|
||||||
def add_campaign(self, name: str, month: int | None = None) -> Campaign:
|
def add_campaign(self, name: str, month: int | None = None) -> Campaign:
|
||||||
if month is None:
|
if month is None:
|
||||||
|
|
@ -144,8 +142,7 @@ class War:
|
||||||
|
|
||||||
def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign:
|
def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign:
|
||||||
for camp in self.campaigns:
|
for camp in self.campaigns:
|
||||||
for part in camp.participants.values():
|
if camp.has_participant(participant_id):
|
||||||
if part.id == participant_id:
|
|
||||||
return camp
|
return camp
|
||||||
raise KeyError(f"Participant {participant_id} not found in any Campaign")
|
raise KeyError(f"Participant {participant_id} not found in any Campaign")
|
||||||
|
|
||||||
|
|
@ -163,16 +160,40 @@ class War:
|
||||||
|
|
||||||
# Sector methods
|
# Sector methods
|
||||||
|
|
||||||
def add_sector(self, campaign_id, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str) -> Sector:
|
def add_sector(
|
||||||
|
self,
|
||||||
|
campaign_id,
|
||||||
|
name: str,
|
||||||
|
round_id: str,
|
||||||
|
major_id: str,
|
||||||
|
minor_id: str,
|
||||||
|
influence_id: str,
|
||||||
|
) -> Sector:
|
||||||
camp = self.get_campaign(campaign_id)
|
camp = self.get_campaign(campaign_id)
|
||||||
return camp.add_sector(name, round_id, major_id, minor_id, influence_id)
|
return camp.add_sector(name, round_id, major_id, minor_id, influence_id)
|
||||||
|
|
||||||
def get_sector(self, id: str) -> Sector:
|
def get_sector(self, id: str) -> Sector:
|
||||||
return self.sectors[id]
|
return self.sectors[id]
|
||||||
|
|
||||||
def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
|
def update_sector(
|
||||||
|
self,
|
||||||
|
sector_id: str,
|
||||||
|
*,
|
||||||
|
name: str,
|
||||||
|
round_id: str,
|
||||||
|
major_id: str,
|
||||||
|
minor_id: str,
|
||||||
|
influence_id: str,
|
||||||
|
):
|
||||||
camp = self.get_campaign_by_sector(sector_id)
|
camp = self.get_campaign_by_sector(sector_id)
|
||||||
camp.update_sector(sector_id, name=name, round_id=round_id, major_id=major_id, minor_id=minor_id, influence_id=influence_id)
|
camp.update_sector(
|
||||||
|
sector_id,
|
||||||
|
name=name,
|
||||||
|
round_id=round_id,
|
||||||
|
major_id=major_id,
|
||||||
|
minor_id=minor_id,
|
||||||
|
influence_id=influence_id,
|
||||||
|
)
|
||||||
|
|
||||||
def remove_sector(self, sector_id: str):
|
def remove_sector(self, sector_id: str):
|
||||||
camp = self.get_campaign_by_sector(sector_id)
|
camp = self.get_campaign_by_sector(sector_id)
|
||||||
|
|
@ -188,9 +209,11 @@ class War:
|
||||||
if not camp.has_participant(part.id)
|
if not camp.has_participant(part.id)
|
||||||
]
|
]
|
||||||
|
|
||||||
def add_campaign_participant(self, campaign_id: str, player_id: str, leader: str, theme: str) -> CampaignParticipant:
|
def add_campaign_participant(
|
||||||
|
self, campaign_id: str, participant_id: str, leader: str, theme: str
|
||||||
|
) -> CampaignParticipant:
|
||||||
camp = self.get_campaign(campaign_id)
|
camp = self.get_campaign(campaign_id)
|
||||||
return camp.add_campaign_participant(player_id, leader, theme)
|
return camp.add_campaign_participant(participant_id, leader, theme)
|
||||||
|
|
||||||
def get_campaign_participant(self, participant_id) -> CampaignParticipant:
|
def get_campaign_participant(self, participant_id) -> CampaignParticipant:
|
||||||
for camp in self.campaigns.values():
|
for camp in self.campaigns.values():
|
||||||
|
|
@ -199,9 +222,11 @@ class War:
|
||||||
return part
|
return part
|
||||||
raise KeyError("Participant not found")
|
raise KeyError("Participant not found")
|
||||||
|
|
||||||
def update_campaign_participant(self, participant_id: str, *, faction: str):
|
def update_campaign_participant(
|
||||||
|
self, participant_id: str, *, leader: str, theme: str
|
||||||
|
):
|
||||||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
camp = self.get_campaign_by_campaign_participant(participant_id)
|
||||||
camp.update_campaign_participant(participant_id, faction=faction)
|
camp.update_campaign_participant(participant_id, leader=leader, theme=theme)
|
||||||
|
|
||||||
def remove_campaign_participant(self, participant_id: str):
|
def remove_campaign_participant(self, participant_id: str):
|
||||||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
camp = self.get_campaign_by_campaign_participant(participant_id)
|
||||||
|
|
@ -227,14 +252,18 @@ class War:
|
||||||
camp = self.get_campaign_by_round(round_id)
|
camp = self.get_campaign_by_round(round_id)
|
||||||
return camp.create_choice(round_id, participant_id)
|
return camp.create_choice(round_id, participant_id)
|
||||||
|
|
||||||
def update_choice(self,
|
def update_choice(
|
||||||
|
self,
|
||||||
round_id: str,
|
round_id: str,
|
||||||
participant_id: str,
|
participant_id: str,
|
||||||
priority_sector_id: str | None,
|
priority_sector_id: str | None,
|
||||||
secondary_sector_id: str | None,
|
secondary_sector_id: str | None,
|
||||||
comment: str | None):
|
comment: str | None,
|
||||||
|
):
|
||||||
camp = self.get_campaign_by_round(round_id)
|
camp = self.get_campaign_by_round(round_id)
|
||||||
camp.update_choice(participant_id, priority_sector_id, secondary_sector_id, comment)
|
camp.update_choice(
|
||||||
|
participant_id, priority_sector_id, secondary_sector_id, comment
|
||||||
|
)
|
||||||
|
|
||||||
def remove_choice(self, round_id: str, participant_id: str):
|
def remove_choice(self, round_id: str, participant_id: str):
|
||||||
camp = self.get_campaign_by_round(round_id)
|
camp = self.get_campaign_by_round(round_id)
|
||||||
|
|
@ -246,7 +275,8 @@ class War:
|
||||||
camp = self.get_campaign_by_round(round_id)
|
camp = self.get_campaign_by_round(round_id)
|
||||||
return camp.create_battle(round_id, sector_id)
|
return camp.create_battle(round_id, sector_id)
|
||||||
|
|
||||||
def update_battle(self,
|
def update_battle(
|
||||||
|
self,
|
||||||
round_id: str,
|
round_id: str,
|
||||||
sector_id: str,
|
sector_id: str,
|
||||||
player_1_id: str | None,
|
player_1_id: str | None,
|
||||||
|
|
@ -254,14 +284,24 @@ class War:
|
||||||
winner_id: str | None,
|
winner_id: str | None,
|
||||||
score: str | None,
|
score: str | None,
|
||||||
victory_condition: str | None,
|
victory_condition: str | None,
|
||||||
comment: str | None):
|
comment: str | None,
|
||||||
|
):
|
||||||
camp = self.get_campaign_by_round(round_id)
|
camp = self.get_campaign_by_round(round_id)
|
||||||
camp.update_battle(sector_id, player_1_id, player_2_id, winner_id, score, victory_condition, comment)
|
camp.update_battle(
|
||||||
|
sector_id,
|
||||||
|
player_1_id,
|
||||||
|
player_2_id,
|
||||||
|
winner_id,
|
||||||
|
score,
|
||||||
|
victory_condition,
|
||||||
|
comment,
|
||||||
|
)
|
||||||
|
|
||||||
def remove_battle(self, round_id: str, sector_id: str):
|
def remove_battle(self, round_id: str, sector_id: str):
|
||||||
camp = self.get_campaign_by_round(round_id)
|
camp = self.get_campaign_by_round(round_id)
|
||||||
camp.remove_battle(round_id, sector_id)
|
camp.remove_battle(round_id, sector_id)
|
||||||
|
|
||||||
|
|
||||||
class Objective:
|
class Objective:
|
||||||
def __init__(self, name: str, description: str):
|
def __init__(self, name: str, description: str):
|
||||||
self.id: str = str(uuid4())
|
self.id: str = str(uuid4())
|
||||||
|
|
@ -277,6 +317,7 @@ class Objective:
|
||||||
def set_description(self, new_description: str):
|
def set_description(self, new_description: str):
|
||||||
self.description = new_description
|
self.description = new_description
|
||||||
|
|
||||||
|
|
||||||
class WarParticipant:
|
class WarParticipant:
|
||||||
def __init__(self, player_id: str, faction: str):
|
def __init__(self, player_id: str, faction: str):
|
||||||
self.id: str = player_id # ref to Model.players
|
self.id: str = player_id # ref to Model.players
|
||||||
|
|
@ -287,4 +328,3 @@ class WarParticipant:
|
||||||
|
|
||||||
def set_faction(self, new_faction: str):
|
def set_faction(self, new_faction: str):
|
||||||
self.faction = new_faction
|
self.faction = new_faction
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue