Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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")