diff --git a/Mage.Sets/src/mage/cards/c/Conflux.java b/Mage.Sets/src/mage/cards/c/Conflux.java index a0de7fd3dca..988edce0fcb 100644 --- a/Mage.Sets/src/mage/cards/c/Conflux.java +++ b/Mage.Sets/src/mage/cards/c/Conflux.java @@ -1,33 +1,32 @@ - package mage.cards.c; -import java.util.UUID; -import mage.ObjectColor; import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.ColorAssignment; +import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.cards.*; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.ColorPredicate; +import mage.filter.common.FilterLandCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ColorlessPredicate; import mage.game.Game; -import mage.players.Player; import mage.target.common.TargetCardInLibrary; +import java.util.UUID; + /** - * - * @author jeffwadsworth + * @author TheElk801 */ public final class Conflux extends CardImpl { public Conflux(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{W}{U}{B}{R}{G}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{W}{U}{B}{R}{G}"); // Search your library for a white card, a blue card, a black card, a red card, and a green card. Reveal those cards and put them into your hand. Then shuffle your library. - this.getSpellAbility().addEffect(new ConfluxEffect()); - + this.getSpellAbility().addEffect(new SearchLibraryPutInHandEffect( + new ConfluxTarget(), true, true + ).setText("search your library for a white card, a blue card, a black card, a red card, and a green card. " + + "Reveal those cards and put them into your hand. Then shuffle your library")); } public Conflux(final Conflux card) { @@ -40,109 +39,44 @@ public final class Conflux extends CardImpl { } } -class ConfluxEffect extends OneShotEffect { +class ConfluxTarget extends TargetCardInLibrary { - public ConfluxEffect() { - super(Outcome.DrawCard); - this.staticText = "Search your library for a white card, a blue card, a black card, a red card, and a green card. Reveal those cards and put them into your hand. Then shuffle your library"; + private static final FilterCard filter + = new FilterLandCard("a white card, a blue card, a black card, a red card, and a green card"); + + static { + filter.add(Predicates.not(ColorlessPredicate.instance)); } - public ConfluxEffect(final ConfluxEffect effect) { - super(effect); + private static final ColorAssignment colorAssigner = new ColorAssignment(); + + ConfluxTarget() { + super(0, 5, filter); + } + + private ConfluxTarget(final ConfluxTarget target) { + super(target); } @Override - public ConfluxEffect copy() { - return new ConfluxEffect(this); + public ConfluxTarget copy() { + return new ConfluxTarget(this); } @Override - public boolean apply(Game game, Ability source) { - Player you = game.getPlayer(source.getControllerId()); - Cards cards = new CardsImpl(); - FilterCard filterWhite = new FilterCard("white card"); - filterWhite.add(new ColorPredicate(ObjectColor.WHITE)); - FilterCard filterBlue = new FilterCard("blue card"); - filterBlue.add(new ColorPredicate(ObjectColor.BLUE)); - FilterCard filterBlack = new FilterCard("black card"); - filterBlack.add(new ColorPredicate(ObjectColor.BLACK)); - FilterCard filterRed = new FilterCard("red card"); - filterRed.add(new ColorPredicate(ObjectColor.RED)); - FilterCard filterGreen = new FilterCard("green card"); - filterGreen.add(new ColorPredicate(ObjectColor.GREEN)); - TargetCardInLibrary targetWhite = new TargetCardInLibrary(filterWhite); - TargetCardInLibrary targetBlue = new TargetCardInLibrary(filterBlue); - TargetCardInLibrary targetBlack = new TargetCardInLibrary(filterBlack); - TargetCardInLibrary targetRed = new TargetCardInLibrary(filterRed); - TargetCardInLibrary targetGreen = new TargetCardInLibrary(filterGreen); - - if (you != null && you.getLibrary().hasCards()) { - if (you.searchLibrary(targetWhite, source, game)) { - if (!targetWhite.getTargets().isEmpty()) { - for (UUID cardId : targetWhite.getTargets()) { - Card card = you.getLibrary().remove(cardId, game); - if (card != null) { - cards.add(card); - } - } - } - } + public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) { + if (!super.canTarget(playerId, id, source, game)) { + return false; } - if (you != null && you.getLibrary().hasCards()) { - if (you.searchLibrary(targetBlue, source, game)) { - if (!targetBlue.getTargets().isEmpty()) { - for (UUID cardId : targetBlue.getTargets()) { - Card card = you.getLibrary().remove(cardId, game); - if (card != null) { - cards.add(card); - } - } - } - } + Card card = game.getCard(id); + if (card == null) { + return false; } - if (you != null && you.getLibrary().hasCards()) { - if (you.searchLibrary(targetBlack, source, game)) { - if (!targetBlack.getTargets().isEmpty()) { - for (UUID cardId : targetBlack.getTargets()) { - Card card = you.getLibrary().remove(cardId, game); - if (card != null) { - cards.add(card); - } - } - } - } + if (this.getTargets().isEmpty()) { + return true; } - if (you != null && you.getLibrary().hasCards()) { - if (you.searchLibrary(targetRed, source, game)) { - if (!targetRed.getTargets().isEmpty()) { - for (UUID cardId : targetRed.getTargets()) { - Card card = you.getLibrary().remove(cardId, game); - if (card != null) { - cards.add(card); - } - } - } - } - } - if (you != null && you.getLibrary().hasCards()) { - if (you.searchLibrary(targetGreen, source, game)) { - if (!targetGreen.getTargets().isEmpty()) { - for (UUID cardId : targetGreen.getTargets()) { - Card card = you.getLibrary().remove(cardId, game); - if (card != null) { - cards.add(card); - } - } - } - } - } - if (you != null) { - you.revealCards("Conflux", cards, game); - for (Card card : cards.getCards(game)) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - you.shuffleLibrary(source, game); - } - return true; + Cards cards = new CardsImpl(this.getTargets()); + cards.add(card); + return colorAssigner.getRoleCount(cards, game) >= cards.size(); } } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ColorAssignment.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ColorAssignment.java new file mode 100644 index 00000000000..40e012f3907 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ColorAssignment.java @@ -0,0 +1,24 @@ +package mage.abilities.dynamicvalue.common; + +import mage.abilities.dynamicvalue.RoleAssignment; +import mage.cards.Card; +import mage.game.Game; + +import java.util.HashSet; +import java.util.Set; + +public class ColorAssignment extends RoleAssignment { + + public ColorAssignment() { + super("W", "U", "B", "R", "G"); + } + + @Override + protected Set makeSet(Card card, Game game) { + Set strings = new HashSet<>(); + for (char c : card.getColor(game).toString().toCharArray()) { + strings.add("" + c); + } + return strings; + } +}