You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document describes the implementation of the `!reset_story` wizard command that allows restarting/resetting a story without having to restart the server.
5
+
6
+
## Feature Description
7
+
The `!reset_story` command provides a way to reset the game world back to its initial state while keeping the server running and players connected. This is particularly useful for:
8
+
- Testing story changes during development
9
+
- Recovering from a broken game state
10
+
- Restarting a story for a fresh playthrough without disconnecting players
11
+
12
+
## Usage
13
+
As a wizard (user with wizard privileges), type:
14
+
```
15
+
!reset_story
16
+
```
17
+
18
+
The command will:
19
+
1. Prompt for confirmation (as this affects all players)
20
+
2. If confirmed, reset the story world
21
+
3. Move all players back to their starting locations
22
+
4. Display a completion message
23
+
24
+
## Implementation Details
25
+
26
+
### Files Modified
27
+
-**tale/cmds/wizard.py**: Added the `do_reset_story` wizard command function
28
+
-**tale/driver.py**: Added the `reset_story()` method to the Driver class
29
+
-**tests/test_reset_story.py**: Added unit tests for the reset functionality
30
+
31
+
### What Gets Reset
32
+
1.**Deferreds**: All scheduled actions are cleared
33
+
2.**MudObject Registry**:
34
+
- All items are removed
35
+
- All NPCs and non-player livings are removed
36
+
- All locations are cleared (except players remain in registry)
37
+
- All exits are cleared
38
+
3.**Story Module**: The story module is reloaded from disk
39
+
4.**Zones**: All zone modules are unloaded and reloaded
40
+
5.**Game Clock**: Reset to the story's epoch or current time
41
+
6.**Player Positions**: All players are moved to their designated starting locations
42
+
43
+
### What Is Preserved
44
+
1.**Player Objects**: Player objects remain in the registry with the same vnum
45
+
2.**Player Inventory**: Players keep their items
46
+
3.**Player Stats**: Player statistics and attributes are preserved
47
+
4.**Player Connections**: Active player connections remain intact
48
+
5.**Server Uptime**: The server uptime counter continues
49
+
50
+
### Technical Approach
51
+
The implementation handles several challenging aspects:
52
+
53
+
1.**Module Reloading**: Python modules are removed from `sys.modules` and reimported to get fresh instances
54
+
2.**Registry Management**: The MudObjRegistry is selectively cleared to preserve players while removing other objects
55
+
3.**Safe Exception Handling**: Specific exceptions are caught when removing players from old locations
56
+
4.**Sequence Number Management**: The registry sequence number is adjusted to account for existing player vnums
57
+
58
+
### Error Handling
59
+
- If the story module cannot be reloaded, an error message is displayed
60
+
- If starting locations cannot be found, players are notified
61
+
- If a player's old location is in an invalid state, the error is caught and ignored
62
+
- All exceptions during reset are caught and reported to the wizard who initiated the command
63
+
64
+
## Testing
65
+
The implementation includes comprehensive unit tests:
66
+
- Test that the command exists and is registered
67
+
- Test that the command is a generator (for confirmation dialog)
68
+
- Test that confirmation is required
69
+
- Test that the Driver.reset_story method exists
70
+
- Test that the command calls the driver's reset method when confirmed
71
+
72
+
## Future Enhancements
73
+
Possible improvements for future versions:
74
+
- Option to reset only specific zones
75
+
- Option to preserve or clear player inventories
76
+
- Backup/restore of game state before reset
77
+
- Configuration to exclude certain objects from reset
78
+
- Reset statistics tracking (number of resets, last reset time)
79
+
80
+
## Known Limitations
81
+
1. Custom story data not managed by the standard story/zone system may not be properly reset
82
+
2. External systems (databases, file caches) are not automatically reset
83
+
3. LLM cache and character memories are not cleared (may need manual cleanup)
84
+
4. Player wiretaps are not automatically re-established after reset
85
+
86
+
## Command Documentation
87
+
The command includes built-in help accessible via:
0 commit comments