Selections should work
This commit is contained in:
parent
4055c92353
commit
43aad028d7
1 changed files with 9 additions and 1 deletions
10
loader.py
10
loader.py
|
@ -11,10 +11,12 @@ class Game:
|
||||||
self.nodes.update({k:game[k]})
|
self.nodes.update({k:game[k]})
|
||||||
|
|
||||||
def make_selection(self,selection):
|
def make_selection(self,selection):
|
||||||
if(selection >= len(self.nodes[self.current][selection]) or selection < 0):
|
if(selection is not int or selection >= len(self.nodes[self.current][selection]) or selection < 0):
|
||||||
print("Invalid selection")
|
print("Invalid selection")
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
self.current = self.nodes[self.current][selection]
|
self.current = self.nodes[self.current][selection]
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def printme(self):
|
def printme(self):
|
||||||
|
@ -28,6 +30,12 @@ class Game:
|
||||||
ostring+=f"{i} - {self.nodes[option]['description']}\n"
|
ostring+=f"{i} - {self.nodes[option]['description']}\n"
|
||||||
print(ostring)
|
print(ostring)
|
||||||
sel = input("Make a selection (number): ")
|
sel = input("Make a selection (number): ")
|
||||||
|
isWrong = self.make_selection(sel)
|
||||||
|
while isWrong == False:
|
||||||
|
sel = input("Make a selection (number): ")
|
||||||
|
isWrong = self.make_selection(sel)
|
||||||
|
self.printme()
|
||||||
|
|
||||||
|
|
||||||
def load(file_path):
|
def load(file_path):
|
||||||
'''Loads the game from a YAML file to a Game class'''
|
'''Loads the game from a YAML file to a Game class'''
|
||||||
|
|
Reference in a new issue