本文整理汇总了Python中menu.Menu.choose方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.choose方法的具体用法?Python Menu.choose怎么用?Python Menu.choose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.choose方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: strike_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def strike_menu():
roll_cube(player)
roll_cube(opponent)
if player.roll > opponent.roll:
print(player)
print(opponent)
print('You hits monster')
opponent.hp -= 2
print(player)
print(opponent)
else:
print(player)
print(opponent)
print('Monster hits you')
player.hp -= 2
print(player)
print(opponent)
name_items = Menu([
MenuItem(1, 'Try your luck', try_your_luck_menu),
MenuItem(2, 'Retreat', strike_menu),
MenuItem(3, 'Quit', quit),
])
name_items.print_menu()
name_items.choose()
示例2: sub_m
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def sub_m():
main_items = Menu([
MenuItem(1, 'sub item1', new_game),
MenuItem(2, 'sub item1', load),
MenuItem(0, 'sub item1', save_and_exit)
])
main_items.print_menu()
main_items.choose()
示例3: main
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def main():
main_items = Menu([
MenuItem(1, 'New Game', name_m),
MenuItem(2, 'Load Game', load),
MenuItem(3, 'Save and Exit', save_and_exit)
])
main_items.print_menu()
main_items.choose()
示例4: potion_select_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def potion_select_menu():
name_items = Menu([
MenuItem(1, 'Potion of Health', lambda: potion_menu(1)),
MenuItem(2, 'Potion of Dexterity', lambda: potion_menu(2)),
MenuItem(3, 'Potion of Luck', lambda: potion_menu(3)),
])
name_items.print_menu()
name_items.choose()
示例5: roll_stat_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def roll_stat_menu():
roll_stat(player)
name_items = Menu([
MenuItem(1, 'reroll_stat', roll_stat_menu),
MenuItem(2, 'Continue', potion_select_menu),
MenuItem(3, 'Save', save),
MenuItem(4, 'Quit', save)
])
name_items.print_menu()
name_items.choose()
示例6: name_m
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def name_m():
new_game()
name_items = Menu([
MenuItem(1, 'Reenter name', name_m),
MenuItem(2, 'Continue', roll_stat_menu),
MenuItem(3, 'Save', save),
MenuItem(4, 'Quit', quit)
])
name_items.print_menu()
name_items.choose()
示例7: fight_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def fight_menu():
print("Test your Sword in a test fight")
print(player)
print(opponent)
name_items = Menu([
MenuItem(1, 'Strike', strike_menu),
MenuItem(2, 'Retreat', save),
MenuItem(3, 'Quit', quit),
])
name_items.print_menu()
name_items.choose()
示例8: begin_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def begin_menu():
print(player)
roll_stat(opponent)
name_items = Menu([
MenuItem(1, 'Begin', fight_menu),
MenuItem(2, 'Save', save),
MenuItem(3, 'Quit', quit),
])
name_items.print_menu()
name_items.choose()
示例9: potion_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def potion_menu(selection):
print() #empty line
if selection == 1: print('choosed pitoion: Potion of Health')
elif selection == 2: print('choosed pitoion: Potion of Dexterity')
elif selection == 3: print('choosed pitoion: Potion of Luck')
else: print('else ag')
name_items = Menu([
MenuItem(1, 'Reselect the Potion', potion_select_menu),
MenuItem(2, 'Continue', begin_menu),
MenuItem(3, 'Quit', quit),
])
name_items.print_menu()
name_items.choose()
示例10: test_choose
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
def test_choose(self):
menu = Menu([
MenuItem(1, "Test", lambda : True)
])
self.assertEqual(menu.choose(1), True)
示例11: start_game
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import choose [as 别名]
from menu import Menu
from menu_item import MenuItem
def start_game():
print(ghjj)
def load_game():
print(dskl)
main_menu = Menu([
MenuItem(1, 'Start game', start_game)
MenuItem(2, 'Load game', load_game)
])
main_menu.choose(1)