Files
ages/agame/display/display.py
Alek Ratzloff e868d0e14f 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>
2021-11-20 19:38:06 -08:00

33 lines
900 B
Python

import abc
from typing import Optional
class Display(metaclass=abc.ABCMeta):
"""
Displays are an abstraction over printing things to the screen.
Use a specific implementation based on the kind of display you want to use.
"""
@abc.abstractmethod
def line(self, line: str = ""):
"Print a single line to the display."
@abc.abstractmethod
def input(self) -> str:
"Get player input."
@abc.abstractmethod
def wait_for_ack(self, prompt: Optional[str] = None):
"""
Wait for the user to press a key.
The behavior is up to the implementor. This could be something like
"press any key to continue", "press enter to continue", or "click OK to
continue". This method should block until input is acknowleged by the
user.
"""
def finish(self):
"Final cleanup code for this display."