From ccd2e04d0ef824e6bf48c70457d9bb4f8f303ae3 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 15 May 2022 16:18:42 -0700 Subject: [PATCH] Doc strings in Messages module --- erynrl/messages.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/erynrl/messages.py b/erynrl/messages.py index 9a59fde..9678473 100644 --- a/erynrl/messages.py +++ b/erynrl/messages.py @@ -8,6 +8,18 @@ import tcod from .geometry import Rect class Message: + '''A message in the message log + + Attributes + ---------- + text : str + The text of the message + foreground : Tuple[int, int, int] + The foreground color to render the message with + count : int + The number of times this message has stacked + ''' + def __init__(self, text: str, fg: Optional[Tuple[int, int, int]] = None): self.text = text self.foreground = fg @@ -53,10 +65,12 @@ class MessageLog: self.messages.append(Message(text, fg)) def render_to_console(self, console: tcod.console.Console, rect: Rect): + '''Render this message log to the given console in the given rect''' self.render_messages(console, rect, self.messages) @staticmethod def render_messages(console: tcod.console.Console, rect: Rect, messages: Reversible[Message]): + '''Render a list of messages to the console in the given rect''' y_offset = min(rect.size.height, len(messages)) for message in reversed(messages): @@ -69,4 +83,4 @@ class MessageLog: break if y_offset < 0: - break \ No newline at end of file + break