{
  name: "Battle Bond Ice",
  rating: 4,
  num: -21002,

  flags: {
    failroleplay: 1,
    noreceiver: 1,
    noentrain: 1,
    notrace: 1,
    failskillswap: 1,
    cantsuppress: 1
  },

  onStart(pokemon) {
    if (!pokemon) return;
    if (!pokemon._bbIceBaseForm) {
      pokemon._bbIceBaseForm = pokemon.species && pokemon.species.name ? pokemon.species.name : null;
    }
  },

  onSourceAfterFaint(length, target, source, effect) {
    if (!source || source.fainted) return;
    if (!effect || effect.effectType !== "Move") return;
    if (effect.category === "Status") return;

    const baseId = (source.baseSpecies && (source.baseSpecies.id || source.baseSpecies.baseSpecies)) || (source.species && (source.species.baseSpecies || source.species.id)) || "";
    const normBase = ("" + baseId).toLowerCase().replace(/[^a-z0-9]/g, "");
    if (normBase !== "greninjaomega") return;

    if (this.effectState.used) return;
    if (this.effectState.lastTurn === this.turn) return;

    this.effectState.used = true;
    this.effectState.lastTurn = this.turn;

    this.add("-ability", source, "Battle Bond Ice");

    const changed =
      source.formeChange("Battle-Bond-Ice", this.effect, true) ||
      source.formeChange("Greninja-Omega-Battle-Bond-Ice", this.effect, true);

    if (changed) {
      this.add("-formechange", source, "Battle-Bond-Ice", "[from] ability: Battle Bond Ice");
    }
  },

  onEnd(pokemon) {
    if (!pokemon) return;
    const base = pokemon._bbIceBaseForm;
    if (!base) return;
    if (pokemon.species && pokemon.species.name === base) return;
    pokemon.formeChange(base, this.effect);
  }
}
