add/edit/delet objectives and participants in war
This commit is contained in:
parent
e33dec40be
commit
495a5adb98
14 changed files with 1088 additions and 322 deletions
|
|
@ -1,27 +1,29 @@
|
|||
from __future__ import annotations
|
||||
from uuid import uuid4
|
||||
from datetime import datetime
|
||||
|
||||
from warchron.model.round import Round
|
||||
|
||||
class Campaign:
|
||||
def __init__(self, name, month):
|
||||
self.id = str(uuid4())
|
||||
self.name = name
|
||||
self.month = month
|
||||
self.entrants = {}
|
||||
def __init__(self, name: str, month: int):
|
||||
self.id: str = str(uuid4())
|
||||
self.name: str = name
|
||||
self.month: int = month
|
||||
self.participants = {}
|
||||
self.sectors = {}
|
||||
self.rounds = []
|
||||
self.is_over = False
|
||||
|
||||
def set_id(self, new_id):
|
||||
def set_id(self, new_id: str):
|
||||
self.id = new_id
|
||||
|
||||
def set_name(self, new_name):
|
||||
def set_name(self, new_name: str):
|
||||
self.name = new_name
|
||||
|
||||
def set_month(self, new_month):
|
||||
def set_month(self, new_month: int):
|
||||
self.month = new_month
|
||||
|
||||
def set_state(self, new_state):
|
||||
def set_state(self, new_state: bool):
|
||||
self.is_over = new_state
|
||||
|
||||
def toDict(self):
|
||||
|
|
@ -29,7 +31,7 @@ class Campaign:
|
|||
"id" : self.id,
|
||||
"name" : self.name,
|
||||
"month" : self.month,
|
||||
# "entrants" : self.entrants,
|
||||
# "participants" : self.participants,
|
||||
"rounds": [rnd.toDict() for rnd in self.rounds],
|
||||
"is_over": self.is_over
|
||||
}
|
||||
|
|
@ -38,13 +40,16 @@ class Campaign:
|
|||
def fromDict(data: dict):
|
||||
camp = Campaign(name=data["name"], month=data["month"])
|
||||
camp.set_id(data["id"])
|
||||
# camp.entrants = data.get("entrants", {})
|
||||
# camp.participants = data.get("participants", {})
|
||||
for rnd_data in data.get("rounds", []):
|
||||
camp.rounds.append(Round.fromDict(rnd_data))
|
||||
camp.set_state(data.get("is_over", False))
|
||||
return camp
|
||||
|
||||
def has_round(self, round_id: str) -> bool:
|
||||
return any(r.id == round_id for r in self.rounds)
|
||||
|
||||
def get_round(self, round_id) -> Round:
|
||||
def get_round(self, round_id: str) -> Round:
|
||||
return self.rounds[round_id]
|
||||
|
||||
def get_all_rounds(self) -> list[Round]:
|
||||
|
|
@ -65,3 +70,19 @@ class Campaign:
|
|||
if rnd.id == round_id:
|
||||
return index
|
||||
raise KeyError("Round not found in campaign")
|
||||
|
||||
class CampaignParticipant:
|
||||
def __init__(self,war_participant_id: str, leader: str):
|
||||
self.id: str = war_participant_id # ref to War.participants
|
||||
self.leader: str = leader
|
||||
self.victory_points = 0
|
||||
self.objective_points = {}
|
||||
|
||||
class Sector:
|
||||
def __init__(self, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
|
||||
self.id: str = str(uuid4())
|
||||
self.name: str = name
|
||||
self.major_objective_id: str = major_id
|
||||
self.minor_objective_id: str = minor_id
|
||||
self.influence_objective_id: str = influence_id
|
||||
self.round_id: str = round_id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue