edit/delete player/war/campaign/round
This commit is contained in:
parent
dc854b4065
commit
185733b5d4
9 changed files with 363 additions and 58 deletions
|
|
@ -4,10 +4,10 @@ from datetime import datetime
|
|||
from warchron.model.round import Round
|
||||
|
||||
class Campaign:
|
||||
def __init__(self, name):
|
||||
def __init__(self, name, month):
|
||||
self.id = str(uuid4())
|
||||
self.name = name
|
||||
self.month = datetime.now().month
|
||||
self.month = month
|
||||
self.entrants = {}
|
||||
self.rounds = []
|
||||
self.is_over = False
|
||||
|
|
@ -36,20 +36,14 @@ class Campaign:
|
|||
|
||||
@staticmethod
|
||||
def fromDict(data: dict):
|
||||
camp = Campaign(name=data["name"])
|
||||
camp = Campaign(name=data["name"], month=data["month"])
|
||||
camp.set_id(data["id"])
|
||||
camp.set_month(data["month"])
|
||||
# camp.entrants = data.get("entrants", {})
|
||||
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 add_round(self, number: int) -> Round:
|
||||
round = Round()
|
||||
self.rounds.append(round)
|
||||
return round
|
||||
|
||||
def get_round(self, round_id) -> Round:
|
||||
return self.rounds[round_id]
|
||||
|
||||
|
|
@ -59,4 +53,9 @@ class Campaign:
|
|||
def add_round(self) -> Round:
|
||||
round = Round()
|
||||
self.rounds.append(round)
|
||||
return round
|
||||
return round
|
||||
|
||||
def remove_round(self, round_id: str):
|
||||
rnd = next((r for r in self.rounds if r.id == round_id), None)
|
||||
if rnd:
|
||||
self.rounds.remove(rnd)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue