diff --git a/dungeonbattle/display/display.py b/dungeonbattle/display/display.py index 2e15a26..fafcfeb 100644 --- a/dungeonbattle/display/display.py +++ b/dungeonbattle/display/display.py @@ -1,6 +1,7 @@ import curses -from typing import Any, Union +from typing import Any, Optional, Union +from dungeonbattle.display.texturepack import TexturePack from dungeonbattle.tests.screen import FakePad @@ -10,9 +11,9 @@ class Display: width: int height: int - def __init__(self, screen: Any, pack: Any): + def __init__(self, screen: Any, pack: Optional[TexturePack] = None): self.screen = screen - self.pack = pack + self.pack = pack or TexturePack.get_pack("ascii") def newpad(self, height: int, width: int) -> Union[FakePad, Any]: return curses.newpad(height, width) if self.screen else FakePad() diff --git a/dungeonbattle/display/statsdisplay.py b/dungeonbattle/display/statsdisplay.py index 6ec27bc..bf204dd 100644 --- a/dungeonbattle/display/statsdisplay.py +++ b/dungeonbattle/display/statsdisplay.py @@ -6,8 +6,8 @@ from dungeonbattle.entities.player import Player class StatsDisplay(Display): player: Player - def __init__(self, *args): - super().__init__(*args) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.pad = self.newpad(self.rows, self.cols) def update_player(self, p: Player) -> None: diff --git a/dungeonbattle/tests/game_test.py b/dungeonbattle/tests/game_test.py index fea99a0..c933847 100644 --- a/dungeonbattle/tests/game_test.py +++ b/dungeonbattle/tests/game_test.py @@ -1,6 +1,7 @@ import unittest from dungeonbattle.display.display import Display +from dungeonbattle.display.display_manager import DisplayManager from dungeonbattle.display.statsdisplay import StatsDisplay from dungeonbattle.game import Game, KeyValues, GameMode from dungeonbattle.menus import MainMenuValues @@ -12,11 +13,13 @@ class TestGame(unittest.TestCase): Setup game. """ self.game = Game() - self.game.new_game(None) + self.game.new_game() + display = DisplayManager(None, self.game) + self.game.display_refresh = display.refresh def test_load_game(self) -> None: self.assertRaises(NotImplementedError, Game.load_game, "game.save") - self.assertRaises(NotImplementedError, Display(None).refresh) + self.assertRaises(NotImplementedError, Display(None).display) def test_key_translation(self) -> None: """ @@ -105,6 +108,7 @@ class TestGame(unittest.TestCase): self.assertEqual(self.game.state, GameMode.MAINMENU) def test_stats_display(self) -> None: - self.game.current_display = StatsDisplay(None, self.game.player, - 42, 42) + self.game.current_display = StatsDisplay(None) + self.game.current_display.update_player(self.game.player) + self.game.current_display.resize(0, 0, 42, 42) self.game.current_display.refresh()