save/load participants, objectives, sectors, choices & battles

This commit is contained in:
Maxime Réaux 2026-02-06 09:59:54 +01:00
parent 7fbdacf97c
commit 6cd3a060c7
9 changed files with 152 additions and 11 deletions

View file

@ -1,4 +1,5 @@
from __future__ import annotations
from typing import Any, Dict
from uuid import uuid4
@ -22,3 +23,21 @@ class CampaignParticipant:
def set_theme(self, new_theme: str) -> None:
self.theme = new_theme
def toDict(self) -> Dict[str, Any]:
return {
"id": self.id,
"war_participant_id": self.war_participant_id,
"leader": self.leader,
"theme": self.theme,
}
@staticmethod
def fromDict(data: Dict[str, Any]) -> CampaignParticipant:
part = CampaignParticipant(
war_participant_id=data["war_participant_id"],
leader=data.get("leader"),
theme=data.get("theme"),
)
part.set_id(data["id"])
return part