Beispiel #1
0
 def set_spread(self, nature, evs):
     evs = [int(e) for e in evs.split(',')]
     hp_percent = self.hp / self.max_hp
     self.stats = calculate_stats(self.base_stats, self.level, evs=evs, nature=nature)
     self.nature = nature
     self.evs = evs
     self.max_hp = self.stats.pop(constants.HITPOINTS)
     self.hp = round(self.max_hp * hp_percent)
Beispiel #2
0
def switch_or_drag(battle, split_msg):
    if is_opponent(battle, split_msg):
        side = battle.opponent
        logger.debug("Opponent has switched - clearing the last used move")
    else:
        side = battle.user
        side.side_conditions[constants.TOXIC_COUNT] = 0

    if side.active is not None:
        # set the pkmn's types back to their original value if the types were changed
        if constants.TYPECHANGE in side.active.volatile_statuses:
            original_types = pokedex[side.active.name][constants.TYPES]
            logger.debug(
                "{} had it's type changed - changing its types back to {}".
                format(side.active.name, original_types))
            side.active.types = original_types

        # if the target was transformed, reset its transformed attributes
        if constants.TRANSFORM in side.active.volatile_statuses:
            logger.debug(
                "{} was transformed. Resetting its transformed attributes".
                format(side.active.name))
            side.active.stats = calculate_stats(side.active.base_stats,
                                                side.active.level)
            side.active.ability = None
            side.active.moves = []
            side.active.types = pokedex[side.active.name][constants.TYPES]

        # reset the boost of the pokemon being replaced
        side.active.boosts.clear()

        # reset the volatile statuses of the pokemon being replaced
        side.active.volatile_statuses.clear()

        # reset toxic count for this side
        side.side_conditions[constants.TOXIC_COUNT] = 0

    # check if the pokemon exists in the reserves
    # if it does not, then the newly-created pokemon is used (for formats without team preview)
    pkmn = Pokemon.from_switch_string(split_msg[3])
    pkmn = find_pokemon_in_reserves(pkmn.name, side.reserve)

    if pkmn is None:
        pkmn = Pokemon.from_switch_string(split_msg[3])
    else:
        side.reserve.remove(pkmn)

    side.last_used_move = LastUsedMove(pokemon_name=None,
                                       move='switch {}'.format(pkmn.name),
                                       turn=battle.turn)

    # pkmn != active is a special edge-case for Zoroark
    if side.active is not None and pkmn != side.active:
        side.reserve.append(side.active)

    side.active = pkmn
    if side.active.name in constants.UNKOWN_POKEMON_FORMES:
        side.active = Pokemon.from_switch_string(split_msg[3])
Beispiel #3
0
    def __init__(self,
                 name: str,
                 level: int,
                 nature="serious",
                 evs=(85, ) * 6):
        self.name = normalize_name(name)
        self.base_name = self.name
        self.level = level
        self.nature = nature
        self.evs = evs
        self.speed_range = StatRange(min=0, max=float("inf"))

        try:
            self.base_stats = pokedex[self.name][constants.BASESTATS]
        except KeyError:
            logger.info("Could not pokedex entry for {}".format(self.name))
            self.name = [k for k in pokedex if self.name.startswith(k)][0]
            logger.info("Using {} instead".format(self.name))
            self.base_stats = pokedex[self.name][constants.BASESTATS]

        self.stats = calculate_stats(self.base_stats,
                                     self.level,
                                     nature=nature,
                                     evs=evs)

        self.max_hp = self.stats.pop(constants.HITPOINTS)
        self.hp = self.max_hp
        if self.name == 'shedinja':
            self.max_hp = 1
            self.hp = 1

        self.ability = None
        self.types = pokedex[self.name][constants.TYPES]
        self.item = constants.UNKNOWN_ITEM

        self.fainted = False
        self.moves = []
        self.status = None
        self.volatile_statuses = []
        self.boosts = defaultdict(lambda: 0)
        self.can_mega_evo = False
        self.can_ultra_burst = False
        self.can_dynamax = False
        self.is_mega = False
        self.can_have_assaultvest = True
        self.can_have_choice_item = True
        self.can_not_have_band = False
        self.can_not_have_specs = False
        self.can_have_life_orb = True
        self.can_have_heavydutyboots = True
Beispiel #4
0
def stancechange(state, attacking_side, attacking_move, attacking_pokemon, defending_pokemon):
    if attacking_pokemon.id in ['aegislash', 'aegislashblade']:
        if attacking_move[constants.CATEGORY] in constants.DAMAGING_CATEGORIES:
            change_stats_into = 'aegislashblade'
        elif attacking_move[constants.ID] == 'kingsshield':
            change_stats_into = 'aegislash'
        else:
            return None

        new_stats = calculate_stats(
            pokedex[change_stats_into][constants.BASESTATS],
            attacking_pokemon.level,
            nature=attacking_pokemon.nature,
            evs=attacking_pokemon.evs
        )

        return [
            (
                constants.MUTATOR_CHANGE_STATS,
                attacking_side,
                (
                    attacking_pokemon.maxhp,
                    new_stats[constants.ATTACK],
                    new_stats[constants.DEFENSE],
                    new_stats[constants.SPECIAL_ATTACK],
                    new_stats[constants.SPECIAL_DEFENSE],
                    attacking_pokemon.speed
                ),
                (
                    attacking_pokemon.hp,
                    attacking_pokemon.attack,
                    attacking_pokemon.defense,
                    attacking_pokemon.special_attack,
                    attacking_pokemon.special_defense,
                    attacking_pokemon.speed
                )
            )

        ]
    return None