First pass on the logs
The newly-added logs manage a list of messages. Entities do register a message to it when hitting each other. Display is created, but not yet added to the layout actually displayed.
This commit is contained in:
17
squirrelbattle/display/logsdisplay.py
Normal file
17
squirrelbattle/display/logsdisplay.py
Normal file
@ -0,0 +1,17 @@
|
||||
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])
|
Reference in New Issue
Block a user