Beispiel #1
0
def switch_or_drag(battle, split_msg):
    """The opponent's pokemon has changed
       If the new one hasn't been seen, create it"""
    if is_opponent(battle, split_msg):
        battle.opponent.side_conditions[constants.TOXIC_COUNT] = 0

        if battle.opponent.active is not None:
            # reset the boost of the pokemon being replaced
            battle.opponent.active.boosts.clear()

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

        # 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, battle.opponent.reserve)

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

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

        battle.opponent.active = pkmn
        if battle.opponent.active.name in constants.UNKOWN_POKEMON_FORMES:
            battle.opponent.active = Pokemon.from_switch_string(split_msg[3])

    else:
        battle.user.side_conditions[constants.TOXIC_COUNT] = 0
        battle.user.active.boosts.clear()
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 form_change(battle, split_msg):
    if is_opponent(battle, split_msg):
        side = battle.opponent
    else:
        side = battle.user

    base_name = side.active.base_name
    hp_percent = float(side.active.hp) / side.active.max_hp
    previous_moves = side.active.moves
    previous_boosts = side.active.boosts
    previous_status = side.active.status
    previous_item = side.active.item

    new_pokemon = Pokemon.from_switch_string(split_msg[3])
    new_pokemon.moves = previous_moves
    if new_pokemon in side.reserve:
        side.reserve.remove(new_pokemon)

    side.active = new_pokemon
    side.active.hp = hp_percent * side.active.max_hp
    side.active.boosts = previous_boosts
    side.active.status = previous_status
    side.active.item = previous_item

    if side.active.name != "zoroark":
        side.active.base_name = base_name
Beispiel #4
0
def switch_or_drag(battle, split_msg):
    """The opponent's pokemon has changed
       If the new one hasn't been seen, create it"""
    if is_opponent(battle, split_msg):
        logger.debug("Opponent has switched - clearing the last used move")
        battle.opponent.last_used_move = LastUsedMove(pokemon_name=None,
                                                      move='switch')

        battle.opponent.side_conditions[constants.TOXIC_COUNT] = 0

        if battle.opponent.active is not None:
            # reset the boost of the pokemon being replaced
            battle.opponent.active.boosts.clear()

            if constants.DYNAMAX in battle.opponent.active.volatile_statuses:
                battle.opponent.active.hp /= 2
                battle.opponent.active.max_hp /= 2
                logger.debug(
                    "Opponent ended dynamax - halving their HP to {}/{}".
                    format(battle.opponent.active.hp,
                           battle.opponent.active.max_hp))

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

        # 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, battle.opponent.reserve)

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

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

        battle.opponent.active = pkmn
        if battle.opponent.active.name in constants.UNKOWN_POKEMON_FORMES:
            battle.opponent.active = Pokemon.from_switch_string(split_msg[3])

    else:
        battle.user.side_conditions[constants.TOXIC_COUNT] = 0
        battle.user.active.boosts.clear()
Beispiel #5
0
def form_change(battle, split_msg):
    if is_opponent(battle, split_msg):
        base_name = battle.opponent.active.base_name
        hp_percent = float(
            battle.opponent.active.hp) / battle.opponent.active.max_hp
        moves = battle.opponent.active.moves
        boosts = battle.opponent.active.boosts
        status = battle.opponent.active.status

        new_pokemon = Pokemon.from_switch_string(split_msg[3])
        new_pokemon.moves = moves
        if new_pokemon in battle.opponent.reserve:
            battle.opponent.reserve.remove(new_pokemon)

        battle.opponent.active = new_pokemon
        battle.opponent.active.hp = hp_percent * battle.opponent.active.max_hp
        battle.opponent.active.boosts = boosts
        battle.opponent.active.status = status

        if battle.opponent.active.name != "zoroark":
            battle.opponent.active.base_name = base_name