package cfvbaibai.cardfantasy.engine.skill;

import cfvbaibai.cardfantasy.CardFantasyRuntimeException;
import cfvbaibai.cardfantasy.Randomizer;
import cfvbaibai.cardfantasy.data.Race;
import cfvbaibai.cardfantasy.data.Skill;
import cfvbaibai.cardfantasy.engine.*;

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

public final class HandCardBuff {
    public static void apply(SkillResolver resolver, SkillUseInfo skillUseInfo, CardInfo card, SkillEffectType effectType, int number) {
        if (card == null) {
            throw new CardFantasyRuntimeException("card cannot be null");
        }
        Skill skill = skillUseInfo.getSkill();
        int impact = skill.getImpact();
        int impactAdd = 0;
        List<CardInfo> allHandCards = card.getOwner().getHand().toList();
        List<CardInfo> addCard = new ArrayList<CardInfo>();
        addCard = Randomizer.getRandomizer().pickRandom(allHandCards, number, true, null);
        for (CardInfo ally : addCard) {
            if (ally.getEffectsCausedBy(skillUseInfo).isEmpty()) {
                resolver.getStage().getUI().useSkill(card, skill, true);
                if (effectType == SkillEffectType.ATTACK_CHANGE) {
                    impactAdd = ally.getInitAT() * impact / 100;
                    resolver.getStage().getUI().adjustAT(card, ally, impactAdd, skill);
                } else if (effectType == SkillEffectType.MAXHP_CHANGE) {
                    impactAdd = ally.getBasicMaxHP() * impact / 100;
                    resolver.getStage().getUI().adjustHP(card, ally, impactAdd, skill);
                } else {
                    throw new CardFantasyRuntimeException("Invalid effect type: " + effectType.name());
                }
                ally.addCoefficientEffect(new SkillEffect(effectType, skillUseInfo, impactAdd, false));
            }
        }
    }
}

@@ -38,16 +38,68 @@
 skill;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 import c
@@ -148,16 +148,16 @@
 eption;%0A
-
 import c
@@ -193,48 +193,8 @@
 er;%0A
-import cfvbaibai.cardfantasy.data.Race;%0A
 impo
@@ -270,61 +270,219 @@
 ine.
-*;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List
+CardInfo;%0Aimport cfvbaibai.cardfantasy.engine.SkillEffect;%0Aimport cfvbaibai.cardfantasy.engine.SkillEffectType;%0Aimport cfvbaibai.cardfantasy.engine.SkillResolver;%0Aimport cfvbaibai.cardfantasy.engine.SkillUseInfo
 ;%0A%0Ap

Fix warnings in HandCardBuff.java