{
    name: "Testdamage",
    rating: 5,
    num: -1005,

    onStart(pokemon) {
        pokemon.testDamageThisTurn = 0;
        this.add('-ability', pokemon, 'Testdamage');
    },

    
    onTryHit(target, source, move) {
        
        if (move.category !== 'Status') {
            return true; 
        }
    },

    
    onDamage(damage, target, source, effect) {
        if (!effect || target.fainted) return;

        
        if (effect.effectType === 'Move') {
            
            if (damage >= target.hp) {
                const newDamage = target.hp - 1;
                target.testDamageThisTurn = (target.testDamageThisTurn || 0) + newDamage;
                return newDamage; 
            } else {
                target.testDamageThisTurn = (target.testDamageThisTurn || 0) + damage;
                return damage;
            }
        }

        
        return damage;
    },

    onResidual(pokemon) {
        if (pokemon.fainted) return;

        const damageTaken = pokemon.testDamageThisTurn || 0;
        this.add('-start', pokemon, 'testdamage', damageTaken);

        
        if (pokemon.hp < pokemon.maxhp) {
            this.heal(pokemon.maxhp - pokemon.hp, pokemon, pokemon, this.effect);
        }

        pokemon.testDamageThisTurn = 0;
    },

    onSwitchOut(pokemon) {
        pokemon.testDamageThisTurn = 0;
    }
}