Fixed RPG

This commit is contained in:
2026-06-01 07:44:38 +03:00
parent 600ad78f05
commit d4cd8f02f4
30 changed files with 1516 additions and 816 deletions
+19 -1
View File
@@ -27,7 +27,7 @@ Return ONLY valid JSON (no markdown):
"cast": [{"name":"NPC name","role":"helper|antagonist|bystander","motivation":"..."}],
"secrets": ["hidden truths not revealed yet"],
"beats": [
{"id":"b1","trigger":"event_driven:rest|event_driven:travel|event_driven:help_request|event_driven:after_fail|event_driven:after_success",
{"id":"b1","title":"short quest title (3-6 words)","trigger":"event_driven:rest|event_driven:travel|event_driven:help_request|event_driven:after_fail|event_driven:after_success",
"injection":"1-3 sentences to introduce the beat WITHOUT breaking current scene",
"choices":[{"id":"a","label":"..."},{"id":"b","label":"..."}]}
],
@@ -90,6 +90,24 @@ def should_advance_arc(user_text: str) -> str | None:
return None
PHASE_ORDER = ["opening", "hook", "complication", "reveal", "climax", "aftermath"]
def advance_phase(arc: dict) -> bool:
"""Advance arc to next phase if beats are exhausted. Returns True if phase changed."""
current = arc.get("phase", "opening")
if arc.get("beats"):
return False
try:
idx = PHASE_ORDER.index(current)
except ValueError:
return False
if idx + 1 >= len(PHASE_ORDER):
return False
arc["phase"] = PHASE_ORDER[idx + 1]
return True
def pop_matching_beats(arc: dict, trigger: str, max_beats: int = 1) -> tuple[dict, list[dict]]:
beats = arc.get("beats", [])
if not isinstance(beats, list):