Modified main menu to be able to override the current game with a new one
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user