Changed the behaviour of DisplayManager to match previous commit and fixed tests and bootstrap accordingly
This commit is contained in:
parent
b0292c05b2
commit
92ab9ae075
@ -11,5 +11,5 @@ class Bootstrap:
|
||||
game = Game()
|
||||
game.new_game()
|
||||
display = DisplayManager(term_manager.screen, game)
|
||||
game.display_refresh = display.refresh
|
||||
game.display_actions = display.handle_display_actions
|
||||
game.run(term_manager.screen)
|
||||
|
@ -5,6 +5,7 @@ from dungeonbattle.display.menudisplay import MenuDisplay, MainMenuDisplay
|
||||
from dungeonbattle.display.texturepack import TexturePack
|
||||
from typing import Any
|
||||
from dungeonbattle.game import Game, GameMode
|
||||
from dungeonbattle.enums import DisplayAction
|
||||
|
||||
|
||||
class DisplayManager:
|
||||
@ -23,6 +24,12 @@ class DisplayManager:
|
||||
self.update_game_components()
|
||||
self.settingsmenudisplay.update_menu(self.game.settings_menu)
|
||||
|
||||
def handle_display_action(self, action:DisplayAction) -> None:
|
||||
if action == DisplayAction.REFRESH:
|
||||
self.refresh()
|
||||
elif action == DisplayAction.UPDATE:
|
||||
self.update_game_components()
|
||||
|
||||
def update_game_components(self) -> None:
|
||||
for d in self.displays:
|
||||
d.pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK)
|
||||
|
@ -18,7 +18,7 @@ class TestGame(unittest.TestCase):
|
||||
self.game = Game()
|
||||
self.game.new_game()
|
||||
display = DisplayManager(None, self.game)
|
||||
self.game.display_refresh = display.refresh
|
||||
self.game.display_actions = display.handle_display_action
|
||||
|
||||
def test_load_game(self) -> None:
|
||||
self.assertRaises(NotImplementedError, Game.load_game, "game.save")
|
||||
|
Loading…
Reference in New Issue
Block a user