diff --git a/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java b/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java new file mode 100644 index 00000000000..99b93e54006 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java @@ -0,0 +1,75 @@ +package mage.cards.o; + +import mage.MageInt; +import mage.abilities.common.DiesSourceTriggeredAbility; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.PutCounterOnCreatureTriggeredAbility; +import mage.abilities.dynamicvalue.common.CountersSourceCount; +import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.keyword.ManifestEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.filter.predicate.mageobject.ColorlessPredicate; + +import java.util.UUID; + +/** + * + * @author Susucr + */ +public final class OmarthisGhostfireInitiate extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another colorless creature"); + + static { + filter.add(AnotherPredicate.instance); + filter.add(ColorlessPredicate.instance); + } + + public OmarthisGhostfireInitiate(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{X}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.SPIRIT); + this.subtype.add(SubType.NAGA); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // Omarthis, Ghostfire Initiate enters the battlefield with X +1/+1 counters on it. + this.addAbility(new EntersBattlefieldAbility( + new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance()) + )); + + // Whenever you put one or more +1/+1 counters on another colorless creature, you may put a +1/+1 counter on Omarthis. + this.addAbility( + new PutCounterOnCreatureTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), + CounterType.P1P1.createInstance(), filter, + false, true + ) + ); + + // When Omarthis dies, manifest a number of cards from the top of your library equal to the number of counters on it. + this.addAbility(new DiesSourceTriggeredAbility( + new ManifestEffect(new CountersSourceCount(null)) + .setText("manifest a number of cards from the top of your library equal to the number of counters on it."), + false + )); + } + + private OmarthisGhostfireInitiate(final OmarthisGhostfireInitiate card) { + super(card); + } + + @Override + public OmarthisGhostfireInitiate copy() { + return new OmarthisGhostfireInitiate(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderMasters.java b/Mage.Sets/src/mage/sets/CommanderMasters.java index 46c76e9b72a..f3ee7f6c8bc 100644 --- a/Mage.Sets/src/mage/sets/CommanderMasters.java +++ b/Mage.Sets/src/mage/sets/CommanderMasters.java @@ -446,6 +446,7 @@ public final class CommanderMasters extends ExpansionSet { cards.add(new SetCardInfo("Odric, Master Tactician", 46, Rarity.RARE, mage.cards.o.OdricMasterTactician.class)); cards.add(new SetCardInfo("Ogre Slumlord", 177, Rarity.RARE, mage.cards.o.OgreSlumlord.class)); cards.add(new SetCardInfo("Ohran Frostfang", 309, Rarity.RARE, mage.cards.o.OhranFrostfang.class)); + cards.add(new SetCardInfo("Omarthis, Ghostfire Initiate", 708, Rarity.MYTHIC, mage.cards.o.OmarthisGhostfireInitiate.class)); cards.add(new SetCardInfo("Omen of the Hunt", 906, Rarity.COMMON, mage.cards.o.OmenOfTheHunt.class)); cards.add(new SetCardInfo("Omen of the Sun", 831, Rarity.COMMON, mage.cards.o.OmenOfTheSun.class)); cards.add(new SetCardInfo("Omnath, Locus of Mana", 310, Rarity.MYTHIC, mage.cards.o.OmnathLocusOfMana.class)); diff --git a/Mage/src/main/java/mage/abilities/common/PutCounterOnCreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/PutCounterOnCreatureTriggeredAbility.java index a2c287529e8..ca348531b78 100644 --- a/Mage/src/main/java/mage/abilities/common/PutCounterOnCreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/PutCounterOnCreatureTriggeredAbility.java @@ -39,16 +39,17 @@ public class PutCounterOnCreatureTriggeredAbility extends TriggeredAbilityImpl { } public PutCounterOnCreatureTriggeredAbility(Effect effect, Counter counter, FilterPermanent filter, boolean setTargetPointer) { - super(Zone.BATTLEFIELD, effect); + this(effect, counter, filter, setTargetPointer, false); + } + + + public PutCounterOnCreatureTriggeredAbility(Effect effect, Counter counter, FilterPermanent filter, boolean setTargetPointer, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); this.counterType = counter; this.filter = filter; this.setTargetPointer = setTargetPointer; - if (counter == null) { - setTriggerPhrase("Whenever you put one or more counters on a " + filter.getMessage() + ", "); - } - else { - setTriggerPhrase("Whenever you put one or more " + counter.getName() + " counters on a " + filter.getMessage() + ", "); - } + + setFilterMessage(); } public PutCounterOnCreatureTriggeredAbility(final PutCounterOnCreatureTriggeredAbility ability) { @@ -89,4 +90,17 @@ public class PutCounterOnCreatureTriggeredAbility extends TriggeredAbilityImpl { getEffects().setValue("countersAdded", event.getAmount()); return true; } + + private void setFilterMessage() { + String filterMessage = filter.getMessage(); + if (!filterMessage.startsWith("another")) { + filterMessage = "a " + filterMessage; + } + + if (this.counterType == null) { + setTriggerPhrase("Whenever you put one or more counters on " + filterMessage + ", "); + } else { + setTriggerPhrase("Whenever you put one or more " + this.counterType.getName() + " counters on " + filterMessage + ", "); + } + } } diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/ManifestEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/ManifestEffect.java index 09d4f45b869..102b40239b4 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/ManifestEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/ManifestEffect.java @@ -5,6 +5,8 @@ import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect; import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType; @@ -20,22 +22,32 @@ import mage.util.CardUtil; import java.util.Set; /** - * * @author LevelX2 */ public class ManifestEffect extends OneShotEffect { - private final int amount; + private final DynamicValue amount; + private final boolean isPlural; public ManifestEffect(int amount) { + this(StaticValue.get(amount), amount > 1); + } + + public ManifestEffect(DynamicValue amount) { + this(amount, true); + } + + private ManifestEffect(DynamicValue amount, boolean isPlural) { super(Outcome.PutCreatureInPlay); this.amount = amount; + this.isPlural = isPlural; this.staticText = setText(); } - public ManifestEffect(final ManifestEffect effect) { + private ManifestEffect(final ManifestEffect effect) { super(effect); this.amount = effect.amount; + this.isPlural = effect.isPlural; } @Override @@ -49,7 +61,8 @@ public class ManifestEffect extends OneShotEffect { if (controller != null) { Ability newSource = source.copy(); newSource.setWorksFaceDown(true); - Set cards = controller.getLibrary().getTopCards(game, amount); + int value = amount.calculate(game, source, this); + Set cards = controller.getLibrary().getTopCards(game, value); for (Card card : cards) { ManaCosts manaCosts = null; if (card.isCreature(game)) { @@ -76,13 +89,13 @@ public class ManifestEffect extends OneShotEffect { private String setText() { StringBuilder sb = new StringBuilder("manifest the top "); - if (amount > 1) { - sb.append(CardUtil.numberToText(amount)).append(" cards "); + if (isPlural) { + sb.append(CardUtil.numberToText(amount.toString())).append(" cards "); } else { sb.append("card "); } sb.append("of your library. "); - if (amount > 1) { + if (isPlural) { sb.append("(To manifest a card, put it onto the battlefield face down as a 2/2 creature. You may turn it face up at any time for its mana cost if it's a creature card.)"); } else { sb.append("(Put it onto the battlefield face down as a 2/2 creature. Turn it face up at any time for its mana cost if it's a creature card.)");