class DrainSkillLogic extends SkillLogic { willBeExecuted ( data ) { let hasValidTarget = data . skill . range . hasValidTarget ( data . executor , this . getCondFunc ( ) ) ; return super . willBeExecuted ( data ) && hasValidTarget ; } private getCondFunc ( ) { return ( card ) : boolean => ! card . isFullHealth ( ) ; } execute ( data ) { let skill = data . skill ; skill . range . getReady ( data . executor , this . getCondFunc ( ) ) ; let target ; this . logger . addMinorEvent ( { executorId : data . executor . id , type : ENUM . MinorEventType . DESCRIPTION , description : data . executor . name + " procs " + skill . name + ". " , skillId : skill . id } ) ; assert ( ! ( skill . range instanceof RandomRange ) , "can't do this with random ranges!" ) ; let eachTargetHealAmount = Math . floor ( data . executor . lastBattleDamageTaken / skill . range . targets . length ) ; while ( target = skill . getTarget ( data . executor ) ) { this . battleModel . damageToTargetDirectly ( target , - 1 * eachTargetHealAmount , " healing" ) ; } } }