feat(engine): add story arc system for narrative-driven world

- Add StoryArc and StoryEventResult models
- Create story_arcs.py with progress tracking logic
- Implement two story arcs: civil_unrest and golden_age
- Progress updates based on faction power balance
- Trigger story events when progress reaches threshold
- Add 3 tests for story arc system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2025-12-30 12:06:14 +08:00
parent 1fd318c9e3
commit cec3e95a4b
5 changed files with 178 additions and 1 deletions

View File

@@ -348,3 +348,36 @@ def test_triggered_faction_event_in_response(client):
assert "triggered_faction_event" in data
assert "type" in data["triggered_faction_event"]
assert "source_faction" in data["triggered_faction_event"]
def test_story_arcs_exists_in_world_state(client):
"""测试 world_state 包含 story_arcs 字段"""
resp = client.post("/step", json={"events": []})
data = resp.json()
assert "story_arcs" in data["world_state"]
story_arcs = data["world_state"]["story_arcs"]
assert "civil_unrest" in story_arcs
assert "golden_age" in story_arcs
def test_story_arc_has_required_fields(client):
"""测试 story_arc 包含必要字段"""
resp = client.post("/step", json={"events": []})
data = resp.json()
for arc_id, arc in data["world_state"]["story_arcs"].items():
assert "progress" in arc
assert "threshold" in arc
assert "active" in arc
assert "stage" in arc
def test_story_event_in_response(client):
"""测试响应包含 story_event 字段"""
resp = client.post("/step", json={"events": []})
data = resp.json()
assert "story_event" in data
assert "triggered" in data["story_event"]
assert "arc_id" in data["story_event"]