com.megacrit.cardcrawl.cards.CardGroup Java Examples

The following examples show how to use com.megacrit.cardcrawl.cards.CardGroup. 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: BranchingUpgradesPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, AbstractCard card, CardGroup group, Hitbox ___upgradeHb) {
    if (card instanceof BranchingUpgradesCard) {
        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);
        try {
            Method canToggleBetaArt = SingleCardViewPopup.class.getDeclaredMethod("canToggleBetaArt");
            canToggleBetaArt.setAccessible(true);
            Method allowUpgradePreview = SingleCardViewPopup.class.getDeclaredMethod("allowUpgradePreview");
            allowUpgradePreview.setAccessible(true);
            if ((boolean) canToggleBetaArt.invoke(__instance)) {
                if ((boolean) allowUpgradePreview.invoke(__instance)) {
                    ___upgradeHb.move(Settings.WIDTH / 2f - 300f * Settings.scale, 70f * Settings.scale);
                    branchUpgradeHb.move(Settings.WIDTH / 2f - 40f * Settings.scale, 70f * Settings.scale);
                }
            } else {
                ___upgradeHb.move(Settings.WIDTH / 2f + 250f * Settings.scale, 70f * Settings.scale);
                branchUpgradeHb.move(Settings.WIDTH / 2f - 250f * Settings.scale, 70f * Settings.scale);
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
 
Example #2
Source File: StSLib.java    From StSLib with MIT License 6 votes vote down vote up
@Override
public void receiveOnBattleStart(AbstractRoom abstractRoom)
{
    CardGroup[] cardGroups = new CardGroup[] {
            AbstractDungeon.player.drawPile,
            AbstractDungeon.player.hand,
            AbstractDungeon.player.discardPile,
            AbstractDungeon.player.exhaustPile
    };

    for (CardGroup cardGroup : cardGroups) {
        for (AbstractCard c : cardGroup.group) {
            if (c instanceof StartupCard) {
                if (((StartupCard) c).atBattleStartPreDraw()) {
                    AbstractDungeon.effectList.add(0, new ShowCardBrieflyEffect(c.makeStatEquivalentCopy()));
                }
            }
        }
    }
}
 
Example #3
Source File: BottledMemoryRelic.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
@Override
public void onEquip() {
    // follow same behavior as base game bottle relics. Maybe there's some mod that adds a bottle mechanic changing card using getPurgeableCards
    CardGroup rememberCards = CardUtils.getCardsForBottling(AbstractDungeon.player.masterDeck.getPurgeableCards());
    rememberCards.group.removeIf(c -> !c.hasTag(REMEMBER_MEMORY));
    if (rememberCards.size() > 0) {
        this.cardSelected = false;
        if (AbstractDungeon.isScreenUp) {
            AbstractDungeon.dynamicBanner.hide();
            AbstractDungeon.overlayMenu.cancelButton.hide();
            AbstractDungeon.previousScreen = AbstractDungeon.screen;
        }

        AbstractDungeon.getCurrRoom().phase = AbstractRoom.RoomPhase.INCOMPLETE;
        AbstractDungeon.gridSelectScreen.open(rememberCards, 1, this.DESCRIPTIONS[1] + this.name + LocalizedStrings.PERIOD, false, false, false, false);
    }
}
 
Example #4
Source File: PrideMemory.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
@Override
public void onVictory() {
    if (isPassiveEffectActive()) {
        CardGroup masterDeckCandidates = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED);
        for (AbstractCard c : AbstractDungeon.player.masterDeck.group) {
            if (c.canUpgrade()) {
                masterDeckCandidates.addToBottom(c);
            }
        }

        if (!masterDeckCandidates.isEmpty()) {
            AbstractCard masterDeckCard = masterDeckCandidates.getRandomCard(AbstractDungeon.cardRandomRng);
            masterDeckCard.upgrade();
            masterDeckCard.superFlash();
            EffectUtils.addPermanentCardUpgradeEffect(masterDeckCard);
        }
    }
}
 
Example #5
Source File: BottledPlaceholderRelic.java    From StS-DefaultModBase with MIT License 5 votes vote down vote up
@Override
public void onEquip() { // 1. When we acquire the relic
    cardSelected = false; // 2. Tell the relic that we haven't bottled the card yet
    if (AbstractDungeon.isScreenUp) { // 3. If the map is open - hide it.
        AbstractDungeon.dynamicBanner.hide();
        AbstractDungeon.overlayMenu.cancelButton.hide();
        AbstractDungeon.previousScreen = AbstractDungeon.screen;
    }
    AbstractDungeon.getCurrRoom().phase = AbstractRoom.RoomPhase.INCOMPLETE;
    // 4. Set the room to INCOMPLETE - don't allow us to use the map, etc.
    CardGroup group = CardGroup.getGroupWithoutBottledCards(AbstractDungeon.player.masterDeck); // 5. Get a card group of all currently unbottled cards
    AbstractDungeon.gridSelectScreen.open(group, 1, DESCRIPTIONS[3] + name + DESCRIPTIONS[2], false, false, false, false);
    // 6. Open the grid selection screen with the cards from the CardGroup we specified above. The description reads "Select a card to bottle for" + (relic name) + "."
}
 
Example #6
Source File: MoveCardsAction.java    From StSLib with MIT License 5 votes vote down vote up
public MoveCardsAction(CardGroup destination, CardGroup source, Predicate<AbstractCard> predicate, int amount, Consumer<List<AbstractCard>> callback)
{
    p = AbstractDungeon.player;
    this.destination = destination;
    this.source = source;
    this.predicate = predicate;
    this.callback = callback;
    setValues(p, AbstractDungeon.player, amount);
    actionType = AbstractGameAction.ActionType.CARD_MANIPULATION;
    duration = Settings.ACTION_DUR_MED;
}
 
Example #7
Source File: OnRemoveCardFromMasterDeckPatch.java    From StSLib with MIT License 5 votes vote down vote up
public static void Postfix(CardGroup __instance, AbstractCard c)
{
    if (__instance.type == CardGroup.CardGroupType.MASTER_DECK) {
        for (AbstractRelic r : AbstractDungeon.player.relics) {
            if (r instanceof OnRemoveCardFromMasterDeckRelic) {
                ((OnRemoveCardFromMasterDeckRelic) r).onRemoveCardFromMasterDeck(c);
            }
        }
    }
}
 
Example #8
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(Astrolabe __instance, @ByRef CardGroup[] tmp)
{
    tmp[0].group.removeIf(c -> SoulboundField.soulbound.get(c));
}
 
Example #9
Source File: ExertedPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static ExprEditor Instrument() {
    return new ExprEditor() {
        @Override
        public void edit(MethodCall methodCall) throws CannotCompileException {
            if (methodCall.getClassName().equals(CardGroup.class.getName()) && methodCall.getMethodName().equals("addToTop")) {
                methodCall.replace(String.format("{ if (!%1$s.isExerted($1)) { $_ = $proceed($$); } }", ExertedPatch.class.getName()));
            }
        }
    };
}
 
Example #10
Source File: MaterialComponentsDeck.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
private static void drawCardsFromPoolToDeck(int count, CardGroup pool, Runnable poolResetFunction) {
    for (int i = 0; i < count; ++i) {
        if (pool.isEmpty()) {
            poolResetFunction.run();
        }
        deck.addToTop(pool.getTopCard());
        pool.removeTopCard();
    }
}
 
Example #11
Source File: PurgeMind.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
private void exhaustRememberCardsInGroup(CardGroup group) {
    for (AbstractCard card : group.group) {
        if (card.hasTag(REMEMBER_MEMORY)) {
            AbstractDungeon.actionManager.addToBottom(new ExhaustSpecificCardAction(card, group));
        }
    }
}
 
Example #12
Source File: Tragedy.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
private void exhaustCursesInGroup(CardGroup group) {
    for (AbstractCard c : group.group) {
        if (c.type.equals(CardType.CURSE)) {
            AbstractDungeon.actionManager.addToBottom(new ExhaustSpecificCardAction(c, group));
        }
    }
}
 
Example #13
Source File: CardSaveData.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void onLoadRaw(JsonElement jsonElement) {
    try {
        cardData = saveFileGson.fromJson(jsonElement, new TypeToken<ArrayList<CardData>>(){}.getType());
    } catch (JsonSyntaxException e) {
        cardData = null;
    }

    final CardGroup masterDeck = AbstractDungeon.player.masterDeck;

    if (jsonElement == null) {
        JorbsMod.logger.warn("CardSaveData found no JSON element to load");
    } else if (cardData == null) {
        JorbsMod.logger.error("CardSaveData failed to parse JSON");
    } else if (cardData.size() != masterDeck.group.size()) {
        JorbsMod.logger.error("CardSaveData has a different number of cards than the master deck");
    } else {
        // Restore meaning to cards from the saved addenda
        int i = 0;

        for (AbstractCard card : masterDeck.group) {
            int wrathEffectCount = cardData.get(i).wrathEffectCount;
            WrathMemory.reapplyToLoadedCard(card, wrathEffectCount);
            boolean isEntombed = cardData.get(i).isEntombed;
            EntombedField.entombed.set(card, isEntombed);
            boolean isExerted = cardData.get(i).isExerted;
            ExertedField.exerted.set(card, isExerted);
            i++;
        }
    }
}
 
Example #14
Source File: ConsumeRandomCardAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public void update() {
    CardGroup candidateCards = CardGroup.getGroupWithoutBottledCards(pileToConsumeFrom.getPurgeableCards());
    if (!candidateCards.isEmpty()) {
        AbstractCard randomlyChosenCard = candidateCards.getRandomCard(AbstractDungeon.cardRandomRng);
        addToTop(new ConsumeCardAction(randomlyChosenCard));
    }
    isDone = true;
}
 
Example #15
Source File: CardsToTopOfDeckAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public CardsToTopOfDeckAction(AbstractCreature source, CardGroup sourcePile, int cardCount, boolean randomOrder) {
    this.setValues(null, source, cardCount);
    this.actionType = ActionType.CARD_MANIPULATION;
    this.duration = Settings.ACTION_DUR_FASTER;
    this.sourcePile = sourcePile;
    this.randomOrder = randomOrder;
}
 
Example #16
Source File: ExhaustCardsMatchingPredicateAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public ExhaustCardsMatchingPredicateAction(
        AbstractCreature source, CardGroup pile, Predicate<AbstractCard> filter)
{
    this.setValues(AbstractDungeon.player, source, 1);
    this.actionType = ActionType.EXHAUST;
    this.startingDuration = Settings.ACTION_DUR_FAST;
    this.duration = this.startingDuration;
    this.pile = pile;
    this.filter = filter;
}
 
Example #17
Source File: CampfireThirstPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static CardGroup getWrathCards() {
    CardGroup masterDeck = AbstractDungeon.player.masterDeck;
    CardGroup retVal = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED);
    for (AbstractCard c : masterDeck.group) {
        if (WrathField.wrathEffectCount.get(c) > 0) {
            retVal.group.add(c);
        }
    }

    return retVal;
}
 
Example #18
Source File: LegendaryPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@SpirePrefixPatch
public static void patch(CardGroup instance, String targetID) {
    if (instance.type == CardGroup.CardGroupType.MASTER_DECK) {
        if (instance.group.stream().anyMatch(c -> c.cardID.equals(targetID) && c.hasTag(LEGENDARY))) {
            logger.error("Legendary card removed by cardID from Master Deck.");
        }
    }
}
 
Example #19
Source File: EntombedPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static ExprEditor Instrument() {
    return new ExprEditor() {
        @Override
        public void edit(MethodCall methodCall) throws CannotCompileException {
            if (methodCall.getClassName().equals(CardGroup.class.getName()) && methodCall.getMethodName().equals("addToTop")) {
                methodCall.replace(String.format("{ if (!%1$s.isEntombed($1)) { $_ = $proceed($$); } }", EntombedPatch.class.getName()));
            }
        }
    };
}
 
Example #20
Source File: AbjureAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
private int moveSpiritShieldsToHand(CardGroup originalPile) {
    int movedCards = 0;
    for (AbstractCard c : originalPile.group) {
        if (c instanceof SpiritShield_Cull) {
            ++movedCards;
            AbstractDungeon.actionManager.addToBottom(new PileToHandAction(originalPile, c));
        }
    }
    return movedCards;
}
 
Example #21
Source File: LegendaryPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@SpirePostfixPatch
public static AbstractCard patch(AbstractCard.CardType type, Random rng) {
    ArrayList<AbstractCard> cards =
            CardGroup.getGroupWithoutBottledCards(AbstractDungeon.player.masterDeck).group.stream()
                    .filter(c -> c.type == type && !c.hasTag(LEGENDARY))
                    .collect(Collectors.toCollection(ArrayList::new));
    return cards.remove(rng.random(cards.size() - 1));
}
 
Example #22
Source File: MoveCardsAction.java    From StSLib with MIT License 4 votes vote down vote up
public MoveCardsAction(CardGroup destination, CardGroup source, Predicate<AbstractCard> predicate, int amount)
{
    this (destination, source, predicate, amount, null);
}
 
Example #23
Source File: UniqueCardUtils.java    From jorbs-spire-mod with MIT License 4 votes vote down vote up
public static int countUniqueCards(CardGroup group) {
    Set<String> uniqueCardIDs = new HashSet<>();
    group.group.forEach(c -> uniqueCardIDs.add(getUpgradeInclusiveCardID(c)));
    return uniqueCardIDs.size();
}
 
Example #24
Source File: IdentityCrisisEvent.java    From StS-DefaultModBase with MIT License 4 votes vote down vote up
@Override
protected void buttonEffect(int i) { // This is the event:
    switch (screenNum) {
        case 0: // While you are on screen number 0 (The starting screen)
            switch (i) {
                case 0: // If you press button the first button (Button at index 0), in this case: Inspiration.
                    this.imageEventText.updateBodyText(DESCRIPTIONS[1]); // Update the text of the event
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]); // 1. Change the first button to the [Leave] button
                    this.imageEventText.clearRemainingOptions(); // 2. and remove all others
                    screenNum = 1; // Screen set the screen number to 1. Once we exit the switch (i) statement,
                    // we'll still continue the switch (screenNum) statement. It'll find screen 1 and do it's actions
                    // (in our case, that's the final screen, but you can chain as many as you want like that)

                    AbstractRelic relicToAdd = RelicLibrary.starterList.get(AbstractDungeon.relicRng.random(RelicLibrary.starterList.size() - 1)).makeCopy();
                    // Get a random starting relic

                    AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2), relicToAdd);


                    break; // Onto screen 1 we go.
                case 1: // If you press button the second button (Button at index 1), in this case: Deinal

                    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.MED, ScreenShake.ShakeDur.MED, false);
                    // Shake the screen
                    CardCrawlGame.sound.play("BLUNT_FAST");  // Play a hit sound
                    AbstractDungeon.player.decreaseMaxHealth(healthdamage); // Lose max HP
                    if (CardGroup.getGroupWithoutBottledCards(AbstractDungeon.player.masterDeck.getPurgeableCards()).size() > 0) {
                        // If you have cards you can remove - remove a card
                        AbstractDungeon.gridSelectScreen.open(
                                CardGroup.getGroupWithoutBottledCards(
                                        AbstractDungeon.player.masterDeck.getPurgeableCards()),
                                1, OPTIONS[6], false, false, false, true);
                    }

                    this.imageEventText.updateBodyText(DESCRIPTIONS[2]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;

                    // Same as before. A note here is that you can also do
                    // imageEventText.clearAllDialogs();
                    // imageEventText.setDialogOption(OPTIONS[1]);
                    // imageEventText.setDialogOption(OPTIONS[4]);
                    // (etc.)
                    // And that would also just set them into slot 0, 1, 2... in order, just like what we do in the very beginning

                    break; // Onto screen 1 we go.
                case 2: // If you press button the third button (Button at index 2), in this case: Acceptance

                    AbstractCard c = new Apotheosis().makeCopy();
                    AbstractDungeon.effectList.add(new ShowCardAndObtainEffect(c, (float) (Settings.WIDTH / 2), (float) (Settings.HEIGHT / 2)));

                    this.imageEventText.updateBodyText(DESCRIPTIONS[3]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;
                    break;
                case 3: // If you press button the fourth button (Button at index 3), in this case: TOUCH
                    imageEventText.loadImage("theDefaultResources/images/events/IdentityCrisisEvent2.png"); // Change the shown image
                    // Other than that, this option doesn't do anything special.
                    this.imageEventText.updateBodyText(DESCRIPTIONS[4]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;
                    break;
            }
            break;
        case 1: // Welcome to screenNum = 1;
            switch (i) {
                case 0: // If you press the first (and this should be the only) button,
                    openMap(); // You'll open the map and end the event.
                    break;
            }
            break;
    }
}
 
