poke-env icon indicating copy to clipboard operation
poke-env copied to clipboard

Tracking ally tera types

Open SeanCole02 opened this issue 10 months ago • 3 comments

Ally tera types always return None unless the ally has terad, is there a latent state where their tera type can be accessed before tera?

SeanCole02 avatar Feb 06 '25 09:02 SeanCole02

You can get this from your teambuilder, but in randoms it doesn't work, as you've said.

The best bypass: battle.can_tera returns your active Pokemon's Tera Type.

areibman avatar May 10 '25 19:05 areibman

Is this because tera type is determined upon viewing a pokemon on the showdown server, or a problem with poke-env?

problemsolver19 avatar May 21 '25 20:05 problemsolver19

I have a hacky solution just add this to update_from_request function in pokemon.py

def update_from_request(self, request_pokemon: Dict[str, Any]):
    self._active = request_pokemon["active"]

    if request_pokemon == self._last_request:
        return

    if "ability" in request_pokemon:
        self.ability = request_pokemon["ability"]
    elif "baseAbility" in request_pokemon:
        self.ability = request_pokemon["baseAbility"]

    self._last_request = request_pokemon

    condition = request_pokemon["condition"]
    self.set_hp_status(condition, store=True)

    self._name = request_pokemon["ident"][4:]
    self._item = request_pokemon["item"]

    # ADD START HERE ---------------------------------------------------------------------
    if self._terastallized_type is None:
        try:
            self._terastallized_type = PokemonType.from_name(
                request_pokemon["teraType"]
            )
        except KeyError:
            pass
    # ADD END HERE ---------------------------------------------------------------------

    details = request_pokemon["details"]
    self._update_from_details(details)

    for move in request_pokemon["moves"]:
        self._add_move(move)

    if len(self._moves) > 4:
        moves_to_keep = {
            Move.retrieve_id(move_id) for move_id in request_pokemon["moves"]
        }
        self._moves = {
            move_id: move
            for move_id, move in self._moves.items()
            if move_id in moves_to_keep
        }

    if "stats" in request_pokemon:
        for stat in request_pokemon["stats"]:
            self._stats[stat] = request_pokemon["stats"][stat]

problemsolver19 avatar May 21 '25 20:05 problemsolver19