Files
Wyvern-Castle/event.py
2026-01-25 16:07:28 +01:00

26 lines
1.0 KiB
Python

from .serializable import Serializable
from .entity import Action, BonusAction, Entity
import json
class Event(Serializable):
def __init__(self, location:str, entities_objectives:dict[str,str]):
super().__init__()
self.location = location
self.entities_objectives = entities_objectives
self.description = ""
def add_turn_event(self, event_text:str, action:Action, bonus:BonusAction):
event_dict = {}
event_dict['text'] = event_text
event_dict['action'] = action
event_dict['bonus'] = bonus
self.description += json.dumps(event_dict)
def update_objectives(self, entities:list[Entity], objectives:list[str]):
assert len(entities) == len(objectives), f"Number of entities & objectives are different: {len(entities)} (entities) and {len(objectives)} (objectives) !"
n = len(entities)
for i in range(n):
entity_name = entities[i].name
objective = objectives[i]
self.entities_objectives[entity_name] = objective