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

57 lines
1.2 KiB
Python
Raw Normal View History

2024-05-09 02:11:16 +00:00
from typing import Callable, Dict, List
2024-05-02 11:56:57 +00:00
from pydantic import Field
2024-05-09 02:11:16 +00:00
from .base import dataclass
2024-05-02 11:56:57 +00:00
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
2024-05-09 02:11:16 +00:00
WorldEntity = Room | Actor | Item