diff --git a/Mage.Sets/src/mage/cards/c/CharitableLevy.java b/Mage.Sets/src/mage/cards/c/CharitableLevy.java new file mode 100644 index 00000000000..b814b907ea6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CharitableLevy.java @@ -0,0 +1,82 @@ +package mage.cards.c; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.SpellCastAllTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.SourceHasCounterCondition; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.cost.SpellsCostIncreasingAllEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.filter.common.FilterBySubtypeCard; +import mage.filter.predicate.Predicates; +import mage.target.common.TargetCardInLibrary; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class CharitableLevy extends CardImpl { + + private static final FilterCard filter = new FilterCard("noncreature spells"); + + static { + filter.add(Predicates.not(CardType.CREATURE.getPredicate())); + } + + private static final Condition condition = new SourceHasCounterCondition(CounterType.COLLECTION, 3, Integer.MAX_VALUE); + + private static final FilterCard filterPlains = new FilterBySubtypeCard(SubType.PLAINS); + + public CharitableLevy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + + // Noncreature spells cost {1} more to cast. + this.addAbility(new SimpleStaticAbility( + new SpellsCostIncreasingAllEffect(1, filter, TargetController.ANY) + )); + + // Whenever a player casts a noncreature spell, put a collection counter on Charitable Levy. Then if there are three or more collection counters on it, sacrifice it. If you do, draw a card, then you may search your library for a Plains card, put it onto the battlefield tapped, then shuffle. + Ability ability = new SpellCastAllTriggeredAbility( + new AddCountersSourceEffect(CounterType.COLLECTION.createInstance()), + StaticFilters.FILTER_SPELL_A_NON_CREATURE, + false + ); + ability.addEffect(new ConditionalOneShotEffect( + new DoIfCostPaid( + new DrawCardSourceControllerEffect(1), + null, new SacrificeSourceCost(), false + ).addEffect(new SearchLibraryPutInPlayEffect( + new TargetCardInLibrary(filterPlains), + true, false, true + )), + condition, + "Then if there are three or more collection counters on it, sacrifice it. " + + "If you do, draw a card, then you may search your library for a Plains card, " + + "put it onto the battlefield tapped, then shuffle" + )); + this.addAbility(ability); + } + + private CharitableLevy(final CharitableLevy card) { + super(card); + } + + @Override + public CharitableLevy copy() { + return new CharitableLevy(this); + } +} diff --git a/Mage.Sets/src/mage/cards/h/HeartwoodStoryteller.java b/Mage.Sets/src/mage/cards/h/HeartwoodStoryteller.java index 571ed01a50e..e89ca557da5 100644 --- a/Mage.Sets/src/mage/cards/h/HeartwoodStoryteller.java +++ b/Mage.Sets/src/mage/cards/h/HeartwoodStoryteller.java @@ -1,38 +1,39 @@ package mage.cards.h; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; +import mage.abilities.common.SpellCastAllTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; -import mage.constants.Zone; +import mage.constants.SetTargetPointer; +import mage.constants.SubType; +import mage.filter.StaticFilters; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; import mage.players.Player; -import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; /** - * * @author emerald000 */ public final class HeartwoodStoryteller extends CardImpl { public HeartwoodStoryteller(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}"); this.subtype.add(SubType.TREEFOLK); this.power = new MageInt(2); this.toughness = new MageInt(3); // Whenever a player casts a noncreature spell, each of that player's opponents may draw a card. - this.addAbility(new HeartwoodStorytellerTriggeredAbility()); + this.addAbility(new SpellCastAllTriggeredAbility( + new HeartwoodStorytellerEffect(), + StaticFilters.FILTER_SPELL_A_NON_CREATURE, + false, SetTargetPointer.PLAYER + )); } private HeartwoodStoryteller(final HeartwoodStoryteller card) { @@ -45,44 +46,6 @@ public final class HeartwoodStoryteller extends CardImpl { } } -class HeartwoodStorytellerTriggeredAbility extends TriggeredAbilityImpl { - - HeartwoodStorytellerTriggeredAbility() { - super(Zone.BATTLEFIELD, new HeartwoodStorytellerEffect(), false); - } - - private HeartwoodStorytellerTriggeredAbility(final HeartwoodStorytellerTriggeredAbility ability) { - super(ability); - } - - @Override - public HeartwoodStorytellerTriggeredAbility copy() { - return new HeartwoodStorytellerTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.SPELL_CAST; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && !spell.isCreature(game)) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getPlayerId())); - } - return true; - } - return false; - } - - @Override - public String getRule() { - return "Whenever a player casts a noncreature spell, each of that player's opponents may draw a card."; - } -} - class HeartwoodStorytellerEffect extends OneShotEffect { HeartwoodStorytellerEffect() { diff --git a/Mage.Sets/src/mage/cards/r/RuricTharTheUnbowed.java b/Mage.Sets/src/mage/cards/r/RuricTharTheUnbowed.java index 91d301ca279..cc02571346f 100644 --- a/Mage.Sets/src/mage/cards/r/RuricTharTheUnbowed.java +++ b/Mage.Sets/src/mage/cards/r/RuricTharTheUnbowed.java @@ -1,33 +1,29 @@ package mage.cards.r; -import java.util.UUID; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.AttacksEachCombatStaticAbility; -import mage.abilities.effects.Effect; +import mage.abilities.common.SpellCastAllTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.keyword.ReachAbility; import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.SetTargetPointer; import mage.constants.SubType; import mage.constants.SuperType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; -import mage.target.targetpointer.FixedTarget; +import mage.filter.StaticFilters; + +import java.util.UUID; /** - * * @author jeffwadsworth */ public final class RuricTharTheUnbowed extends CardImpl { public RuricTharTheUnbowed(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{G}"); this.supertype.add(SuperType.LEGENDARY); this.subtype.add(SubType.OGRE); this.subtype.add(SubType.WARRIOR); @@ -37,15 +33,19 @@ public final class RuricTharTheUnbowed extends CardImpl { // Vigilance this.addAbility(VigilanceAbility.getInstance()); - + // Reach this.addAbility(ReachAbility.getInstance()); - + // Ruric Thar, the Unbowed attacks each turn if able. this.addAbility(new AttacksEachCombatStaticAbility()); - + // Whenever a player casts a noncreature spell, Ruric Thar deals 6 damage to that player. - this.addAbility(new RuricTharTheUnbowedAbility()); + this.addAbility(new SpellCastAllTriggeredAbility( + new DamageTargetEffect(6), + StaticFilters.FILTER_SPELL_A_NON_CREATURE, + false, SetTargetPointer.PLAYER + )); } private RuricTharTheUnbowed(final RuricTharTheUnbowed card) { @@ -56,42 +56,4 @@ public final class RuricTharTheUnbowed extends CardImpl { public RuricTharTheUnbowed copy() { return new RuricTharTheUnbowed(this); } -} - -class RuricTharTheUnbowedAbility extends TriggeredAbilityImpl { - - public RuricTharTheUnbowedAbility() { - super(Zone.BATTLEFIELD, new DamageTargetEffect(6), false); - } - - private RuricTharTheUnbowedAbility(final RuricTharTheUnbowedAbility ability) { - super(ability); - } - - @Override - public RuricTharTheUnbowedAbility copy() { - return new RuricTharTheUnbowedAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.SPELL_CAST; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && !spell.isCreature(game)) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getPlayerId())); - } - return true; - } - return false; - } - - @Override - public String getRule() { - return "Whenever a player casts a noncreature spell, Ruric Thar deals 6 damage to that player."; - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index 0b1114a0e2e..08614a026f1 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -48,6 +48,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Bridgeworks Battle", 249, Rarity.UNCOMMON, mage.cards.b.BridgeworksBattle.class)); cards.add(new SetCardInfo("Buried Alive", 273, Rarity.UNCOMMON, mage.cards.b.BuriedAlive.class)); cards.add(new SetCardInfo("Cephalid Coliseum", 300, Rarity.UNCOMMON, mage.cards.c.CephalidColiseum.class)); + cards.add(new SetCardInfo("Charitable Levy", 21, Rarity.UNCOMMON, mage.cards.c.CharitableLevy.class)); cards.add(new SetCardInfo("Chthonian Nightmare", 83, Rarity.RARE, mage.cards.c.ChthonianNightmare.class)); cards.add(new SetCardInfo("Collective Resistance", 147, Rarity.UNCOMMON, mage.cards.c.CollectiveResistance.class)); cards.add(new SetCardInfo("Colossal Dreadmask", 148, Rarity.COMMON, mage.cards.c.ColossalDreadmask.class));