From 16a96fa8a80c59f90e4598b5061014a21322a0d8 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sun, 18 Jun 2023 21:01:49 -0400 Subject: [PATCH] [LTR] Implement Merry, Esquire of Rohan --- .../src/mage/cards/m/MerryEsquireOfRohan.java | 98 +++++++++++++++++++ .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + 2 files changed, 99 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MerryEsquireOfRohan.java diff --git a/Mage.Sets/src/mage/cards/m/MerryEsquireOfRohan.java b/Mage.Sets/src/mage/cards/m/MerryEsquireOfRohan.java new file mode 100644 index 0000000000..eb69802bf2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MerryEsquireOfRohan.java @@ -0,0 +1,98 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.EquippedSourceCondition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.HasteAbility; +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.GameEvent; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MerryEsquireOfRohan extends CardImpl { + + public MerryEsquireOfRohan(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HALFLING); + this.subtype.add(SubType.KNIGHT); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Merry, Esquire of Rohan has first strike as long as it's equipped. + this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect( + new GainAbilitySourceEffect(FirstStrikeAbility.getInstance()), + EquippedSourceCondition.instance, "{this} has first strike as long as it's equipped" + ))); + + // Whenever you attack with Merry and another legendary creature, draw a card. + this.addAbility(new MerryEsquireOfRohanTriggeredAbility()); + } + + private MerryEsquireOfRohan(final MerryEsquireOfRohan card) { + super(card); + } + + @Override + public MerryEsquireOfRohan copy() { + return new MerryEsquireOfRohan(this); + } +} + +class MerryEsquireOfRohanTriggeredAbility extends TriggeredAbilityImpl { + + MerryEsquireOfRohanTriggeredAbility() { + super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1)); + this.setTriggerPhrase("Whenever you attack with {this} and another legendary creature, "); + } + + private MerryEsquireOfRohanTriggeredAbility(final MerryEsquireOfRohanTriggeredAbility ability) { + super(ability); + } + + @Override + public MerryEsquireOfRohanTriggeredAbility copy() { + return new MerryEsquireOfRohanTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return game + .getCombat() + .getAttackers() + .contains(getSourceId()) + && game + .getCombat() + .getAttackers() + .stream() + .filter(uuid -> !getSourceId().equals(uuid)) + .map(game::getPermanent) + .filter(Objects::nonNull) + .filter(permanent -> permanent.isLegendary(game)) + .anyMatch(permanent -> permanent.isCreature(game)); + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index a758ba1ec8..cf668e0e0a 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -150,6 +150,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("March from the Black Gate", 94, Rarity.UNCOMMON, mage.cards.m.MarchFromTheBlackGate.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("Merry, Esquire of Rohan", 215, Rarity.RARE, mage.cards.m.MerryEsquireOfRohan.class)); cards.add(new SetCardInfo("Minas Tirith", 256, Rarity.RARE, mage.cards.m.MinasTirith.class)); cards.add(new SetCardInfo("Mines of Moria", 257, Rarity.RARE, mage.cards.m.MinesOfMoria.class)); cards.add(new SetCardInfo("Mirkwood Bats", 95, Rarity.COMMON, mage.cards.m.MirkwoodBats.class));