{
  name: "Hocus Pocus",
  rating: 4,
  num: -1017,
  flags: {},

  onSwitchIn(pokemon) {
    if (this.turn === 0) return;
    if (pokemon.abilityState.activated) return;
    if (pokemon.item) return;

    const isTrickRoom = this.field.getPseudoWeather("trickroom");

    if (isTrickRoom) {
      this.field.removePseudoWeather("trickroom");
      this.add("-fieldend", "move: Trick Room");
      this.add("-ability", pokemon, "Hocus Pocus");
      this.add("-message", `${pokemon.name} unraveled the twisted dimensions!`);
    } else {
      this.field.addPseudoWeather("trickroom");
      this.add("-fieldstart", "move: Trick Room");
      this.add("-ability", pokemon, "Hocus Pocus");
      this.add("-message", `${pokemon.name} twisted the dimensions with Hocus Pocus!`);
    }

    pokemon.abilityState.activated = true;
  },

  onModifyPriority(priority, pokemon, target, move) {
    if (move?.category === "Status" && this.field.getPseudoWeather("trickroom") && !pokemon.item) {
      return priority - 0.1;
    }
  },

  onStart(pokemon) {
    if (this.field.getPseudoWeather("trickroom") && !pokemon.item && !pokemon.abilityState.hocuspocusBoosted) {
      this.boost({ atk: 1, def: 1 }, pokemon, pokemon, null, true);
      this.add("-ability", pokemon, "Hocus Pocus");
      pokemon.abilityState.hocuspocusBoosted = true;
    }
  },

  onEnd(pokemon) {
    if (pokemon.abilityState.hocuspocusBoosted) {
      pokemon.abilityState.hocuspocusBoosted = false;
    }
  },

  onUpdate(pokemon) {
    if (pokemon.item) {
      if (pokemon.abilityState.hocuspocusBoosted) {
        this.add("-message", `${pokemon.name}'s Hocus Pocus boost faded because it is now holding an item.`);
        pokemon.abilityState.hocuspocusBoosted = false;
      }
      return;
    }

    const trickRoomActive = this.field.getPseudoWeather("trickroom");

    if (trickRoomActive && !pokemon.abilityState.hocuspocusBoosted) {
      this.boost({ atk: 1, def: 1 }, pokemon, pokemon, null, true);
      this.add("-ability", pokemon, "Hocus Pocus");
      pokemon.abilityState.hocuspocusBoosted = true;
    }
    if (!trickRoomActive && pokemon.abilityState.hocuspocusBoosted) {
      this.add("-message", `${pokemon.name}'s Hocus Pocus boost faded as Trick Room ended.`);
      pokemon.abilityState.hocuspocusBoosted = false;
    }
  },
}