Example #25
Source File: MoveCardsAction.java    From StSLib with MIT License 4 votes vote down vote up
public MoveCardsAction(CardGroup destination, CardGroup source, Predicate<AbstractCard> predicate, Consumer<List<AbstractCard>> callback)
{
    this(destination, source, predicate, 1, callback);
}
 
Example #26
Source File: MoveCardsAction.java    From StSLib with MIT License 4 votes vote down vote up
public MoveCardsAction(CardGroup destination, CardGroup source, int amount, Consumer<List<AbstractCard>> callback)
{
    this(destination, source, c -> true, amount, callback);
}
 
Example #27
Source File: AutoplayCardAction.java    From StSLib with MIT License 4 votes vote down vote up
public AutoplayCardAction(AbstractCard card, CardGroup group)
{
    this.card = card;
    this.group = group;
}
 
Example #28
Source File: FetchAction.java    From StSLib with MIT License 4 votes vote down vote up
public FetchAction(CardGroup source)
{
    this(source, c -> true, 1);
}
 
Example #29
Source File: FetchAction.java    From StSLib with MIT License 4 votes vote down vote up
public FetchAction(CardGroup source, int amount)
{
    this(source, c -> true, amount);
}
 
Example #30
Source File: MoveCardsAction.java    From StSLib with MIT License 4 votes vote down vote up
public MoveCardsAction(CardGroup destination, CardGroup source, Consumer<List<AbstractCard>> callback)
{
    this(destination, source, c -> true, 1, callback);
}