squirrel-battle/dungeonbattle/menus.py

35 lines
676 B
Python

from enum import Enum, auto
from typing import Any
class Menu:
values: list
def __init__(self):
self.position = 0
def go_up(self) -> None:
self.position = max(0, self.position - 1)
def go_down(self) -> None:
self.position = min(len(self.values) - 1, self.position + 1)
def validate(self) -> Any:
return self.values[self.position]
class MainMenuValues(Enum):
START = 'Jouer'
SETTINGS = 'Paramètres'
EXIT = 'Quitter'
class MainMenu(Menu):
values = [e for e in MainMenuValues]
class ArbitraryMenu(Menu):
def __init__(self, values: list):
super().__init__()
self.values = values