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


Python Inventory.check_durability方法代码示例

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


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

示例1: Game

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

#.........这里部分代码省略.........
                self.printScreen()
                return True
            else:
                self.messages.append("You don't have any Potions!")
                return False

        # SHIELDING
        elif decisions[0] == 'c':
            # is there a shield equipped?
            shields = self.inventory.get_equipped_defense()
            if shields:
                self.playerStance = "DEFENSIVE"
                self.messages.append("You raised your shield!")
                return True
            else:
                self.messages.append(
                    "You try to raise your shield, only to discover you're not holding one. The {0} looks confused.".format(
                        self.current_enemy.name))
                return True

        # BAD COMMAND
        else:
            assert(False and "Invalid command specified")

    def enemyTurn(self):
        # enemy will of course hit back
        damage = int((float(self.current_enemy.item.strength) * ENEMY_DAMAGE_CONSTANT) * self.current_enemy.next_attack)
        # player is shielding
        shield_level = 0
        if self.playerStance == "DEFENSIVE":
            # find the shields the player has
            #shield_level = self.inventory.get_equipped_defense().strength
            shield_level = self.inventory.get_defense()
            self.inventory.check_durability()
        if self.playerStance == "DEFENSIVE" and self.seerdata.current_block:
            self.messages.append("You successfully blocked the enemy attack!")
        else:
            self.player.damage(damage)
            damageType = "hit" if not isinstance(
                self.current_enemy.item,
                RangedWeapon) else "shoot"
            self.messages.append(
                "The {0} {2}s you for {1} damage!".format(
                    self.current_enemy.name,
                    damage,
                    damageType))
        return True

        # escape results

    def _isMssgTooLong(self, currentMessage, messageToAppend):
        return len(currentMessage + messageToAppend) > 159


    def runEvent(self):


        from ai import USE_AI

        self.seerdata.generate_encounter(self.inventory.get_defense(), self.escape_chance, self.items_dropped, is_dorf=("DORF" in self.current_enemy.image))
        # Combat loop
        isPlayerTurn = True
        self.messages = []
        if self.player.hiding: self.messages.append("A {0} found your hiding place!".format(self.current_enemy.name))
        else: self.messages.append("A {0} appeared!".format(self.current_enemy.name))
        self.playerStance = "NEUTRAL"
开发者ID:gaohongl,项目名称:183siege-reach,代码行数:70,代码来源:game.py


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