squirrel-battle/squirrelbattle/display/logsdisplay.py

18 lines
563 B
Python

from squirrelbattle.display.display import Display
from squirrelbattle.interfaces import Logs
class LogsDisplay(Display):
def __init__(self, *args) -> None:
super().__init__(*args)
self.pad = self.newpad(self.rows, self.cols)
def update_logs(self, logs: Logs) -> None:
self.logs = logs
def display(self) -> None:
messages = self.logs.messages[-self.height:].reverse()
for i, y in enumerate(range(self.y + self.height - 1, self.y - 1, - 1)):
self.pad.addstr(y, self.x, messages[i][:self.width])