diff --git a/Mage.Sets/src/mage/cards/d/DawnBlessedPennant.java b/Mage.Sets/src/mage/cards/d/DawnBlessedPennant.java new file mode 100644 index 00000000000..6fe8e20d01f --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DawnBlessedPennant.java @@ -0,0 +1,67 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.ChosenSubtypePredicate; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DawnBlessedPennant extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledPermanent("a permanent you control of the chosen type"); + private static final FilterCard filter2 = new FilterCard("card of the chosen type from your graveyard"); + + static { + filter.add(ChosenSubtypePredicate.TRUE); + filter2.add(ChosenSubtypePredicate.TRUE); + } + + public DawnBlessedPennant(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + + // As this artifact enters, choose Elemental, Elf, Faerie, Giant, Goblin, Kithkin, Merfolk, or Treefolk. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect( + Outcome.Benefit, SubType.ELEMENTAL, SubType.ELF, SubType.FAERIE, SubType.GIANT, + SubType.GOBLIN, SubType.KITHKIN, SubType.MERFOLK, SubType.TREEFOLK + ))); + + // Whenever a permanent you control of the chosen type enters, you gain 1 life. + this.addAbility(new EntersBattlefieldAllTriggeredAbility(new GainLifeEffect(1), filter)); + + // {2}, {T}, Sacrifice this artifact: Return target card of the chosen type from your graveyard to your hand. + Ability ability = new SimpleActivatedAbility(new ReturnFromGraveyardToHandTargetEffect(), new GenericManaCost(2)); + ability.addCost(new TapSourceCost()); + ability.addCost(new SacrificeSourceCost()); + ability.addTarget(new TargetCardInYourGraveyard(filter2)); + this.addAbility(ability); + } + + private DawnBlessedPennant(final DawnBlessedPennant card) { + super(card); + } + + @Override + public DawnBlessedPennant copy() { + return new DawnBlessedPennant(this); + } +} diff --git a/Mage.Sets/src/mage/sets/LorwynEclipsed.java b/Mage.Sets/src/mage/sets/LorwynEclipsed.java index 7786292b08e..94ab632cb47 100644 --- a/Mage.Sets/src/mage/sets/LorwynEclipsed.java +++ b/Mage.Sets/src/mage/sets/LorwynEclipsed.java @@ -111,6 +111,7 @@ public final class LorwynEclipsed extends ExpansionSet { cards.add(new SetCardInfo("Curious Colossus", 298, Rarity.MYTHIC, mage.cards.c.CuriousColossus.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Darkness Descends", 97, Rarity.UNCOMMON, mage.cards.d.DarknessDescends.class)); cards.add(new SetCardInfo("Dawn's Light Archer", 174, Rarity.COMMON, mage.cards.d.DawnsLightArcher.class)); + cards.add(new SetCardInfo("Dawn-Blessed Pennant", 254, Rarity.UNCOMMON, mage.cards.d.DawnBlessedPennant.class)); cards.add(new SetCardInfo("Dawnhand Eulogist", 99, Rarity.COMMON, mage.cards.d.DawnhandEulogist.class)); cards.add(new SetCardInfo("Deceit", 212, Rarity.MYTHIC, mage.cards.d.Deceit.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Deceit", 293, Rarity.MYTHIC, mage.cards.d.Deceit.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java index 5ff422fa9fb..7b62317e94e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java @@ -12,6 +12,8 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; /** @@ -19,9 +21,18 @@ import java.util.UUID; */ public class ChooseCreatureTypeEffect extends OneShotEffect { - public ChooseCreatureTypeEffect(Outcome outcome) { + private final List subTypes = new ArrayList<>(); + + public ChooseCreatureTypeEffect(Outcome outcome, SubType... subTypes) { super(outcome); - staticText = "choose a creature type"; + for (SubType subType : subTypes) { + this.subTypes.add(subType); + } + if (this.subTypes.isEmpty()) { + staticText = "choose a creature type"; + } else { + staticText = "choose " + CardUtil.concatWithOr(this.subTypes); + } } protected ChooseCreatureTypeEffect(final ChooseCreatureTypeEffect effect) { @@ -35,20 +46,19 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { if (mageObject == null) { mageObject = game.getObject(source); } - if (controller != null && mageObject != null) { - Choice typeChoice = new ChoiceCreatureType(game, source); - if (controller.choose(outcome, typeChoice, game)) { - if (!game.isSimulation()) { - game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoiceKey()); - } - game.getState().setValue(source.getSourceId() + "_type", SubType.byDescription(typeChoice.getChoiceKey())); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoiceKey()), game); - } - return true; - } + if (controller == null || mageObject == null) { + return false; } - return false; + Choice typeChoice = new ChoiceCreatureType(game, source, true, "Choose a creature type", subTypes); + if (!controller.choose(outcome, typeChoice, game)) { + return false; + } + game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoiceKey()); + game.getState().setValue(source.getSourceId() + "_type", SubType.byDescription(typeChoice.getChoiceKey())); + if (mageObject instanceof Permanent) { + ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoiceKey()), game); + } + return true; } @Override @@ -61,10 +71,10 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { } /** - * @param objectId sourceId the effect was executed under + * @param objectId sourceId the effect was executed under * @param game * @param typePostfix special postfix if you want to store multiple choices - * from different effects + * from different effects * @return */ public static SubType getChosenCreatureType(UUID objectId, Game game, String typePostfix) { diff --git a/Mage/src/main/java/mage/choices/ChoiceCreatureType.java b/Mage/src/main/java/mage/choices/ChoiceCreatureType.java index 7a71402bd62..74fad3db095 100644 --- a/Mage/src/main/java/mage/choices/ChoiceCreatureType.java +++ b/Mage/src/main/java/mage/choices/ChoiceCreatureType.java @@ -6,7 +6,10 @@ import mage.constants.SubType; import mage.game.Game; import mage.players.Player; -import java.util.*; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; /** @@ -23,19 +26,25 @@ public class ChoiceCreatureType extends ChoiceImpl { } public ChoiceCreatureType(Game game, Ability source, boolean required, String chooseMessage) { + this(game, source, required, chooseMessage, null); + } + + public ChoiceCreatureType(Game game, Ability source, boolean required, String chooseMessage, Collection subTypes) { super(required); this.setMessage(chooseMessage); MageObject sourceObject = source == null ? null : game.getObject(source); if (sourceObject != null) { this.setSubMessage(sourceObject.getLogName()); } - this.setSearchEnabled(true); + this.setSearchEnabled(true); // collect basic info // additional info will be added onChooseStart - SubType.getCreatureTypes().stream().map(SubType::toString).forEach(value -> { - this.withItem(value, value, null, null, null); - }); + ((subTypes == null || subTypes.isEmpty()) + ? SubType.getCreatureTypes() : subTypes) + .stream() + .map(SubType::toString) + .forEach(value -> this.withItem(value, value, null, null, null)); } protected ChoiceCreatureType(final ChoiceCreatureType choice) { diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 49b4e4e0a73..5ea92eb24ad 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -2199,20 +2199,20 @@ public final class CardUtil { return "T" + gameState.getTurnNum() + "." + gameState.getTurn().getStep().getType().getStepShortText(); } - public static String concatWithOr(List strings) { + public static String concatWithOr(List strings) { return concatWith(strings, "or"); } - public static String concatWithAnd(List strings) { + public static String concatWithAnd(List strings) { return concatWith(strings, "and"); } - private static String concatWith(List strings, String last) { + private static String concatWith(List strings, String last) { switch (strings.size()) { case 0: return ""; case 1: - return strings.get(0); + return strings.get(0).toString(); case 2: return strings.get(0) + " " + last + " " + strings.get(1); }