{
    onStart(pokemon) {
        let warnMoves = [];
        let warnBp = 1;
        for (const target of pokemon.foes()) {
            for (const moveSlot of target.moveSlots) {
                const move = this.dex.moves.get(moveSlot.move);
                let bp = move.basePower;
                if (move.ohko) bp = 150;
                if (move.id === 'counter' || move.id === 'metalburst' || move.id === 'mirrorcoat') bp = 120;
                if (bp === 1) bp = 80;
                if (!bp && move.category !== 'Status') bp = 80;
                if (bp > warnBp) {
                    warnMoves = [[move, target]];
                    warnBp = bp;
                } else if (bp === warnBp) {
                    warnMoves.push([move, target]);
                }
            }
        }
        if (!warnMoves.length) return;
        const [warnMove, warnTarget] = this.sample(warnMoves);
        this.add('-activate', pokemon, 'ability: Forewarn', warnMove, '[of] ' + warnTarget);

        if (!warnTarget.volatiles['disable']) {
            warnTarget.addVolatile('forewarn', pokemon, { move: warnMove.id, duration: 1 });
        }
    },

    condition: {
        duration: 1,
        onStart(target, source, effect) {
            this.effectState.move = effect.move;
            this.add('-start', target, 'Disable', this.dex.moves.get(effect.move).name, '[from] ability: Forewarn', '[of] ' + source);
        },
        onDisableMove(pokemon) {
            if (pokemon.volatiles['forewarn']?.move) {
                pokemon.disableMove(this.effectState.move);
            }
        },
        onBeforeMove(attacker, defender, move) {
            if (move.id === this.effectState.move) {
                this.add('cant', attacker, 'Disable', move);
                return false;
            }
        },
        onEnd(pokemon) {
            this.add('-end', pokemon, 'Disable');
        },
    },
    flags: {},
    name: "Forewarn",
    rating: 0.5,
    num: 108,
}
