本文整理汇总了Python中UI.inputNumber方法的典型用法代码示例。如果您正苦于以下问题:Python UI.inputNumber方法的具体用法?Python UI.inputNumber怎么用?Python UI.inputNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI
的用法示例。
在下文中一共展示了UI.inputNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: genOpponent
# 需要导入模块: import UI [as 别名]
# 或者: from UI import inputNumber [as 别名]
def genOpponent(MaxLevel):
"""Generates a monster with level chosen by user, max MaxLevel"""
#If Player has won over a level 1 opponent, he's given choice of other
#opponents up to his level (1..maximal level won + 1)
if MaxLevel != 1:
while 1:
UI.printNow("Select monster level to battle (1.. " + str(MaxLevel) + " ): ")
choice = UI.inputNumber()
if (choice < 1) or (choice > MaxLevel):
print("Invalid choice!")
else: break
else: choice = 1
#Generate a random monster of a given level
Monster = Character.CharClass()
Monster.generate(choice)
Monster.Name = "Level " + str(Monster.Level) + " Monster"
return Monster
示例2: doInventory
# 需要导入模块: import UI [as 别名]
# 或者: from UI import inputNumber [as 别名]
def doInventory(self, MyCell):
"""Shows character inventory menu"""
while 1:
ChosenItem = self.Inventory.chooseInventoryItem("Your inventory")
if ChosenItem == None:
break
InventoryItemMenu = UI.MenuClass()
InventoryItemMenu.Title = ChosenItem.Base.Name
if ChosenItem.Base.CanEquip:
if ChosenItem.Equipped:
InventoryItemMenu.addItem("Unequip", lambda: self.unequip(ChosenItem.Base), "U", 1)
else:
InventoryItemMenu.addItem("Equip", lambda: self.equip(ChosenItem.Base), "E", 1)
InventoryItemMenu.addItem("Drop", UI.emptyCallback, "D")
Choice = InventoryItemMenu.doMenu()
if InventoryItemMenu.Returned:
continue
if InventoryItemMenu.Items[Choice].Text == "Drop":
if ChosenItem.Count == 1:
self.removeItem((ChosenItem.Base))
MyCell.Items.append(ChosenItem.Base)
print(ChosenItem.Base.Name, "dropped")
break
while 1:
ToDrop = UI.inputNumber("Enter count of items to drop (max " + str(ChosenItem.Count) + "): ")
if ToDrop in range(ChosenItem.Count + 1):
break
print("Invalid choice")
self.removeItem(ChosenItem.Base, ToDrop)
print(ChosenItem.Base.Name, "x", ToDrop, "dropped")
MyCell.Items.append(ChosenItem.Base)
UI.waitForKey()