feat(engine): 实现行动点系统

- 扩展 AgentState 添加 action_points, max_action_points, last_action_tick 字段
- 新增 ActionFeedback 模型用于返回行动执行结果
- 创建 action_points.py 模块实现行动点消耗与恢复逻辑
- 行动消耗表: vote=1, trigger_skill=2, influence=2, comment/support/chaos=0
- 每 tick 恢复 1 点行动点(不超过 max)
- 行动点不足时拒绝执行并返回失败反馈
- 新增 7 个测试用例,全部 37 个测试通过

🤖 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 13:48:33 +08:00
parent 4664796d0b
commit 5ae63d9df9
6 changed files with 267 additions and 7 deletions

View File

@@ -108,6 +108,14 @@ class StoryEventResult(BaseModel):
description: Optional[str] = None
class ActionFeedback(BaseModel):
"""行动反馈"""
success: bool = True
reason: str = ""
remaining_ap: int = 0
user: str = ""
class AgentState(BaseModel):
emotion: Emotion = Emotion.CALM
goal: str = ""
@@ -119,6 +127,10 @@ class AgentState(BaseModel):
stance: Stance = Field(default_factory=Stance)
# 所属阵营
faction: str = "neutral" # "optimists" | "fearful" | "neutral"
# 行动点系统
action_points: int = Field(default=3, ge=0)
max_action_points: int = Field(default=3, ge=1)
last_action_tick: int = 0
class WorldState(BaseModel):
@@ -171,3 +183,4 @@ class StepResponse(BaseModel):
global_event: GlobalEventResult = Field(default_factory=GlobalEventResult)
triggered_faction_event: FactionEventResult = Field(default_factory=FactionEventResult)
story_event: StoryEventResult = Field(default_factory=StoryEventResult)
action_feedbacks: List[ActionFeedback] = Field(default_factory=list)