squirrel-battle/dungeonbattle/display/display.py

41 lines
947 B
Python

import curses
from typing import Any, Union
from dungeonbattle.tests.screen import FakePad
class Display:
x: int
y: int
width: int
height: int
def __init__(self, screen: Any, pack: Any):
self.screen = screen
self.pack = pack
def newpad(self, height: int, width: int) -> Union[FakePad, Any]:
return curses.newpad(height, width) if self.screen else FakePad()
def resize(self, y: int, x: int, height: int, width: int) -> None:
self.x = x
self.y = y
self.width = width
self.height = height
def refresh(self, *args) -> None:
if len(args) == 4:
self.resize(*args)
self.display()
def display(self) -> None:
raise NotImplementedError
@property
def rows(self) -> int:
return curses.LINES if self.screen else 42
@property
def cols(self) -> int:
return curses.COLS if self.screen else 42