Fix up all the runtime errors caused by the previous refactoring

This commit is contained in:
Eryn Wells 2022-05-01 09:51:22 -07:00
parent f1b95a697e
commit a54828c7fb
4 changed files with 40 additions and 20 deletions

View file

@ -8,10 +8,20 @@ from typing import Optional
class Entity:
'''A single-tile drawable entity with a symbol and position.'''
def __init__(self, symbol: str, *, position: Optional[Point] = None, color: Optional[tcod.Color] = None):
def __init__(self, symbol: str, *,
position: Optional[Point] = None,
fg: Optional[tcod.Color] = None,
bg: Optional[tcod.Color] = None):
self.position = position if position else Point()
self.color = color if color else tcod.white
self.foreground = fg if fg else tcod.white
self.background = bg
self.symbol = symbol
def print_to_console(self, console: tcod.Console) -> None:
console.print(x=self.__x, y=self.__y, string=self.__symbol, fg=self.__color)
console.print(x=self.position.x, y=self.position.y, string=self.symbol, fg=self.foreground, bg=self.background)
def __str__(self):
return f'{self.symbol}[{self.position}]'
def __repr__(self):
return f'{self.__class__.__name__}({self.symbol}, position={self.position}, fg={self.foreground}, bg={self.background})'