当前位置: 首页>>代码示例>>Python>>正文


Python UI.inputNumber方法代码示例

本文整理汇总了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
开发者ID:mildbyte,项目名称:console-massacre,代码行数:21,代码来源:BattleField.py

示例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()
开发者ID:mildbyte,项目名称:console-massacre,代码行数:40,代码来源:Character.py


注:本文中的UI.inputNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。