Modified main menu to be able to override the current game with a new one

This commit is contained in:
Charles Peyrat 2020-11-13 18:08:48 +01:00
parent eca6b9af1f
commit ae493337ed
3 changed files with 6 additions and 3 deletions

View File

@ -1,11 +1,9 @@
#!/usr/bin/env python
from dungeonbattle.entities.player import Player
from dungeonbattle.interfaces import Map
from .display import Display
class MapDisplay(Display):
player: Player
def __init__(self, *args):
super().__init__(*args)

View File

@ -12,6 +12,7 @@ from typing import Callable
class Game:
map: Map
player: Player
# display_actions is a display interface set by the bootstrapper
display_actions: Callable[[DisplayActions], None]
def __init__(self) -> None:

View File

@ -24,7 +24,8 @@ class Menu:
class MainMenuValues(Enum):
START = 'Jouer'
START = 'Nouvelle partie'
RESUME = 'Continuer'
SETTINGS = 'Paramètres'
EXIT = 'Quitter'
@ -46,6 +47,9 @@ class MainMenu(Menu):
if key == KeyValues.ENTER:
option = self.validate()
if option == MainMenuValues.START:
game.new_game()
game.state = GameMode.PLAY
elif option == MainMenuValues.RESUME:
game.state = GameMode.PLAY
elif option == MainMenuValues.SETTINGS:
game.state = GameMode.SETTINGS