package xyz.luxnk.mxmmod.cards;

import basemod.abstracts.CustomCard;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.actions.unique.MadnessAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.DoubleTapPower;
import xyz.luxnk.mxmmod.action.StormRushAction;
import xyz.luxnk.mxmmod.patches.AbstractCardEnum;
import xyz.luxnk.mxmmod.util.SpeedUpUtil;

public class StormRush_MXM extends CustomCard {

    public static final String ID = "StormRush_MXM";
    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "img/cards/attack/strike_mxm.png";
    private static final int COST = 2;
    private static final int ATTACK_DMG = 15;
    private static final int CARD_AMOUNT = 1;
    private static final int SPEED_COUNT = 6;

    public StormRush_MXM() {
        super(
                ID,
                NAME,
                IMG_PATH,
                COST,
                DESCRIPTION,
                CardType.ATTACK,
                AbstractCardEnum.MXM_COLOR,
                CardRarity.RARE,
                CardTarget.ENEMY
        );
        this.baseDamage = ATTACK_DMG;
        this.baseMagicNumber = CARD_AMOUNT;
        this.magicNumber = this.baseMagicNumber;
    }

    @Override
    public void use(AbstractPlayer abstractPlayer, AbstractMonster abstractMonster) {
        AbstractDungeon.actionManager.addToBottom(
                new DamageAction(
                        abstractMonster,
                        new DamageInfo(abstractPlayer, this.damage, this.damageTypeForTurn),
                        AbstractGameAction.AttackEffect.SLASH_HORIZONTAL));
        AbstractDungeon.actionManager.addToBottom(
                new ApplyPowerAction(
                        abstractPlayer,
                        abstractPlayer,
                        new DoubleTapPower(abstractPlayer, this.magicNumber),
                        this.magicNumber));
        if (SpeedUpUtil.checkSpeed(abstractPlayer, SPEED_COUNT)) {
            AbstractDungeon.actionManager.addToBottom(new StormRushAction(this.magicNumber));
        }
    }

    @Override
    public AbstractCard makeCopy() {
        return new StormRush_MXM();
    }

    @Override
    public void upgrade() {
        if (!this.upgraded) {
            upgradeName();
            upgradeMagicNumber(1);
        }
    }
}
