forked from Cathesth/TRPG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.py
More file actions
96 lines (69 loc) · 3.53 KB
/
schemas.py
File metadata and controls
96 lines (69 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from pydantic import BaseModel, Field
from typing import List, Any, Optional
# --- Basic Components ---
class GlobalVariable(BaseModel):
name: str = Field(description="Variable name (e.g., 'hp', 'gold', 'sanity')")
initial_value: int = Field(default=0, description="Starting value")
type: str = Field(default="int", description="int, boolean, string")
class Item(BaseModel):
name: str = Field(description="Unique item name")
description: str = Field(description="Item flavor text")
is_key_item: bool = Field(default=False, description="If true, critical for progression")
# --- Logic Components ---
class Condition(BaseModel):
target: str = Field(description="Variable name OR Item name")
type: str = Field(description="'variable' or 'item'")
operator: str = Field(description=">, <, ==, >=, <=, has, not_has")
value: Any = Field(description="Comparison value (e.g., 50, true)")
class Effect(BaseModel):
target: str = Field(description="Variable name OR Item name")
type: str = Field(description="'variable' or 'item'")
operation: str = Field(description="add, subtract, set, gain_item, lose_item")
value: Any
# --- Scene Components (CHANGED) ---
class SceneTransition(BaseModel):
"""
Choice(선택지) 대신 사용.
플레이어가 특정 행동을 했을 때 다음 씬으로 넘어가는 '규칙'을 정의함.
"""
target_scene_id: str = Field(description="ID of the destination scene")
trigger: str = Field(
description="The action or event that triggers this transition (e.g., 'Player opens the door', 'Player attacks the merchant'). NOT a UI button text.")
conditions: List[Condition] = Field(default=[], description="Requirements for this transition to happen")
effects: List[Effect] = Field(default=[], description="Side effects when this transition happens")
class NPC(BaseModel):
name: str
role: str = Field(description="Role in the story")
personality: str = Field(description="Personality traits")
description: str = Field(description="Visual description")
image_prompt: Optional[str] = Field(None, description="Prompt for generating NPC portrait")
dialogue_style: str = Field(description="How they speak")
class Scene(BaseModel):
scene_id: str
title: str
description: str = Field(description="Detailed scene description text. Pure narrative.")
image_prompt: Optional[str] = Field(None, description="Prompt for generating scene background image")
# Legacy fields (Optional)
required_item: Optional[str] = Field(None)
required_action: Optional[str] = Field(None)
npcs: List[str] = Field(default=[], description="Names of NPCs present in this scene")
# Changed from choices to transitions
transitions: List[SceneTransition] = Field(default=[],
description="Possible paths to other scenes based on player actions.")
class Ending(BaseModel):
ending_id: str
title: str
description: str
image_prompt: Optional[str] = Field(None, description="Ending illustration prompt")
condition: str = Field(description="Narrative condition")
# --- Root Schema ---
class GameScenario(BaseModel):
title: str
genre: str = Field(description="Fantasy, Sci-Fi, Horror, etc.")
background_story: str
prologue: str
variables: List[GlobalVariable] = Field(default=[], description="Global state variables")
items: List[Item] = Field(default=[], description="Registry of all items")
npcs: List[NPC]
scenes: List[Scene]
endings: List[Ending]