from uuid import uuid4 class Round: def __init__(self): self.id = str(uuid4()) self.sectors = {} self.choices = {} self.battles = {} self.is_over = False def set_id(self, new_id): self.id = new_id def set_state(self, new_state): self.is_over = new_state def toDict(self): return { "id": self.id, # "sectors" : self.sectors, # "choices" : self.choices, # "battles" : self.battles, "is_over": self.is_over } @staticmethod def fromDict(data: dict): rnd = Round() rnd.set_id(data["id"]) # rnd.sectors = data.get("sectors", {}) # rnd.choices = data.get("choices", {}) # rnd.battles = data.get("battles", {}) rnd.set_state(data.get("is_over", False)) return rnd