From 972d8fb324828647153bfa88d62483e7b948c33d Mon Sep 17 00:00:00 2001
From: theelk801 <theelk801@gmail.com>
Date: Thu, 8 Jun 2023 20:46:20 -0400
Subject: [PATCH] [LTR] Implement Dunedain Rangers

---
 .../src/mage/cards/d/DunedainRangers.java     | 60 +++++++++++++++++++
 .../TheLordOfTheRingsTalesOfMiddleEarth.java  |  1 +
 .../permanent/RingBearerPredicate.java        | 17 ++++++
 3 files changed, 78 insertions(+)
 create mode 100644 Mage.Sets/src/mage/cards/d/DunedainRangers.java
 create mode 100644 Mage/src/main/java/mage/filter/predicate/permanent/RingBearerPredicate.java

diff --git a/Mage.Sets/src/mage/cards/d/DunedainRangers.java b/Mage.Sets/src/mage/cards/d/DunedainRangers.java
new file mode 100644
index 0000000000..49cf41e7eb
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/d/DunedainRangers.java
@@ -0,0 +1,60 @@
+package mage.cards.d;
+
+import mage.MageInt;
+import mage.abilities.common.LandfallAbility;
+import mage.abilities.condition.Condition;
+import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
+import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
+import mage.abilities.effects.keyword.TheRingTemptsYouEffect;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.constants.AbilityWord;
+import mage.constants.CardType;
+import mage.constants.ComparisonType;
+import mage.constants.SubType;
+import mage.filter.FilterPermanent;
+import mage.filter.common.FilterControlledPermanent;
+import mage.filter.predicate.permanent.RingBearerPredicate;
+
+import java.util.UUID;
+
+/**
+ * @author TheElk801
+ */
+public final class DunedainRangers extends CardImpl {
+
+    private static final FilterPermanent filter = new FilterControlledPermanent();
+
+    static {
+        filter.add(RingBearerPredicate.instance);
+    }
+
+    private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
+            filter, ComparisonType.EQUAL_TO, 0
+    );
+
+    public DunedainRangers(UUID ownerId, CardSetInfo setInfo) {
+        super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
+
+        this.subtype.add(SubType.HUMAN);
+        this.subtype.add(SubType.RANGER);
+        this.power = new MageInt(4);
+        this.toughness = new MageInt(4);
+
+        // Landfall -- Whenever a land enters the battlefield under your control, if you don't control a Ring-bearer, the Ring tempts you.
+        this.addAbility(new ConditionalInterveningIfTriggeredAbility(
+                new LandfallAbility(new TheRingTemptsYouEffect()),
+                condition, "Whenever a land enters the battlefield under your control, " +
+                "if you don't control a Ring-bearer, the Ring tempts you."
+        ).setAbilityWord(AbilityWord.LANDFALL));
+    }
+
+    private DunedainRangers(final DunedainRangers card) {
+        super(card);
+    }
+
+    @Override
+    public DunedainRangers copy() {
+        return new DunedainRangers(this);
+    }
+}
diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java
index 7df094c33a..b0bf7a5f4f 100644
--- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java
+++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java
@@ -38,6 +38,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
         cards.add(new SetCardInfo("Council's Deliberation", 46, Rarity.UNCOMMON, mage.cards.c.CouncilsDeliberation.class));
         cards.add(new SetCardInfo("Display of Power", 119, Rarity.RARE, mage.cards.d.DisplayOfPower.class));
         cards.add(new SetCardInfo("Dunedain Blade", 6, Rarity.COMMON, mage.cards.d.DunedainBlade.class));
+        cards.add(new SetCardInfo("Dunedain Rangers", 159, Rarity.UNCOMMON, mage.cards.d.DunedainRangers.class));
         cards.add(new SetCardInfo("Dunland Crebain", 82, Rarity.COMMON, mage.cards.d.DunlandCrebain.class));
         cards.add(new SetCardInfo("Eagles of the North", 7, Rarity.COMMON, mage.cards.e.EaglesOfTheNorth.class));
         cards.add(new SetCardInfo("Easterling Vanguard", 83, Rarity.COMMON, mage.cards.e.EasterlingVanguard.class));
diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/RingBearerPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/RingBearerPredicate.java
new file mode 100644
index 0000000000..58cb8df0ec
--- /dev/null
+++ b/Mage/src/main/java/mage/filter/predicate/permanent/RingBearerPredicate.java
@@ -0,0 +1,17 @@
+package mage.filter.predicate.permanent;
+
+import mage.filter.predicate.Predicate;
+import mage.game.Game;
+import mage.game.permanent.Permanent;
+
+/**
+ * @author TheElk801
+ */
+public enum RingBearerPredicate implements Predicate<Permanent> {
+    instance;
+
+    @Override
+    public boolean apply(Permanent input, Game game) {
+        return input.isRingBearer(game);
+    }
+}