save/load participants, objectives, sectors, choices & battles
This commit is contained in:
parent
7fbdacf97c
commit
6cd3a060c7
9 changed files with 152 additions and 11 deletions
|
|
@ -22,9 +22,8 @@ class Round:
|
|||
def toDict(self) -> Dict[str, Any]:
|
||||
return {
|
||||
"id": self.id,
|
||||
# "sectors" : self.sectors,
|
||||
# "choices" : self.choices,
|
||||
# "battles" : self.battles,
|
||||
"choices": [c.toDict() for c in self.choices.values()],
|
||||
"battles": [b.toDict() for b in self.battles.values()],
|
||||
"is_over": self.is_over,
|
||||
}
|
||||
|
||||
|
|
@ -32,9 +31,12 @@ class Round:
|
|||
def fromDict(data: Dict[str, Any]) -> Round:
|
||||
rnd = Round()
|
||||
rnd.set_id(data["id"])
|
||||
# rnd.sectors = data.get("sectors", {})
|
||||
# rnd.choices = data.get("choices", {})
|
||||
# rnd.battles = data.get("battles", {})
|
||||
for c in data.get("choices", []):
|
||||
choice = Choice.fromDict(c)
|
||||
rnd.choices[choice.participant_id] = choice
|
||||
for b in data.get("battles", []):
|
||||
battle = Battle.fromDict(b)
|
||||
rnd.battles[battle.sector_id] = battle
|
||||
rnd.set_state(data.get("is_over", False))
|
||||
return rnd
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue