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
|
|
@ -1,3 +1,7 @@
|
|||
from __future__ import annotations
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
class Battle:
|
||||
def __init__(
|
||||
self,
|
||||
|
|
@ -33,3 +37,27 @@ class Battle:
|
|||
|
||||
def set_comment(self, new_comment: str | None) -> None:
|
||||
self.comment = new_comment
|
||||
|
||||
def toDict(self) -> Dict[str, Any]:
|
||||
return {
|
||||
"sector_id": self.sector_id,
|
||||
"player_1_id": self.player_1_id,
|
||||
"player_2_id": self.player_2_id,
|
||||
"winner_id": self.winner_id,
|
||||
"score": self.score,
|
||||
"victory_condition": self.victory_condition,
|
||||
"comment": self.comment,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def fromDict(data: Dict[str, Any]) -> Battle:
|
||||
battle = Battle(
|
||||
data["sector_id"],
|
||||
data.get("player_1_id"),
|
||||
data.get("player_2_id"),
|
||||
)
|
||||
battle.winner_id = data.get("winner_id")
|
||||
battle.score = data.get("score")
|
||||
battle.victory_condition = data.get("victory_condition")
|
||||
battle.comment = data.get("comment")
|
||||
return battle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue