當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。