package cfvbaibai.cardfantasy.engine.feature;

import java.util.ArrayList;
import java.util.List;

import cfvbaibai.cardfantasy.data.Feature;
import cfvbaibai.cardfantasy.engine.CardInfo;
import cfvbaibai.cardfantasy.engine.FeatureEffect;
import cfvbaibai.cardfantasy.engine.FeatureEffectType;
import cfvbaibai.cardfantasy.engine.FeatureInfo;
import cfvbaibai.cardfantasy.engine.FeatureResolver;
import cfvbaibai.cardfantasy.engine.HeroDieSignal;
import cfvbaibai.cardfantasy.engine.OnAttackBlockingResult;
import cfvbaibai.cardfantasy.engine.OnDamagedResult;

public final class EnergyDrainFeature {
    public static void apply(FeatureInfo featureInfo, FeatureResolver resolver, CardInfo attacker, CardInfo defender,
            OnAttackBlockingResult result, OnDamagedResult damagedResult) throws HeroDieSignal {
        if (result.getDamage() == 0 || defender == null) {
            return;
        }
        Feature feature = featureInfo.getFeature();
        int adjAT = attacker.getLevel0AT() * feature.getImpact() / 100;

        List<CardInfo> victims = new ArrayList<CardInfo>();
        victims.add(attacker);
        //resolver.getStage().getUI().useSkill(defender, attacker, feature, true);
        int totalAttackWeakened = WeakenFeature.weakenCard(resolver, featureInfo, adjAT, defender, victims);
        //resolver.getStage().getUI().adjustAT(defender, attacker, adjAT, feature);
        //attacker.addEffect(new FeatureEffect(FeatureEffectType.ATTACK_CHANGE, featureInfo, totalAttackWeakened, true));
        
        if (!defender.isDead()) {
            resolver.getStage().getUI().adjustAT(defender, defender, totalAttackWeakened, feature);
            defender.addEffect(new FeatureEffect(FeatureEffectType.ATTACK_CHANGE, featureInfo, totalAttackWeakened, true));
        }
        
        if (damagedResult != null) {
            // Null on magical attack. Only sweep is affected by damaged result.
            damagedResult.originalDamage -= totalAttackWeakened;
        }
    }
}

@@ -38,19 +38,17 @@
 feature;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -67,17 +67,16 @@
 rayList;
-%0D
 %0Aimport 
@@ -90,19 +90,17 @@
 il.List;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -134,17 +134,16 @@
 Feature;
-%0D
 %0Aimport 
@@ -176,25 +176,24 @@
 ne.CardInfo;
-%0D
 %0Aimport cfvb
@@ -231,17 +231,16 @@
 eEffect;
-%0D
 %0Aimport 
@@ -286,17 +286,16 @@
 ectType;
-%0D
 %0Aimport 
@@ -335,17 +335,16 @@
 ureInfo;
-%0D
 %0Aimport 
@@ -388,17 +388,16 @@
 esolver;
-%0D
 %0Aimport 
@@ -439,17 +439,16 @@
 eSignal;
-%0D
 %0Aimport 
@@ -499,17 +499,16 @@
 gResult;
-%0D
 %0Aimport 
@@ -552,19 +552,17 @@
 dResult;
-%0D%0A%0D
+%0A
 %0Apublic 
@@ -593,17 +593,16 @@
 eature %7B
-%0D
 %0A    pub
@@ -711,17 +711,16 @@
 efender,
-%0D
 %0A       
@@ -808,17 +808,16 @@
 Signal %7B
-%0D
 %0A       
@@ -859,33 +859,32 @@
 ender == null) %7B
-%0D
 %0A            ret
@@ -887,17 +887,16 @@
  return;
-%0D
 %0A       
@@ -889,33 +889,32 @@
 eturn;%0A        %7D
-%0D
 %0A        Feature
@@ -949,17 +949,16 @@
 ature();
-%0D
 %0A       
@@ -987,17 +987,17 @@
 getLevel
-0
+1
 AT() * f
@@ -1025,11 +1025,9 @@
 100;
-%0D%0A%0D
+%0A
 %0A   
@@ -1082,17 +1082,16 @@
 Info%3E();
-%0D
 %0A       
@@ -1113,17 +1113,16 @@
 tacker);
-%0D
 %0A       
@@ -1196,17 +1196,16 @@
 , true);
-%0D
 %0A       
@@ -1305,17 +1305,16 @@
 ictims);
-%0D
 %0A       
@@ -1381,33 +1381,32 @@
 adjAT, feature);
-%0D
 %0A        //attac
@@ -1503,33 +1503,32 @@
 eakened, true));
-%0D
 %0A        %0D%0A     
@@ -1512,33 +1512,32 @@
 true));%0A        
-%0D
 %0A        if (!de
@@ -1554,17 +1554,16 @@
 ead()) %7B
-%0D
 %0A       
@@ -1654,17 +1654,16 @@
 eature);
-%0D
 %0A       
@@ -1778,17 +1778,16 @@
  true));
-%0D
 %0A       
@@ -1784,25 +1784,24 @@
 );%0A        %7D
-%0D
 %0A        %0D%0A 
@@ -1797,17 +1797,16 @@
         
-%0D
 %0A       
@@ -1834,17 +1834,16 @@
  null) %7B
-%0D
 %0A       
@@ -1915,17 +1915,16 @@
  result.
-%0D
 %0A       
@@ -1980,17 +1980,16 @@
 eakened;
-%0D
 %0A       
@@ -1994,16 +1994,13 @@
    %7D
-%0D
 %0A    %7D
-%0D
 %0A%7D
-%0D
 %0A

Fix bug in EnergyDrain