{
  name: "Sensory Deprivation",
  rating: 5,
  flags: {},
  clearDome(pokemon) {
    for (const side of this.sides || []) {
      const mons = [...(side.active || []), ...(side.pokemon || [])];
      for (const mon of mons) {
        if (mon?.volatiles?.enmakorogi?.source === pokemon) mon.removeVolatile("enmakorogi");
      }
    }
  },
  onStart(pokemon) {
    this.effectState.domeBroken = false;
    this.add("-ability", pokemon, "Sensory Deprivation");
    for (const target of pokemon.foes()) {
      if (!target || target.fainted) continue;
      target.addVolatile("enmakorogi", pokemon);
    }
  },
  onFoeSwitchIn(target) {
    if (this.effectState?.domeBroken) return;
    const source = this.effectState && this.effectState.target;
    if (!source || source.fainted || !target || target.fainted) return;
    target.addVolatile("enmakorogi", source);
  },
  onModifyMove(move, pokemon, target) {
    if (!pokemon || !move || !target) return;
    if (target.volatiles?.enmakorogi?.source !== pokemon) return;
    move.ignoreAccuracy = true;
    move.ignoreEvasion = true;
    if (move.type === "Dark" || move.type === "Ghost" || move.type === "Bug") move.willCrit = true;
  },
  onDamagingHit(damage, target, source, move) {
    if (!target || !target.hasAbility("sensorydeprivation") || !damage || typeof damage !== "number") return;
    if (damage >= target.maxhp * 0.35) {
      this.effectState.domeBroken = true;
      this.add("-activate", target, "ability: Sensory Deprivation");
      this.effect.clearDome.call(this, target);
    }
  },
  onEnd(pokemon) {
    this.effect.clearDome.call(this, pokemon);
  },
  onFaint(pokemon) {
    this.effect.clearDome.call(this, pokemon);
  }
}
