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


Python Inventory.equip_main_hand方法代码示例

本文整理汇总了Python中inventory.Inventory.equip_main_hand方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.equip_main_hand方法的具体用法?Python Inventory.equip_main_hand怎么用?Python Inventory.equip_main_hand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inventory.Inventory的用法示例。


在下文中一共展示了Inventory.equip_main_hand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Game

# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import equip_main_hand [as 别名]

#.........这里部分代码省略.........
                        pickupMssg = ''
                        toAppend = toAppend[1:]
                    pickupMssg += toAppend
                
                # If Space still in inventory, display "Add to inventory"
                if self.inventory.has_inventory_space():
                    validOptions.append('8')
                    toAppend = ' [8: Add to inventory]'
                    if self._isMssgTooLong(pickupMssg, toAppend):
                        self.messages.append(pickupMssg)
                        pickupMssg = ''
                        toAppend = toAppend[1:]
                    pickupMssg += toAppend
                
                # Always allowed to ignore items
                validOptions.append('9')
                toAppend = ' [9: Ignore]'
                if self._isMssgTooLong(pickupMssg, toAppend):
                    self.messages.append(pickupMssg)
                    pickupMssg = ''
                    toAppend = toAppend[1:]
                pickupMssg += toAppend

                # self.messages.append("[1: Pick up with MH] [2: Pick up with OH] [3: Don't pick up]")
                self.messages.append(pickupMssg)
                self.printScreen()
                y_or_n = self.user.__move__(self.getDataForAI("ITEM"))
                while y_or_n not in validOptions:
                    self.messages.append("Please enter " + '/'.join(validOptions))
                    self.printScreen()
                    y_or_n = self.user.__move__(self.getDataForAI("ITEM"))
                if y_or_n == '1':
                    # pick up item
                    self.inventory.equip_main_hand(self.current_enemy.item)
                    self.printScreen()
                    if not USE_AI: 
                        time.sleep(2)
                elif y_or_n == '2':
                    self.inventory.equip_offhand(self.current_enemy.item)
                    self.printScreen()
                    if not USE_AI: 
                        time.sleep(2)
                elif y_or_n == '8':
                    self.inventory.add_to_pack(self.current_enemy.item)
                elif y_or_n != '9':
                    # Items in inventory are keys 3-7
                    self.inventory.replace_item(int(y_or_n) - 3, self.current_enemy.item)


        elif self.player.isDead():
            self.printScreen()
            if not USE_AI: time.sleep(2)
            raise Defeat("You have been defeated.")

    def checkEvent(self):
        pass
        random.seed()

        event_value = random.uniform(0, 1)
        encounter_chance = 0.03 + BASE_ENEMY_ENCOUNTER_CHANCE * self.danger 
        
        if self.player.hiding: 
            h_event_value = random.uniform(0, 1)
            h_encounter_chance = 0.03 + BASE_HIDE_ENCOUNTER_CHANCE * self.hide_danger 
            if h_event_value <= h_encounter_chance:
                encounter_chance = 1
开发者ID:gaohongl,项目名称:183siege-reach,代码行数:70,代码来源:game.py


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