Story System - State Manager¶
File: cogs/story/state_manager.py
The StoryStateManager is a focused utility responsible for applying state changes to a StoryInstance based on the structured plan provided by the Director (GM) agent.
StoryStateManager Class¶
__init__(self, bot)¶
Initializes the state manager.
async update_state_from_gm_plan(self, instance: StoryInstance, gm_plan: GMActionPlan) -> StoryInstance¶
This is the primary method of the class. It takes the current story instance and the GMActionPlan from the Director AI and applies the planned updates.
- Parameters:
instance(StoryInstance): The current state of the story.gm_plan(GMActionPlan): The structured plan from the Director AI.
- Process:
- Core State Update: It checks the
state_updatefield of the plan. If it exists, it updates theinstance'scurrent_location,current_date, andcurrent_timewith the new values from the plan. - Relationship Logging: It logs any relationship updates specified in the
relationships_updatefield of the plan. The actual database update for relationships is handled in theStoryManager. - Event Log Management: It ensures the
event_logon the story instance does not grow indefinitely by trimming it to the last 20 entries.
- Core State Update: It checks the
- Returns: The modified
StoryInstanceobject with the updated state.
initialize_default_state(self, instance: StoryInstance) -> StoryInstance¶
A helper method to set up default values for a new story instance, such as setting the initial weather to "sunny".