Add !reset_story wizard command to restart story without server restart #128

Merged
Copilot merged 7 commits from copilot/investigate-resetting-story into update-v0.42.0 2025-11-26 15:23:52 -05:00
Copilot commented 2025-11-23 11:47:07 -05:00 (Migrated from github.com)

Story resets currently require a full server restart, disconnecting all players and losing session state.

Changes

Command Layer (tale/cmds/wizard.py)

  • Added !reset_story wizard command with confirmation dialog
  • Catches and reports exceptions during reset

Driver Layer (tale/driver.py)

  • Implemented Driver.reset_story() method that:
    • Clears deferreds, items, NPCs, locations, exits from MudObjRegistry
    • Preserves player objects by filtering by vnum before registry clear
    • Reloads story module and zone modules via sys.modules removal + importlib.reload()
    • Resets game clock and re-registers periodicals
    • Moves players to starting locations

Tests (tests/test_reset_story.py)

  • Unit tests for command registration, confirmation flow, and driver integration

Usage

# As wizard in-game
!reset_story
# Prompts: "Are you sure you want to reset the story? This will affect all players!"
# On confirmation: resets world, preserves player inventory/stats/connections

Preserved vs Reset

Preserved: Player objects, inventory, stats, privileges, active connections, server uptime

Reset: All NPCs/items/locations/exits, deferreds, game clock, zone state

The solution is general at the Driver level as requested, working with any story type.

Original prompt

This section details on the original issue you should resolve

<issue_title>investigate restarting/resetting story</issue_title>
<issue_description>Currently, a story is started when the server is started, ie

python stories.my_story.story

investigate if it's possible to restart a story, without having to restart the server.

preferably a general solution, either in Story, or Driver level.

it should be a wizard command, like "reset_story".</issue_description>

Comments on the Issue (you are @copilot in this section)


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Story resets currently require a full server restart, disconnecting all players and losing session state. ## Changes **Command Layer** (`tale/cmds/wizard.py`) - Added `!reset_story` wizard command with confirmation dialog - Catches and reports exceptions during reset **Driver Layer** (`tale/driver.py`) - Implemented `Driver.reset_story()` method that: - Clears deferreds, items, NPCs, locations, exits from MudObjRegistry - Preserves player objects by filtering by vnum before registry clear - Reloads `story` module and zone modules via `sys.modules` removal + `importlib.reload()` - Resets game clock and re-registers periodicals - Moves players to starting locations **Tests** (`tests/test_reset_story.py`) - Unit tests for command registration, confirmation flow, and driver integration ## Usage ```python # As wizard in-game !reset_story # Prompts: "Are you sure you want to reset the story? This will affect all players!" # On confirmation: resets world, preserves player inventory/stats/connections ``` ## Preserved vs Reset **Preserved:** Player objects, inventory, stats, privileges, active connections, server uptime **Reset:** All NPCs/items/locations/exits, deferreds, game clock, zone state The solution is general at the Driver level as requested, working with any story type. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>investigate restarting/resetting story</issue_title> > <issue_description>Currently, a story is started when the server is started, ie > > python stories.my_story.story > > investigate if it's possible to restart a story, without having to restart the server. > > preferably a general solution, either in Story, or Driver level. > > it should be a wizard command, like "reset_story".</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes neph1/LlamaTale#127 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/neph1/LlamaTale/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
neph1 (Migrated from github.com) approved these changes 2025-11-23 16:09:43 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
neph1/LlamaTale!128
No description provided.