save & load wars
This commit is contained in:
parent
1218f32752
commit
dc854b4065
5 changed files with 52 additions and 50 deletions
|
|
@ -29,20 +29,21 @@ class Campaign:
|
|||
"id" : self.id,
|
||||
"name" : self.name,
|
||||
"month" : self.month,
|
||||
"entrants" : self.entrants,
|
||||
"rounds" : self.rounds,
|
||||
# "entrants" : self.entrants,
|
||||
"rounds": [rnd.toDict() for rnd in self.rounds],
|
||||
"is_over": self.is_over
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def fromDict(id, name, month, entrants, rounds, is_over):
|
||||
tmp = Campaign(name=name)
|
||||
tmp.set_id(id)
|
||||
tmp.set_month(month)
|
||||
## entrants placeholder
|
||||
## rounds placeholder
|
||||
tmp.set_state(is_over)
|
||||
return tmp
|
||||
def fromDict(data: dict):
|
||||
camp = Campaign(name=data["name"])
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue