auto create & edit choice
This commit is contained in:
parent
723723dea1
commit
9f676f6b9d
6 changed files with 166 additions and 59 deletions
|
|
@ -3,6 +3,7 @@ from uuid import uuid4
|
|||
from datetime import datetime
|
||||
|
||||
from warchron.model.campaign import Campaign, Sector, CampaignParticipant
|
||||
from warchron.model.round import Round, Choice, Battle
|
||||
|
||||
|
||||
class War:
|
||||
|
|
@ -12,7 +13,7 @@ class War:
|
|||
self.year: int = year
|
||||
self.participants: dict[str, WarParticipant] = {}
|
||||
self.objectives: dict[str, Objective] = {}
|
||||
self.campaigns = []
|
||||
self.campaigns: list[Campaign] = []
|
||||
self.is_over: bool = False
|
||||
|
||||
def set_id(self, new_id: str):
|
||||
|
|
@ -72,6 +73,7 @@ class War:
|
|||
obj.set_description(description)
|
||||
|
||||
def remove_objective(self, objective_id: str):
|
||||
# TODO manage sectors referring to it
|
||||
del self.objectives[objective_id]
|
||||
|
||||
# War participant methods
|
||||
|
|
@ -100,6 +102,7 @@ class War:
|
|||
part.set_faction(faction)
|
||||
|
||||
def remove_war_participant(self, player_id: str):
|
||||
# TODO manage campaign_participants referring to it
|
||||
del self.participants[player_id]
|
||||
|
||||
# Campaign methods
|
||||
|
|
@ -167,10 +170,10 @@ class War:
|
|||
def get_sector(self, id: str) -> Sector:
|
||||
return self.sectors[id]
|
||||
|
||||
def update_sector(self, objective_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
|
||||
obj = self.get_objective(objective_id)
|
||||
obj.set_name(name)
|
||||
|
||||
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.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):
|
||||
camp = self.get_campaign_by_sector(sector_id)
|
||||
camp.remove_sector(sector_id)
|
||||
|
|
@ -204,6 +207,26 @@ class War:
|
|||
camp = self.get_campaign_by_campaign_participant(participant_id)
|
||||
camp.remove_campaign_participant(participant_id)
|
||||
|
||||
# Round methods
|
||||
|
||||
def add_round(self, campaign_id: str) -> Round:
|
||||
camp = self.get_campaign(campaign_id)
|
||||
return camp.add_round()
|
||||
|
||||
def remove_round(self, round_id: str):
|
||||
camp = self.get_campaign_by_round(round_id)
|
||||
camp.remove_round(round_id)
|
||||
|
||||
# Choice methods
|
||||
|
||||
def create_choice(self, round_id: str, participant_id: str) -> Choice:
|
||||
camp = self.get_campaign_by_round(round_id)
|
||||
return camp.create_choice(round_id, participant_id)
|
||||
|
||||
def remove_choice(self, round_id: str, participant_id: str):
|
||||
camp = self.get_campaign_by_round(round_id)
|
||||
camp.remove_choice(round_id, participant_id)
|
||||
|
||||
class Objective:
|
||||
def __init__(self, name: str, description: str):
|
||||
self.id: str = str(uuid4())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue