{
  num: -2016,
  accuracy: true,
  basePower: 0,
  category: "Status",
  name: "Sand Barrier",
  pp: 10,
  priority: 4,
  flags: { noassist: 1, failcopycat: 1 },
  stallingMove: true,
  volatileStatus: "sandbarrier",
  onPrepareHit(pokemon) {
    return !!this.queue.willAct() && this.runEvent("StallMove", pokemon);
  },
  onHit(pokemon) {
    pokemon.addVolatile("stall");
  },
  condition: {
    duration: 1,
    onStart(target) {
      this.add("-singleturn", target, "move: Protect");
    },
    onTryHitPriority: 3,
    onTryHit(target, source, move) {
      if (!move.flags || !move.flags.protect) {
        if (["gmaxoneblow", "gmaxrapidflow"].includes(move.id)) return;
        if (move.isZ || move.isMax) target.getMoveHitData(move).zBrokeProtect = true;
        return;
      }
      if (move.smartTarget) {
        move.smartTarget = false;
      } else {
        this.add("-activate", target, "move: Protect");
      }
      const locked = source.getVolatile("lockedmove");
      if (locked && source.volatiles["lockedmove"].duration === 2) {
        delete source.volatiles["lockedmove"];
      }
      if (this.checkMoveMakesContact(move, source, target) && source && !source.fainted) {
        const item = source.getItem();
        if (item && item.id && this.singleEvent("TakeItem", item, source.itemState, source, target, move, item)) {
          const lost = source.takeItem(target);
          if (lost) this.add("-enditem", source, lost, "[from] move: Sand Barrier", "[of] " + target);
        }
      }
      return this.NOT_FAIL;
    },
    onHit(target, source, move) {
      if (move.isZOrMaxPowered && this.checkMoveMakesContact(move, source, target) && source && !source.fainted) {
        const item = source.getItem();
        if (item && item.id && this.singleEvent("TakeItem", item, source.itemState, source, target, move, item)) {
          const lost = source.takeItem(target);
          if (lost) this.add("-enditem", source, lost, "[from] move: Sand Barrier", "[of] " + target);
        }
      }
    }
  },
  secondary: null,
  target: "self",
  type: "Ground"
}
