implemented Scoundrel game
This commit is contained in:
+15
-3
@@ -16,6 +16,20 @@ _idx_map = {
|
||||
'0': 9, 'p': 9
|
||||
}
|
||||
|
||||
def confirm(msg, yes='y', no='n', alt_prompt=None):
|
||||
prompt=f' ({yes}/{no}) '
|
||||
yes = yes.lower()
|
||||
no = no.lower()
|
||||
if alt_prompt is not None:
|
||||
prompt = alt_prompt
|
||||
final_prompt = msg + prompt
|
||||
while True:
|
||||
choice = input(final_prompt).strip().lower()
|
||||
if choice == yes:
|
||||
return True
|
||||
elif choice == no:
|
||||
return False
|
||||
|
||||
def menu(choices, max_size = 10):
|
||||
"""
|
||||
Presents a menu of choices and prompts for numeric or
|
||||
@@ -49,6 +63,4 @@ def menu(choices, max_size = 10):
|
||||
return menu(choices)
|
||||
else:
|
||||
print('Invalid choice!')
|
||||
return menu(choices)
|
||||
|
||||
|
||||
return menu(choices)
|
||||
|
||||
Reference in New Issue
Block a user