Add modern death recovery - #223
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a named modern feature gate (modern_death_recovery) that provides a less-punishing death outcome for non-honor players, while preserving the legacy full-reset behavior for honor-mode and force-honor deaths. It centralizes death recovery into a shared DeathRecoveryPlan so command damage, YAML room-script damage, and Zar animation deaths follow the same modern recovery rules and persistence ordering.
Changes:
- Added
modern_death_recoveryto the modern feature registry and documented its contract indocs/MODERN_FEATURES.md, with an accompanying manual E2E checklist update indocs/PORTING_PLAN.md. - Implemented shared modern death recovery planning/application logic (
DeathRecoveryPlan) including level loss, effect/spell clearing, inventory drop placement (spill + dark forest fallback), and metadata for WebSocket/UI refreshes. - Routed command-path, YAML
damage, and Zar deaths through the shared recovery plan with atomic persistence and expanded unit/WebSocket test coverage.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/PORTING_PLAN.md | Adds modern-death recovery checklist coverage to the porting plan. |
| docs/MODERN_FEATURES.md | Documents the modern feature taxonomy and the modern_death_recovery contract. |
| backend/kyrgame/constants.py | Introduces named constants for modern death recovery (rooms, object ids, exhaustion, thresholds). |
| backend/kyrgame/modern_features.py | Registers modern_death_recovery as an active modern feature with refs/tests. |
| backend/kyrgame/player_lifecycle.py | Adds DeathRecoveryPlan + modern recovery planning and application logic, including item placement. |
| backend/kyrgame/commands.py | Applies modern recovery to command damage deaths, with atomic persistence and per-room drop broadcasts. |
| backend/kyrgame/yaml_rooms.py | Applies modern recovery to YAML damage, including deferred-mode planning and event metadata. |
| backend/kyrgame/rooms.py | Plumbs deferred modern death recovery through the room script engine and room-object syncing. |
| backend/kyrgame/webapp.py | Commits deferred YAML modern recovery plans before mutating live state / broadcasting. |
| backend/kyrgame/world/animation_tick_system.py | Applies modern recovery to Zar deaths, with optional atomic persister support. |
| backend/kyrgame/runtime.py | Implements Zar modern-death atomic persistence and forwards modern recovery metadata in events. |
| backend/tests/test_player_lifecycle.py | Adds unit coverage for modern recovery plan behavior (spellbook preservation, GOTKYG clearing, drops). |
| backend/tests/test_commands_cast.py | Adds command-path modern recovery tests including persistence-failure safety. |
| backend/tests/test_yaml_room_engine.py | Adds YAML damage modern recovery behavior coverage. |
| backend/tests/test_room_scripts.py | Adds integration coverage for spill-room syncing and deferred-mode staging. |
| backend/tests/world/test_animation_tick_system.py | Adds Zar modern recovery coverage (force-honor legacy path, modern path, persister failure). |
| backend/tests/test_gateway_dispatch_bridge.py | Adds WebSocket end-to-end coverage for Zar modern death recovery metadata and persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2580c46cee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9152f9c44d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 194728d46f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Adds the clearly named
modern_death_recoveryfeature for non-honor deaths while preserving the existing honor and forced-honor death reset path.Routes command damage, YAML room damage, and Zar animation deaths through a shared death recovery plan, and documents modern behavior in
docs/MODERN_FEATURES.md.Changes
DeathRecoveryPlanplumbing.DROPIT3notices and exclude the victim from room fan-out to avoid duplicate notices.Motivation & Context
Intent
modern_death_recoveryso maintainers can review, disable, or extract it separately from legacy behavior.Context
legacy/KYRSYSP.C:148and adds the requested castle soulstone/kyragem recovery rule.Legacy code being ported
legacy/KYRSYSP.C- death reset and GOTKYG threshold behavior.DIEMSG,KILLED, holy-light arrival,DROPIT3,S11M06, androom_objectsevent behavior.backend/kyrgame/player_lifecycle.py- sharedDeathRecoveryPlan, modern state mutation, and item placement rules.backend/kyrgame/commands.py- command damage modern recovery and atomic persistence path.backend/kyrgame/yaml_rooms.py/backend/kyrgame/rooms.py- YAMLdamagemodern recovery, deferred recovery planning, live spill-room refresh, and multi-room object sync.backend/kyrgame/world/animation_tick_system.py/backend/kyrgame/runtime.py/backend/kyrgame/webapp.py- Zar death recovery, persistence, and WebSocket refresh metadata.backend/kyrgame/constants.py/backend/kyrgame/modern_features.py- named constants and modern feature registry.docs/MODERN_FEATURES.md/docs/PORTING_PLAN.md- canonical documentation and manual demo checklist.DIEMSG,KILLED, and willow arrival messages.Testing
cd legacy && make -f ELWKYR(Worldgroup build)pytest backend/testscd backend && python -m kyrgame.scripts.package_content --output ../legacy/Dist/offline-content.jsonpython.exe -m py_compile backend\kyrgame\commands.py backend\kyrgame\yaml_rooms.py backend\kyrgame\rooms.py backend\kyrgame\runtime.py backend\kyrgame\webapp.py backend\kyrgame\world\animation_tick_system.pypython.exe -m pytest backend\tests\world\test_animation_tick_system.py::test_zarfood_modern_death_persister_failure_keeps_predeath_state backend\tests\test_room_scripts.py::test_yaml_modern_death_deferred_mode_stages_spill_until_caller_commits backend\tests\test_commands_cast.py::test_cast_zelastone_target_hit_modern_death_recovery_drops_and_filters_items -qpython.exe -m pytest backend\tests\test_commands_cast.py::test_cast_zelastone_target_hit_modern_death_recovery_drops_and_filters_items backend\tests\test_yaml_room_engine.py::test_damage_action_uses_modern_death_recovery_for_non_honor_player backend\tests\world\test_animation_tick_system.py::test_zarfood_uses_modern_death_recovery_for_non_honor_player backend\tests\test_gateway_dispatch_bridge.py::test_websocket_zar_death_uses_modern_recovery_for_non_honor_player -qpython.exe -m pytest backend\tests\test_player_lifecycle.py backend\tests\test_commands_cast.py backend\tests\test_yaml_room_engine.py backend\tests\test_room_scripts.py backend\tests\world\test_animation_tick_system.py backend\tests\test_modern_features.py backend\tests\test_gateway_dispatch_bridge.py::test_websocket_zar_death_refreshes_target_room_and_arrival_witness backend\tests\test_gateway_dispatch_bridge.py::test_websocket_zar_death_uses_modern_recovery_for_non_honor_player backend\tests\test_gateway_dispatch_bridge.py::test_websocket_spell_death_refreshes_target_room_and_arrival_witness -qpython.exe -m pytest backend\tests\test_command_dispatcher.py::test_rub_dragonstaff_uses_legacy_rub_path backend\tests\test_command_dispatcher.py::test_rub_dragonstaff_attacks_when_zar_is_already_here -qgit diff --cached --checkhttp://127.0.0.1:8000/openapi.json, frontendhttp://127.0.0.1:5173/, backend container source inspection formodern_death_recovery.Details:
Manual E2E Demo Checklist
kyrgame-local.zt...non-honor test player near Zar with level, spellbook bits, memorized spells, charms/effects, gold, soulstone/kyragem, and ordinary inventory.302and confirm the dying player sees item-drop text before death text, then willow arrival, one-level reduction, max HP/SP for the new level, exhaustion, gold loss, memorized-spell loss, spellbook preservation, effect clearing, and castle soulstone/kyragem filtering.Risk & Rollback
DeathRecoveryPlanmetadata and room-object updates.UI Changes