{
  name: "Tide Sigil",
  rating: 4,
  num: -21004,
  flags: {},

  onSwitchIn(pokemon) {
    if (pokemon.abilityState.used) return;

    const foes = pokemon.side.foe.active.filter(x => x && !x.fainted);
    if (!foes.length) return;

    const encoreMove = this.dex.moves.get("encore");
    let success = false;

    for (const foe of foes) {
      if (foe.volatiles["encore"]) continue;
      if (!foe.lastMove || foe.lastMove.isZ || foe.lastMove.isMax || foe.lastMove.id === "struggle") continue;

      let hasPP = true;
      for (const slot of foe.moveSlots) {
        if (slot.id === foe.lastMove.id) {
          if (!slot.pp) hasPP = false;
          break;
        }
      }
      if (!hasPP) continue;

      if (foe.addVolatile("encore", pokemon, encoreMove)) {
        success = true;
      }
    }

    if (!success) return;

    this.add("-ability", pokemon, "Tide Sigil");
    this.boost({ spe: 1 }, pokemon);
    pokemon.abilityState.used = true;
  }
}
