Files
ages/agame/dialog.py

41 lines
969 B
Python
Raw Permalink Normal View History

import dataclasses
from typing import Mapping, Optional, Sequence, TYPE_CHECKING
if TYPE_CHECKING:
from agame.action import Action
@dataclasses.dataclass
class DialogOption:
# The text for this dialog option.
text: str
# The actions that get executed upon choosing this dialog option.
actions: Sequence["Action"] = dataclasses.field(default_factory=list)
# The variable required for being able to display this dialog option.
#
# This variable must not be equal to `False`.
required_var: Optional[str] = None
# The next dialog that is chosen.
next: Optional[str] = None
{
"main": {
"type": "reply",
"options": [
{
"text": "What happened here?",
"next": "main",
"actions": [],
},
{
"text": "Bye.",
},
],
},
"bye": {
"type": "print",
"text": "Mhm.",
},
}