Generic menu implementation

This commit is contained in:
Nicolas Margulies 2020-11-06 16:20:07 +01:00
parent bfce9487c5
commit 60ca00b8fa

14
dungeonbattle/menus.py Normal file
View File

@ -0,0 +1,14 @@
class Menu:
def __init__(self, values:list):
self.values = values
self.position = 0
def go_up(self):
self.position = max(0, self.position -1)
def go_down(self):
self.position = min(len(self.values)-1, self.position +1)
def validate(self):
return self.values[self.position]