diff --git a/Mage.Sets/src/mage/cards/m/MeriadocBrandybuck.java b/Mage.Sets/src/mage/cards/m/MeriadocBrandybuck.java new file mode 100644 index 0000000000..cde68efd66 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MeriadocBrandybuck.java @@ -0,0 +1,77 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.DefenderAttackedEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.token.FoodToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MeriadocBrandybuck extends CardImpl { + + public MeriadocBrandybuck(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HALFLING); + this.subtype.add(SubType.CITIZEN); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever one or more Halflings you control attack a player, create a Food token. + this.addAbility(new MeriadocBrandybuckTriggeredAbility()); + } + + private MeriadocBrandybuck(final MeriadocBrandybuck card) { + super(card); + } + + @Override + public MeriadocBrandybuck copy() { + return new MeriadocBrandybuck(this); + } +} + +class MeriadocBrandybuckTriggeredAbility extends TriggeredAbilityImpl { + + MeriadocBrandybuckTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new FoodToken())); + setTriggerPhrase("Whenever one or more Halflings you control attack a player, "); + } + + private MeriadocBrandybuckTriggeredAbility(final MeriadocBrandybuckTriggeredAbility ability) { + super(ability); + } + + @Override + public MeriadocBrandybuckTriggeredAbility copy() { + return new MeriadocBrandybuckTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DEFENDER_ATTACKED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return isControlledBy(event.getPlayerId()) + && game.getPlayer(event.getTargetId()) != null + && ((DefenderAttackedEvent) event) + .getAttackers(game) + .stream() + .anyMatch(permanent -> permanent.hasSubtype(SubType.HALFLING, game)); + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index e340895360..60aae96cd7 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -56,6 +56,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Long List of the Ents", 174, Rarity.UNCOMMON, mage.cards.l.LongListOfTheEnts.class)); cards.add(new SetCardInfo("Many Partings", 176, Rarity.COMMON, mage.cards.m.ManyPartings.class)); cards.add(new SetCardInfo("Mauhur, Uruk-hai Captain", 214, Rarity.UNCOMMON, mage.cards.m.MauhurUrukHaiCaptain.class)); + cards.add(new SetCardInfo("Meriadoc Brandybuck", 177, Rarity.UNCOMMON, mage.cards.m.MeriadocBrandybuck.class)); cards.add(new SetCardInfo("Mount Doom", 258, Rarity.MYTHIC, mage.cards.m.MountDoom.class)); cards.add(new SetCardInfo("Mountain", 268, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Nazgul", 100, Rarity.UNCOMMON, mage.cards.n.Nazgul.class));