Open
Refactor narrative_nodes.json: 57.7% line reduction via templates, merged actions, inline end nodes#8
Conversation
…erged fire actions, inline end nodes
…tion, improve docstrings
Copilot
AI
changed the title
[WIP] Optimize narrative nodes data file for clarity and maintenance
Refactor narrative_nodes.json: 57.7% line reduction via templates, merged actions, inline end nodes
Jul 12, 2026
mimi99528
marked this pull request as ready for review
July 13, 2026 05:04
mimi99528
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
narrative_nodes.jsonhad grown to 1139 lines in prototype stage due to redundant per-action five-level result sets, 4 near-identical fire distraction actions, and 5 content-free_endplaceholder nodes. This PR restructures the data and updates all consuming code.Data file (
narrative_nodes.json): 1139 → 482 lines (−57.7%)New top-level structure:
{ "outcome_templates": { "fire_distraction": { "大成功": {...}, "成功": {...}, ... } }, "nodes": [ ... ] }火焰箭/火球术/点火术→ single点燃类action referencing shared template via{"$template": "fire_distraction"}. Key matches action name directly — no fallback lookup needed._endnodes:altar_site_001_endetc. replaced by"__end__"sentinel innext_nodes+end_summaryfield on the parent node.narrative_system.pyNarrativeNode.from_dictacceptstemplates: Optional[Dict]param; detects and handles threeresults_poolformats: legacy list, new compact dict, and{"$template": "..."}reference._resolve_templatestatic method for{param}substitution in template text.load_from_filedetects new{outcome_templates, nodes}top-level dict vs. old flat list (backward compatible).end_summary: Optional[str]field toNarrativeNode.NarrativeResultdocstring documents the full effects field schema (30+ effect types) as canonical reference.scene_manager.py/game_view.py_handle_narrative_confirmnow checksnext_node_id == "__end__"to return to map, replacing the oldis_end_nodelookup against a now-removed node object.