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:
2021-11-20 19:38:06 -08:00
parent 4cf3608f71
commit e868d0e14f
8 changed files with 202 additions and 35 deletions

View File

@@ -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):
"""