package cfvbaibai.cardfantasy.engine.skill;

import cfvbaibai.cardfantasy.CardFantasyRuntimeException;
import cfvbaibai.cardfantasy.GameUI;
import cfvbaibai.cardfantasy.data.Race;
import cfvbaibai.cardfantasy.data.Skill;
import cfvbaibai.cardfantasy.engine.CardInfo;
import cfvbaibai.cardfantasy.engine.SkillEffect;
import cfvbaibai.cardfantasy.engine.SkillEffectType;
import cfvbaibai.cardfantasy.engine.SkillResolver;
import cfvbaibai.cardfantasy.engine.SkillUseInfo;

public class Synchrome {
    public static void apply(SkillResolver resolver, SkillUseInfo skillUseInfo, CardInfo fieldCard, CardInfo summonedCard, Race race) {
        if (fieldCard == null) {
            throw new CardFantasyRuntimeException("fieldCard cannot be null");
        }
        Skill skill = skillUseInfo.getSkill();
        int adjAT = skill.getImpact() * fieldCard.getLevel0AT() / 100;
        int adjHP = skill.getImpact() * fieldCard.getLevel0AT() / 100;
        GameUI ui = resolver.getStage().getUI();
        if (summonedCard == fieldCard) {
            return;
        }
        if (summonedCard.isSummonedMinion()) {
            return;
        }
        if (summonedCard.getOriginalRace() != race) {
            return;
        }
        ui.useSkill(summonedCard, fieldCard, skill, true);
        ui.adjustAT(summonedCard, fieldCard, adjAT, skill);
        fieldCard.addEffect(new SkillEffect(SkillEffectType.ATTACK_CHANGE, skillUseInfo, adjAT, true));
        ui.adjustHP(summonedCard, fieldCard, adjHP, skill);
        fieldCard.addEffect(new SkillEffect(SkillEffectType.MAXHP_CHANGE, skillUseInfo, adjHP, true));
    }
}

@@ -36,17 +36,19 @@
 e.skill;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -97,16 +97,17 @@
 ception;
+%0D
 %0Aimport 
@@ -135,16 +135,17 @@
 .GameUI;
+%0D
 %0Aimport 
@@ -176,16 +176,17 @@
 ta.Race;
+%0D
 %0Aimport 
@@ -218,16 +218,17 @@
 a.Skill;
+%0D
 %0Aimport 
@@ -265,16 +265,17 @@
 ardInfo;
+%0D
 %0Aimport 
@@ -315,16 +315,17 @@
 lEffect;
+%0D
 %0Aimport 
@@ -369,16 +369,17 @@
 ectType;
+%0D
 %0Aimport 
@@ -421,16 +421,17 @@
 esolver;
+%0D
 %0Aimport 
@@ -472,17 +472,19 @@
 UseInfo;
-%0A
+%0D%0A%0D
 %0Apublic 
@@ -500,16 +500,17 @@
 chrome %7B
+%0D
 %0A    pub
@@ -629,32 +629,33 @@
 rd, Race race) %7B
+%0D
 %0A        if (fie
@@ -671,16 +671,17 @@
  null) %7B
+%0D
 %0A       
@@ -751,16 +751,17 @@
  null%22);
+%0D
 %0A       
@@ -754,32 +754,33 @@
 ll%22);%0D%0A        %7D
+%0D
 %0A        Skill s
@@ -810,16 +810,17 @@
 Skill();
+%0D
 %0A       
@@ -874,32 +874,33 @@
 evel0AT() / 100;
+%0D
 %0A        int adj
@@ -933,32 +933,29 @@
 ieldCard.get
-Level0AT
+MaxHP
 () / 100;%0A  
@@ -951,16 +951,17 @@
 ) / 100;
+%0D
 %0A       
@@ -1001,16 +1001,17 @@
 getUI();
+%0D
 %0A       
@@ -1043,16 +1043,17 @@
 dCard) %7B
+%0D
 %0A       
@@ -1056,32 +1056,33 @@
          return;
+%0D
 %0A        %7D%0A     
@@ -1067,32 +1067,33 @@
 turn;%0D%0A        %7D
+%0D
 %0A        if (sum
@@ -1123,16 +1123,17 @@
 ion()) %7B
+%0D
 %0A       
@@ -1136,32 +1136,33 @@
          return;
+%0D
 %0A        %7D%0A     
@@ -1147,32 +1147,33 @@
 turn;%0D%0A        %7D
+%0D
 %0A        if (sum
@@ -1210,16 +1210,17 @@
  race) %7B
+%0D
 %0A       
@@ -1231,16 +1231,17 @@
  return;
+%0D
 %0A       
@@ -1242,16 +1242,17 @@
        %7D
+%0D
 %0A       
@@ -1302,16 +1302,17 @@
 , true);
+%0D
 %0A       
@@ -1355,32 +1355,33 @@
 , adjAT, skill);
+%0D
 %0A        fieldCa
@@ -1464,24 +1464,25 @@
 jAT, true));
+%0D
 %0A        ui.
@@ -1529,16 +1529,17 @@
  skill);
+%0D
 %0A       
@@ -1637,13 +1637,16 @@
 e));
+%0D
 %0A    %7D
+%0D
 %0A%7D
+%0D
 %0A

Fix numeric bug in Synchrome.