poke-env
poke-env copied to clipboard
Tracking ally tera types
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?
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.
Is this because tera type is determined upon viewing a pokemon on the showdown server, or a problem with poke-env?
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]