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


Python Species.isAttackable方法代码示例

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


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

示例1: is_larger_attack_option

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import isAttackable [as 别名]
    def is_larger_attack_option(self, defend_player, def_spec_index, attacker, largest_def_species):
        """
        Checks if the attacker -> def_species_index is a larger attack option than attacker -> largest_def_species
        :param defend_player: PlayerState - the defending playerState containing the defending species to compare
        :param def_spec_index: Nat - the index of the species to compare against largest_def_species
        :param attacker: Species - the attacking species
        :param largest_def_species: Species - the current largest defending species to compare against
        :return: One of: - Tuple(Nat, Species) - the new larger option found
                         - False (if not a larger option)
        """
        lNeighbor, rNeighbor = defend_player.get_neighbors(def_spec_index)

        def_species = defend_player.species[def_spec_index]

        if Species.isAttackable(def_species, attacker, lNeighbor, rNeighbor) and def_species.isLarger(largest_def_species):
            return def_spec_index, defend_player.species[def_spec_index]
        return False
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:19,代码来源:player.py

示例2: feed_result_carnivore

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import isAttackable [as 别名]
    def feed_result_carnivore(self, attSpecIndex, defPlayerIndex, defSpecIndex):
        """
        Effect: Attacking species will get food, decrease population if attacking horns.
                Defending species of defPlayerIndex will reduce in population if attack succeeds
                Food is taken from the wateringHole for successful attacks
                Extinction will cause extinct species owners to get cards, which are removed from this dealers hand
        :param attSpecIndex: Nat - the index of the carnivore species in the player that is attacking
        :param defPlayerIndex: Nat - the index of the player to attack
        :param defSpecIndex: Nat - the index of the species in the defending player to attack
        :return: Void
        """
        attPlayerState = self.playerStates[0]
        attSpecies = attPlayerState.get_species_at(attSpecIndex)

        defPlayerState = self.playerStates[defPlayerIndex]
        defSpecies = defPlayerState.get_species_at(defSpecIndex)

        leftSpecies = defPlayerState.getLeftNeighbor(defSpecIndex)
        rightSpecies = defPlayerState.getRightNeighbor(defSpecIndex)

        if Species.isAttackable(defSpecies, attSpecies, leftSpecies, rightSpecies):
            self.execute_attack(attSpecies, defSpecies, attPlayerState, defPlayerState, attSpecIndex, defSpecIndex)
        else:
            raise Exception("Bad Attack")
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:26,代码来源:dealer.py


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