com.megacrit.cardcrawl.helpers.CardLibrary Java Examples

The following examples show how to use com.megacrit.cardcrawl.helpers.CardLibrary. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LegendaryPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static void addCardToPools(AbstractCard card) {
    logger.info(String.format("Adding card %1$s (%2$s/%3$s/%4$s) to applicable pools", card.cardID, card.rarity, card.color, card.type));

    // AbstractDungeon has many returnRandom*, returnTrulyRandom*, and *transformCard methods that use these pools.
    if (card.rarity == AbstractCard.CardRarity.COMMON) {
        AbstractDungeon.commonCardPool.addToTop(card);
        AbstractDungeon.srcCommonCardPool.addToTop(card);
    } else if (card.rarity == AbstractCard.CardRarity.UNCOMMON) {
        AbstractDungeon.uncommonCardPool.addToTop(card);
        AbstractDungeon.srcUncommonCardPool.addToTop(card);
    } else if (card.rarity == AbstractCard.CardRarity.RARE) {
        AbstractDungeon.rareCardPool.addToTop(card);
        AbstractDungeon.srcRareCardPool.addToTop(card);
    }

    // Note: color pools can overlap with rarity pools
    if (card.color == AbstractCard.CardColor.COLORLESS) {
        AbstractDungeon.colorlessCardPool.addToTop(card);
        AbstractDungeon.srcColorlessCardPool.addToTop(card);
    }
    if (card.color == AbstractCard.CardColor.CURSE || card.rarity == AbstractCard.CardRarity.CURSE) {
        AbstractDungeon.curseCardPool.addToTop(card);
        AbstractDungeon.srcCurseCardPool.addToTop(card);

        // AbstractDungeon.transformCard can call getCurse directly to generate a replacement curse.
        HashMap<String, AbstractCard> curses = ReflectionUtils.getPrivateField(null, CardLibrary.class, "curses");
        curses.put(card.cardID, card);
    }
}
 
Example #2
Source File: LegendaryPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static void removeCardFromPools(AbstractCard card) {
    logger.info(String.format("Removing card %1$s (%2$s/%3$s/%4$s) from applicable pools", card.cardID, card.rarity, card.color, card.type));
    Predicate<AbstractCard> isMatch = c -> c.cardID.equals(card.cardID);

    // AbstractDungeon has many returnRandom*, returnTrulyRandom*, and *transformCard methods that use these pools.
    if (card.rarity == AbstractCard.CardRarity.COMMON) {
        AbstractDungeon.commonCardPool.group.removeIf(isMatch);
        AbstractDungeon.srcCommonCardPool.group.removeIf(isMatch);
    } else if (card.rarity == AbstractCard.CardRarity.UNCOMMON) {
        AbstractDungeon.uncommonCardPool.group.removeIf(isMatch);
        AbstractDungeon.srcUncommonCardPool.group.removeIf(isMatch);
    } else if (card.rarity == AbstractCard.CardRarity.RARE) {
        AbstractDungeon.rareCardPool.group.removeIf(isMatch);
        AbstractDungeon.srcRareCardPool.group.removeIf(isMatch);
    }

    // Note: color pools can overlap with rarity pools
    if (card.color == AbstractCard.CardColor.COLORLESS) {
        AbstractDungeon.colorlessCardPool.group.removeIf(isMatch);
        AbstractDungeon.srcColorlessCardPool.group.removeIf(isMatch);
    }
    if (card.color == AbstractCard.CardColor.CURSE || card.rarity == AbstractCard.CardRarity.CURSE) {
        AbstractDungeon.curseCardPool.group.removeIf(isMatch);
        AbstractDungeon.srcCurseCardPool.group.removeIf(isMatch);

        // AbstractDungeon.transformCard can call getCurse directly to generate a replacement curse.
        HashMap<String, AbstractCard> curses = ReflectionUtils.getPrivateField(null, CardLibrary.class, "curses");
        curses.remove(card.cardID);
    }
}
 
Example #3
Source File: DeckOfTrialsSaveData.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void onLoad(String deckOfTrials) {
    Arrays.asList(deckOfTrials.split(",")).forEach(c -> {
        if (c.length() > 0) {
            DeckOfTrials.deck.addToTop(CardLibrary.getCard(CULL, c));
        }
    });
}
 
Example #4
Source File: SoulboundPatch.java    From StSLib with MIT License 5 votes vote down vote up
@SpireInsertPatch(
        locator=Locator.class,
        localvars={"tmp"}
)
public static void Insert(@ByRef ArrayList<String>[] tmp)
{
    tmp[0].removeIf(id -> CardLibrary.cards.get(id).rarity == AbstractCard.CardRarity.SPECIAL);
}
 
Example #5
Source File: SoulboundPatch.java    From StSLib with MIT License 5 votes vote down vote up
@SpireInsertPatch(
        locator=Locator.class,
        localvars={"tmp"}
)
public static void Insert(AbstractCard prohibitedCard, Random rng, @ByRef ArrayList<String>[] tmp)
{
    tmp[0].removeIf(id -> CardLibrary.cards.get(id).rarity == AbstractCard.CardRarity.SPECIAL);
}