class ProtectSkillLogic extends SkillLogic { counter : boolean = false ; willBeExecuted ( data ) { data . skill . getReady ( data . executor ) ; if ( this . cardManager . isSameCard ( data . targetCard , data . executor ) && data . skill . skillRange !== ENUM . SkillRange . MYSELF ) { return false ; } assert ( ! ( data . skill . range instanceof RandomRange ) , "can't do this with random ranges!" ) ; return super . willBeExecuted ( data ) && this . cardManager . isCardInList ( data . targetCard , data . skill . range . targets ) ; } execute ( data ) { return this . executeProtectPhase ( data ) ; } executeProtectPhase ( data , noProtectLog ? ) { let protector = data . executor ; let protectSkill = data . skill ; let attackSkill = data . attackSkill ; let toReturn = { } ; if ( ! noProtectLog ) { this . logger . addMinorEvent ( { executorId : protector . id , type : ENUM . MinorEventType . PROTECT , protect : { protectedId : data . targetCard . id , counter : this . counter , counteredSkillId : attackSkill . id , attackerId : data . attacker . id } , description : protector . name + " procs " + protectSkill . name + " to protect " + data . targetCard . name + ". " , skillId : protectSkill . id } ) ; } if ( protectSkill . skillFunc === ENUM . SkillFunc . PROTECT_REFLECT ) { var dmgRatio = protectSkill . skillFuncArg5 ; } this . battleModel . processDamagePhase ( { attacker : data . attacker , target : protector , skill : attackSkill , scaledRatio : data . scaledRatio , varyingRatio : data . varyingRatio , dmgRatio : dmgRatio } ) ; if ( protectSkill . skillFunc === ENUM . SkillFunc . PROTECT_REFLECT ) { toReturn . dmgTaken = protector . lastBattleDamageTaken ; } if ( ! data . attacker . justMissed && ! protector . isDead ) { if ( attackSkill . skillFunc === ENUM . SkillFunc . ATTACK || attackSkill . skillFunc === ENUM . SkillFunc . MAGIC ) { AfflictionSkillLogic . processAffliction ( data . attacker , protector , attackSkill ) ; } else if ( Skill . isDebuffAttackSkill ( attackSkill . id ) ) { if ( Math . random ( ) <= attackSkill . skillFuncArg3 ) { DebuffSkillLogic . processDebuff ( data . attacker , protector , attackSkill ) ; } } } if ( data . targetsAttacked ) { data . targetsAttacked [ protector . id ] = true ; } this . clearAllCardsDamagePhaseData ( ) ; return toReturn ; } }