{
    num: 581,
    accuracy: true,
    basePower: 0,
    category: "Status",
    name: "Misty Terrain",
    pp: 10,
    priority: 0,
    flags: { nonsky: 1, metronome: 1 },
    terrain: "mistyterrain",
    condition: {
        duration: 5,
        durationCallback(source, effect) {
            if (source?.hasItem("terrainextender")) {
                return 8;
            }
            return 5;
        },
        onSetStatus(status, target, source, effect) {
            if (!target.isGrounded() || target.isSemiInvulnerable() || target.hasItem("heavydutyboots"))
                return;
            if (effect && (effect.status || effect.id === "yawn")) {
                this.add("-activate", target, "move: Misty Terrain");
            }
            return false;
        },
        onTryAddVolatile(status, target, source, effect) {
            if (!target.isGrounded() || target.isSemiInvulnerable())
                return;
            if (status.id === "confusion") {
                if (effect.effectType === "Move" && !effect.secondaries)
                    this.add("-activate", target, "move: Misty Terrain");
                return null;
            }
        },
        onBasePowerPriority: 6,
        onBasePower(basePower, attacker, defender, move) {
            if (move.type === "Dragon" && defender.isGrounded() && !defender.isSemiInvulnerable() && !defender.hasItem("heavydutyboots")) {
                this.debug("misty terrain weaken");
                return this.chainModify(0.5);
            }
        },
        onFieldStart(field, source, effect) {
            if (effect?.effectType === "Ability") {
                this.add("-fieldstart", "move: Misty Terrain", "[from] ability: " + effect.name, "[of] " + source);
            } else {
                this.add("-fieldstart", "move: Misty Terrain");
            }
        },
        onFieldResidualOrder: 27,
        onFieldResidualSubOrder: 7,
        onFieldEnd() {
            this.add("-fieldend", "Misty Terrain");
        }
    },
    secondary: null,
    target: "all",
    type: "Fairy",
    zMove: { boost: { spd: 1 } },
    contestType: "Beautiful"
}
