{
  num: -130124,
  accuracy: 100,
  basePower: 85,
  category: "Physical",
  name: "Takaoni",
  pp: 10,
  priority: 0,
  flags: { contact: 1, protect: 1, mirror: 1, metronome: 1, slicing: 1 },
  onModifyMove(move, source, target) {
    move.ignoreEvasion = true;
    if (!source || !target) return;
    const sourceAir = !source.isGrounded();
    const targetAir = !target.isGrounded();
    const wins = sourceAir && !targetAir || sourceAir === targetAir && source.getStat("spe") >= target.getStat("spe");
    if (wins) move.willCrit = true;
  },
  onBasePower(basePower, source, target, move) {
    if (!source || !target) return;
    const sourceAir = !source.isGrounded();
    const targetAir = !target.isGrounded();
    source.shunsuiTakaoniBackfire = false;
    if (sourceAir && !targetAir) return this.chainModify(1.85);
    if (!sourceAir && targetAir) {
      source.shunsuiTakaoniBackfire = true;
      return this.chainModify(0.5);
    }
    if (source.getStat("spe") >= target.getStat("spe")) return this.chainModify(1.6);
    source.shunsuiTakaoniBackfire = true;
    return this.chainModify(0.5625);
  },
  onAfterMoveSecondarySelf(source, target, move) {
    if (!source) return;
    if (!source.terastallized) source.setType(["Flying", "Fighting"]);
    if (source.shunsuiTakaoniBackfire) {
      source.shunsuiTakaoniBackfire = false;
      this.damage(Math.max(1, Math.floor(source.maxhp / 10)), source, source, move);
      return;
    }
    if (!source.hasAbility("katenkyokotsu")) return;
    this.add("-activate", source, "ability: Katen Kyokotsu");
    source.shunsuiGamesWon = source.shunsuiGamesWon || {};
    const fresh = !source.shunsuiGamesWon.takaoni;
    if (fresh) {
      source.shunsuiGamesWon.takaoni = true;
      this.boost({spe: 1}, source, source, this.dex.abilities.get("katenkyokotsu"));
    }
    const score = Object.keys(source.shunsuiGamesWon).length;
    if (score >= 3 && !source.shunsuiGameMaster) {
      source.shunsuiGameMaster = true;
      this.boost({atk: 1, spe: 1}, source, source, this.dex.abilities.get("katenkyokotsu"));
      this.heal(Math.max(1, Math.floor(source.maxhp / 4)), source, source, this.dex.abilities.get("katenkyokotsu"));
    }
    let heal = source.shunsuiRepeatGamePenalty === "takaoni" ? Math.floor(source.maxhp / 12) : Math.floor(source.maxhp / (source.shunsuiGameMaster ? 6 : 8));
    if (target && target.fainted) heal = Math.max(heal, Math.floor(source.maxhp / 3));
    this.heal(Math.max(1, heal), source, source, this.dex.abilities.get("katenkyokotsu"));
  },
  secondary: null,
  target: "normal",
  type: "Flying",
  zMove: { basePower: 160 },
  contestType: "Cool",
  desc: "The mountain game. The higher-positioned fighter wins. Airborne Shunsui heavily powers this move and crits grounded foes; if he loses the height rule, the move weakens and backfires. Winning shifts him to Flying/Fighting, heals him, and adds to Katen Kyokotsu's score."
}
