cleaned the arguments

This commit is contained in:
eichhornchen 2020-11-09 01:11:13 +01:00
parent e9c8640159
commit 8d5d9d38ff
1 changed files with 11 additions and 7 deletions

View File

@ -7,12 +7,15 @@ from dungeonbattle.entities.player import Player
from dungeonbattle.interfaces import Map from dungeonbattle.interfaces import Map
class MapDisplay(Display): class MapDisplay:
def __init__(self, screen: Any, m: Map, player: Player, pack: TexturePack): self.map: Map
super().__init__(screen) self.player: Player
def __init__(self, screen: Any, pack: TexturePack, height : int, width : int):
self.screen = screen
self.height = height
self.width = width
self.pack = pack self.pack = pack
self.map = m
self.player = player
self.pad = self.newpad(m.height, m.width + 1) self.pad = self.newpad(m.height, m.width + 1)
def update_pad(self) -> None: def update_pad(self) -> None:
@ -20,7 +23,9 @@ class MapDisplay(Display):
for e in self.map.entities: for e in self.map.entities:
self.pad.addstr(e.y, e.x, self.pack.PLAYER) self.pad.addstr(e.y, e.x, self.pack.PLAYER)
def display(self, y: int, x: int) -> None: def display(self, m : Map, p : Player y: int, x: int) -> None:
self.map = m
self.player = p
deltay, deltax = (self.height // 2) + 1, (self.width // 2) + 1 deltay, deltax = (self.height // 2) + 1, (self.width // 2) + 1
pminrow, pmincol = y - deltay, x - deltax pminrow, pmincol = y - deltay, x - deltax
sminrow, smincol = max(-pminrow, 0), max(-pmincol, 0) sminrow, smincol = max(-pminrow, 0), max(-pmincol, 0)
@ -36,5 +41,4 @@ class MapDisplay(Display):
self.pad.refresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) self.pad.refresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol)
def refresh(self) -> None: def refresh(self) -> None:
self.ensure_resized(self.pad)
return self.display(self.player.y, self.player.x) return self.display(self.player.y, self.player.x)