package xyz.luxnk.mxmmod.cards;

import basemod.abstracts.CustomCard;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInDiscardAction;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInDrawPileAction;
import com.megacrit.cardcrawl.actions.defect.DiscardPileToHandAction;
import com.megacrit.cardcrawl.actions.unique.DeckToHandAction;
import com.megacrit.cardcrawl.actions.utility.DiscardToHandAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.status.Dazed;
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.random.Random;
import xyz.luxnk.mxmmod.action.PoorWineAction;
import xyz.luxnk.mxmmod.patches.AbstractCardEnum;

public class PoorWine_MXM extends CustomCard {

    public static final String ID = "PoorWine_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 DESCRIPTION_UPG = cardStrings.UPGRADE_DESCRIPTION;
    public static final String IMG_PATH = "img/cards/skill/poor_wine.png";
    private static final int COST = 1;

    public PoorWine_MXM() {
        super(
                ID,
                NAME,
                IMG_PATH,
                COST,
                DESCRIPTION,
                CardType.SKILL,
                AbstractCardEnum.MXM_COLOR,
                CardRarity.RARE,
                CardTarget.SELF
        );
    }

    @Override
    public void use(AbstractPlayer abstractPlayer, AbstractMonster abstractMonster) {

        int dazedCount = new Random().random(1, 6);
        System.out.println("酒品极差：随机数值为：" + dazedCount);
        AbstractDungeon.actionManager.addToBottom(
                new MakeTempCardInDrawPileAction(
                        new Dazed(), dazedCount, true, true
                ));
        AbstractDungeon.actionManager.addToBottom(
                new MakeTempCardInDiscardAction(
                        new Dazed(), (6 - dazedCount)
                ));
        AbstractDungeon.actionManager.addToBottom(
                new DeckToHandAction(1)
        );
        AbstractDungeon.actionManager.addToBottom(
                new DiscardPileToHandAction(1)
        );
        if (this.upgraded) {
            AbstractDungeon.actionManager.addToBottom(
                    new PoorWineAction(1)
            );
        }
    }

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

    @Override
    public void upgrade() {
        if (!this.upgraded) {
            upgradeName();
            this.rawDescription = DESCRIPTION_UPG;
            initializeDescription();
        }
    }
}
