Add room entry auto-triggers, player input, and more
* When you teleport to a room, the teleport auto-triggers fire. * Rooms have auto-triggers. None by default. They are run every time you teleport to a room, and when the game starts. Gate behavior behind a variable. * PlayerInputAction waits for player input (and potentially write it into a variable) Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -3,6 +3,9 @@ from typing import MutableMapping, Optional, Sequence, Union, TYPE_CHECKING
|
||||
from agame.item import ItemInst
|
||||
from agame.util import search_item_name
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from agame.action import Action
|
||||
|
||||
|
||||
__all__ = ("Room",)
|
||||
|
||||
@@ -13,6 +16,8 @@ class Room:
|
||||
name: str
|
||||
desc: Union[str, Sequence[str]]
|
||||
items: MutableMapping[str, ItemInst]
|
||||
# Actions that are executed upon teleport or entrance to this room.
|
||||
teleport_actions: Sequence["Action"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -20,6 +25,7 @@ class Room:
|
||||
name: str,
|
||||
desc: Union[str, Sequence[str]],
|
||||
items: Union[Sequence[ItemInst], MutableMapping[str, ItemInst]],
|
||||
teleport_actions: Sequence["Action"] = [],
|
||||
):
|
||||
self.id = id
|
||||
self.name = name
|
||||
@@ -28,6 +34,7 @@ class Room:
|
||||
self.items = items
|
||||
else:
|
||||
self.items = {item.id: item for item in items}
|
||||
self.teleport_actions = teleport_actions
|
||||
|
||||
def search_item_name(self, item_name: str) -> Optional[ItemInst]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user