diff --git a/Mage.Sets/src/mage/cards/d/DruidOfHorns.java b/Mage.Sets/src/mage/cards/d/DruidOfHorns.java new file mode 100644 index 00000000000..2478e7fd172 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DruidOfHorns.java @@ -0,0 +1,106 @@ +package mage.cards.d; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Mode; +import mage.abilities.SpellAbility; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.token.BeastToken; +import mage.game.stack.Spell; +import mage.target.Target; + +/** + * + * @author TheElk801 + */ +public final class DruidOfHorns extends CardImpl { + + public DruidOfHorns(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.DRUID); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Whenever you cast an Aura spell that targets Druid of Horns, create a 3/3 green Beast creature token. + this.addAbility(new DruidOfHornsTriggeredAbility()); + } + + public DruidOfHorns(final DruidOfHorns card) { + super(card); + } + + @Override + public DruidOfHorns copy() { + return new DruidOfHorns(this); + } +} + +class DruidOfHornsTriggeredAbility extends TriggeredAbilityImpl { + + public DruidOfHornsTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new BeastToken()), false); + } + + public DruidOfHornsTriggeredAbility(final DruidOfHornsTriggeredAbility ability) { + super(ability); + } + + @Override + public DruidOfHornsTriggeredAbility copy() { + return new DruidOfHornsTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getPlayerId().equals(this.getControllerId())) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (checkSpell(spell, game)) { + return true; + } + } + return false; + } + + private boolean checkSpell(Spell spell, Game game) { + if (spell != null && spell.hasSubtype(SubType.AURA, game)) { + SpellAbility sa = spell.getSpellAbility(); + for (UUID modeId : sa.getModes().getSelectedModes()) { + Mode mode = sa.getModes().get(modeId); + for (Target target : mode.getTargets()) { + if (!target.isNotTarget() && target.getTargets().contains(this.getSourceId())) { + return true; + } + } + for (Effect effect : mode.getEffects()) { + for (UUID targetId : effect.getTargetPointer().getTargets(game, sa)) { + if (targetId.equals(this.getSourceId())) { + return true; + } + } + } + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever you cast an Aura spell that targets {this}, " + super.getRule(); + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2019.java b/Mage.Sets/src/mage/sets/CoreSet2019.java index f414160956a..4f7ae769be0 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2019.java +++ b/Mage.Sets/src/mage/sets/CoreSet2019.java @@ -85,6 +85,7 @@ public final class CoreSet2019 extends ExpansionSet { cards.add(new SetCardInfo("Djinn of Wishes", 52, Rarity.RARE, mage.cards.d.DjinnOfWishes.class)); cards.add(new SetCardInfo("Draconic Disciple", 215, Rarity.UNCOMMON, mage.cards.d.DraconicDisciple.class)); cards.add(new SetCardInfo("Dragon's Hoard", 232, Rarity.RARE, mage.cards.d.DragonsHoard.class)); + cards.add(new SetCardInfo("Druid of Horns", 176, Rarity.UNCOMMON, mage.cards.d.DruidOfHorns.class)); cards.add(new SetCardInfo("Druid of the Cowl", 177, Rarity.COMMON, mage.cards.d.DruidOfTheCowl.class)); cards.add(new SetCardInfo("Dryad Greenseeker", 178, Rarity.UNCOMMON, mage.cards.d.DryadGreenseeker.class)); cards.add(new SetCardInfo("Dwarven Priest", 11, Rarity.COMMON, mage.cards.d.DwarvenPriest.class));