Add display abstraction
In case we want to run this on something that isn't an ANSI terminal, we have the option to implement it however we want. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ __all__ = (
|
||||
"PrintAction",
|
||||
"PrintRoomAction",
|
||||
"PlayerInputAction",
|
||||
"WaitForAckAction",
|
||||
"TeleportAction",
|
||||
"GetAction",
|
||||
"CheckInvItemsAction",
|
||||
@@ -91,11 +92,10 @@ class PlayerInputAction(Action):
|
||||
Waits for a user to press a key, or press enter, or whatever.
|
||||
"""
|
||||
|
||||
prompt: str = "Press enter to continue..."
|
||||
store_var_id: Optional[str] = None
|
||||
|
||||
def act(self, game: "Game"):
|
||||
line = input(self.prompt)
|
||||
line = game.display.input()
|
||||
if self.store_var_id:
|
||||
assert (
|
||||
self.store_var_id in game.vars
|
||||
@@ -103,6 +103,18 @@ class PlayerInputAction(Action):
|
||||
game.vars[self.store_var_id] = line
|
||||
|
||||
|
||||
class WaitForAckAction(Action):
|
||||
"""
|
||||
Waits for a player to press a single key, or press enter, to acknowledge and
|
||||
continue processing.
|
||||
|
||||
This is basically "press any key to continue..." territory.
|
||||
"""
|
||||
|
||||
def act(self, game: "Game"):
|
||||
game.display.wait_for_ack()
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class TeleportAction(Action):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user