{
    onTryHit(target, source, move) {
        if (target === source || move.category === 'Status' || move.type === '???' || move.id === 'struggle') return;
        if (move.id === 'skydrop' && !source.volatiles['skydrop']) return;
        this.debug('Wonder Guard immunity: ' + move.id);
        if (target.runEffectiveness(move) <= 0) {
            if (move.smartTarget) {
                move.smartTarget = false;
            } else {
                this.add('-immune', target, '[from] ability: Wonder Guard');
            }
            return null;
        }
    },
    onAfterTerastallization(pokemon) {
        if (pokemon.terastallized) {
            const teraType = pokemon.teraType || pokemon.types[0];
            this.add('-start', pokemon, 'Tera Type', teraType);
            pokemon.addVolatile('teratypeboost');
        }

        pokemon.addVolatile('wogteraremove');
        if (pokemon.volatiles['wogteraremove']) {
            this.add('custom', '-endterastallize', pokemon);
            delete pokemon.terastallized;
            pokemon.removeVolatile('wogteraremove');
        }
    },
    onSwitchOut(pokemon) {
        if (pokemon.volatiles['teratypeboost']) {
            pokemon.teraBoostKept = true;
        }
    },
    onSwitchIn(pokemon) {
        if (pokemon.teraBoostKept) {
            this.add('-start', pokemon, 'Tera Type');
            pokemon.addVolatile('teratypeboost');
        }
    },
    onModifyDamage(damage, source, target, move) {
        if (source.volatiles['teratypeboost']) {
            const teraType = source.teraType || source.types[0];

            if (target.hasType(teraType)) {
                this.debug('Tera type boost for Wonder Guard: matching types');
                return this.chainModify(2);
            }
        }
    },
    flags: {failroleplay: 1, noreceiver: 1, noentrain: 1, failskillswap: 1, breakable: 1},
    name: "Wonder Guard",
    rating: 5,
    num: 25,
}
