1
0
Fork 0
taleweave-ai/adventure/models.py

58 lines
1.2 KiB
Python
Raw Normal View History

2024-05-02 11:56:57 +00:00
from typing import TYPE_CHECKING, Callable, Dict, List
from pydantic import Field
if TYPE_CHECKING:
from dataclasses import dataclass
else:
from pydantic.dataclasses import dataclass as dataclass # noqa
Actions = Dict[str, Callable]
2024-05-05 22:46:24 +00:00
AttributeValue = bool | int | str
Attributes = Dict[str, AttributeValue]
2024-05-02 11:56:57 +00:00
@dataclass
class Item:
name: str
description: str
actions: Actions = Field(default_factory=dict)
2024-05-05 22:46:24 +00:00
attributes: Attributes = Field(default_factory=dict)
2024-05-02 11:56:57 +00:00
@dataclass
class Actor:
name: str
backstory: str
description: str
actions: Actions = Field(default_factory=dict)
items: List[Item] = Field(default_factory=list)
2024-05-05 22:46:24 +00:00
attributes: Attributes = Field(default_factory=dict)
2024-05-02 11:56:57 +00:00
@dataclass
class Room:
name: str
description: str
portals: Dict[str, str] = Field(default_factory=dict)
items: List[Item] = Field(default_factory=list)
actors: List[Actor] = Field(default_factory=list)
actions: Actions = Field(default_factory=dict)
2024-05-05 22:46:24 +00:00
attributes: Attributes = Field(default_factory=dict)
2024-05-02 11:56:57 +00:00
@dataclass
class World:
name: str
2024-05-04 04:18:21 +00:00
order: List[str]
2024-05-02 11:56:57 +00:00
rooms: List[Room]
theme: str
@dataclass
class WorldState:
memory: Dict[str, List[str | Dict[str, str]]]
step: int
2024-05-04 04:18:21 +00:00
world: World