refactor: improved castMultipleWithAttributeForFree usage with exiled cards (close #13788) (#13794)

This commit is contained in:
Omar Ballesteros 2025-06-28 13:07:15 -06:00 committed by GitHub
parent c3a0c731d6
commit dc8b51c59b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 26 additions and 0 deletions

View file

@ -76,6 +76,8 @@ class CollectedConjuringEffect extends OneShotEffect {
} }
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 6)); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 6));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter, 2); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter, 2);
controller.putCardsOnBottomOfLibrary(cards, game, source, false); controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true; return true;

View file

@ -78,6 +78,8 @@ class DanceWithCalamityEffect extends OneShotEffect {
player.moveCards(card, Zone.EXILED, source, game); player.moveCards(card, Zone.EXILED, source, game);
cards.add(card); cards.add(card);
} }
game.processAction();
cards.retainZone(Zone.EXILED, game);
if (cards if (cards
.getCards(game) .getCards(game)
.stream() .stream()

View file

@ -79,6 +79,8 @@ class EmergentUltimatumEffect extends OneShotEffect {
boolean searched = player.searchLibrary(targetCardInLibrary, source, game); boolean searched = player.searchLibrary(targetCardInLibrary, source, game);
Cards cards = new CardsImpl(targetCardInLibrary.getTargets()); Cards cards = new CardsImpl(targetCardInLibrary.getTargets());
player.moveCards(cards, Zone.EXILED, source, game); player.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
if (cards.isEmpty()) { if (cards.isEmpty()) {
if (searched) { if (searched) {
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);

View file

@ -67,6 +67,8 @@ class EpicExperimentEffect extends OneShotEffect {
} }
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, CardUtil.getSourceCostsTag(game, source, "X", 0))); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, CardUtil.getSourceCostsTag(game, source, "X", 0)));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
FilterCard filter = new FilterInstantOrSorceryCard(); FilterCard filter = new FilterInstantOrSorceryCard();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, CardUtil.getSourceCostsTag(game, source, "X", 0) + 1)); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, CardUtil.getSourceCostsTag(game, source, "X", 0) + 1));
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter);

View file

@ -91,6 +91,8 @@ class EtaliPrimalConquerorEffect extends OneShotEffect {
} }
} }
} }
game.processAction();
cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD);
return true; return true;
} }

View file

@ -78,6 +78,8 @@ class EtaliPrimalStormEffect extends OneShotEffect {
} }
} }
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter);
return true; return true;
} }

View file

@ -78,6 +78,7 @@ class FeveredSuspicionEffect extends OneShotEffect {
} }
} }
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
nonlands.retainZone(Zone.EXILED, game); nonlands.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree( CardUtil.castMultipleWithAttributeForFree(
controller, source, game, nonlands, controller, source, game, nonlands,

View file

@ -144,6 +144,7 @@ class GixYawgmothPraetorExileEffect extends OneShotEffect {
int xValue = GetXValue.instance.calculate(game, source, this); int xValue = GetXValue.instance.calculate(game, source, this);
Set<Card> toExile = opponent.getLibrary().getTopCards(game, xValue); Set<Card> toExile = opponent.getLibrary().getTopCards(game, xValue);
controller.moveCards(toExile, Zone.EXILED, source, game); controller.moveCards(toExile, Zone.EXILED, source, game);
game.processAction();
Cards cards = new CardsImpl(toExile); Cards cards = new CardsImpl(toExile);
cards.retainZone(Zone.EXILED, game); cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD, Integer.MAX_VALUE, null, true); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD, Integer.MAX_VALUE, null, true);

View file

@ -79,6 +79,8 @@ class HazoretsUndyingFuryEffect extends OneShotEffect {
// move cards from library to exile // move cards from library to exile
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
// cast the possible cards without paying the mana // cast the possible cards without paying the mana
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter);
return true; return true;

View file

@ -108,6 +108,7 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
controller.moveCards(card, Zone.EXILED, source, game); controller.moveCards(card, Zone.EXILED, source, game);
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
} }
game.processAction();
cards.retainZone(Zone.EXILED, game); cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD);
return true; return true;

View file

@ -114,6 +114,7 @@ class KefkaDancingMadEffect extends OneShotEffect {
return false; return false;
} }
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game); cards.retainZone(Zone.EXILED, game);
KefkaDancingMadTracker tracker = new KefkaDancingMadTracker(); KefkaDancingMadTracker tracker = new KefkaDancingMadTracker();
CardUtil.castMultipleWithAttributeForFree( CardUtil.castMultipleWithAttributeForFree(

View file

@ -80,6 +80,8 @@ class KotisTheFangkeeperEffect extends OneShotEffect {
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1)); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
game.processAction();
cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter);
return true; return true;
} }

View file

@ -110,6 +110,8 @@ class KyloxVisionaryInventorEffect extends OneShotEffect {
return true; return true;
} }
player.moveCards(cards, Zone.EXILED, source, game); player.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree( CardUtil.castMultipleWithAttributeForFree(
player, source, game, cards, player, source, game, cards,
StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY

View file

@ -132,6 +132,8 @@ class PrimevalSpawnSpellEffect extends OneShotEffect {
} }
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 10)); Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 10));
player.moveCards(cards, Zone.EXILED, source, game); player.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
CardUtil.castMultipleWithAttributeForFree( CardUtil.castMultipleWithAttributeForFree(
player, source, game, cards, StaticFilters.FILTER_CARD, player, source, game, cards, StaticFilters.FILTER_CARD,
Integer.MAX_VALUE, new PrimevalSpawnTracker() Integer.MAX_VALUE, new PrimevalSpawnTracker()

View file

@ -71,6 +71,8 @@ class VillainousWealthEffect extends OneShotEffect {
} }
Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, xValue)); Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, xValue));
opponent.moveCards(cards, Zone.EXILED, source, game); opponent.moveCards(cards, Zone.EXILED, source, game);
game.processAction();
cards.retainZone(Zone.EXILED, game);
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, CardUtil.getSourceCostsTag(game, source, "X", 0) + 1)); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, CardUtil.getSourceCostsTag(game, source, "X", 0) + 1));
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter); CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, filter);