{
  num: -13005,
  accuracy: true,
  basePower: 0,
  category: "Status",
  name: "Enma Korogi",
  pp: 5,
  priority: 0,
  flags: { protect: 1, mirror: 1, metronome: 1, sound: 1, authentic: 1 },
  bankaiOnly(source, move) {
    if (!source) return false;
    const species = source.species || source.template || {};
    const speciesName = species.name || species.species || "";
    const speciesId = species.id || "";
    const types = source.getTypes ? source.getTypes() : [];
    if (source.hasAbility?.("sensorydeprivation")) return true;
    if (speciesName === "Tosen-Mega" || speciesName === "Tosen-Bankai" || speciesId === "tosenmega" || speciesId === "tosenbankai") return true;
    if (species.forme === "Mega" && (species.baseSpecies === "Tosen" || speciesName.includes("Tosen"))) return true;
    if ((source.baseSpecies?.baseSpecies === "Tosen" || species.baseSpecies === "Tosen" || speciesName === "Tosen") && types.includes("Ghost")) return true;
    this.add("-fail", source, move);
    this.attrLastMove("[still]");
    return false;
  },
  onTryMove(source, target, move) {
    if (!this.effect.bankaiOnly.call(this, source, move)) return null;
  },
  onTry(source, target, move) {
    if (!this.effect.bankaiOnly.call(this, source, move)) return null;
  },
  onTryHit(target, source, move) {
    if (!this.effect.bankaiOnly.call(this, source, move)) return null;
  },
  onHit(target, source, move) {
    if (!target || target.fainted) return;
    target.addVolatile("enmakorogi", source, move);
  },
  condition: {
    onStart(target, source) {
      this.effectState.source = source;
      this.add("-start", target, "move: Enma Korogi", "[of] " + source);
    },
    onTrapPokemon(pokemon) {
      pokemon.tryTrap(true);
    },
    onResidualOrder: 13,
    onResidual(pokemon) {
      const bankaiUser = this.effectState.source;
      if (!bankaiUser || bankaiUser.fainted || !bankaiUser.hp) {
        pokemon.removeVolatile("enmakorogi");
        return;
      }
      this.boost({ accuracy: -1, spe: -1 }, pokemon, bankaiUser, this.dex.moves.get("enmakorogi"));
    },
    onTryMove(source, target, move) {
      const bankaiUser = this.effectState.source;
      if (!bankaiUser || bankaiUser.fainted || !move) return;
      const moveId = String(move.id || "").toLowerCase();
      const blockedSenseMoves = ["aurasphere", "detect", "foresight", "lockon", "mindreader", "miracleeye", "odorsleuth"];
      if (move.category === "Status" || move.flags?.sound || blockedSenseMoves.includes(moveId)) {
        this.add("-activate", bankaiUser, "ability: Sensory Deprivation");
        this.add("-fail", source);
        return false;
      }
      if (target === bankaiUser && !move.flags?.contact) {
        this.add("-activate", bankaiUser, "ability: Sensory Deprivation");
        this.add("-fail", source);
        return false;
      }
    },
    onSourceTryHit(target, source, move) {
      const bankaiUser = this.effectState.source;
      if (!bankaiUser || bankaiUser.fainted || source !== this.effectState.target || target !== bankaiUser || !move) return;
      if (move.category !== "Status" && !move.flags?.contact) {
        this.add("-activate", bankaiUser, "ability: Sensory Deprivation");
        this.add("-fail", source);
        return false;
      }
    },
    onSourceAccuracyPriority: -1,
    onSourceAccuracy(accuracy, target, source, move) {
      const bankaiUser = this.effectState.source;
      if (!bankaiUser || bankaiUser.fainted || source !== this.effectState.target || target !== bankaiUser || !move?.flags?.contact) return;
      return 50;
    },
    onAccuracyPriority: -1,
    onAccuracy(accuracy, target, source, move) {
      const bankaiUser = this.effectState.source;
      if (!bankaiUser || bankaiUser.fainted) return;
      if (target === this.effectState.target && source === bankaiUser) return true;
    },
    onSourceModifyMove(move, source, target) {
      const bankaiUser = this.effectState.source;
      if (!bankaiUser || source !== bankaiUser || !move) return;
      move.ignoreAccuracy = true;
      move.ignoreEvasion = true;
      if (move.type === "Dark" || move.type === "Ghost" || move.type === "Bug") move.willCrit = true;
    },
    onModifyCritRatio(critRatio, source, target, move) {
      const bankaiUser = this.effectState.source;
      if (source === bankaiUser && (move?.type === "Dark" || move?.type === "Ghost" || move?.type === "Bug")) return 5;
    },
    onEnd(target) {
      this.add("-end", target, "move: Enma Korogi");
    }
  },
  target: "allAdjacentFoes",
  type: "Dark",
  zMove: { boost: { accuracy: 1 } },
  contestType: "Clever",
  desc: "Bankai-only. Seals all adjacent foes inside Enma Korogi until the dome breaks, trapping them, dropping their Accuracy and Speed each turn, and making Tosen's Dark, Ghost, and Bug attacks never miss and always crit against them."
}
