From 2f16054f6a1b2bd1ce28872917df8d034d39e73e Mon Sep 17 00:00:00 2001
From: Evan Kranzler <theelk801@gmail.com>
Date: Sat, 25 May 2019 15:37:27 -0400
Subject: [PATCH] Implemented Giver of Runes

---
 Mage.Sets/src/mage/cards/g/GiverOfRunes.java | 100 +++++++++++++++++++
 Mage.Sets/src/mage/sets/ModernHorizons.java  |   1 +
 2 files changed, 101 insertions(+)
 create mode 100644 Mage.Sets/src/mage/cards/g/GiverOfRunes.java

diff --git a/Mage.Sets/src/mage/cards/g/GiverOfRunes.java b/Mage.Sets/src/mage/cards/g/GiverOfRunes.java
new file mode 100644
index 0000000000..b7ba145087
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/g/GiverOfRunes.java
@@ -0,0 +1,100 @@
+package mage.cards.g;
+
+import mage.MageInt;
+import mage.abilities.Ability;
+import mage.abilities.common.SimpleActivatedAbility;
+import mage.abilities.costs.common.TapSourceCost;
+import mage.abilities.effects.OneShotEffect;
+import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
+import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect;
+import mage.abilities.keyword.ProtectionAbility;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.constants.CardType;
+import mage.constants.Duration;
+import mage.constants.Outcome;
+import mage.constants.SubType;
+import mage.filter.FilterObject;
+import mage.filter.FilterPermanent;
+import mage.filter.common.FilterControlledCreaturePermanent;
+import mage.filter.predicate.mageobject.ColorlessPredicate;
+import mage.filter.predicate.permanent.AnotherPredicate;
+import mage.game.Game;
+import mage.players.Player;
+import mage.target.TargetPermanent;
+
+import java.util.UUID;
+
+/**
+ * @author TheElk801
+ */
+public final class GiverOfRunes extends CardImpl {
+
+    private static final FilterPermanent filter
+            = new FilterControlledCreaturePermanent("another creature you control");
+
+    static {
+        filter.add(AnotherPredicate.instance);
+    }
+
+    public GiverOfRunes(UUID ownerId, CardSetInfo setInfo) {
+        super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}");
+
+        this.subtype.add(SubType.KOR);
+        this.subtype.add(SubType.CLERIC);
+        this.power = new MageInt(1);
+        this.toughness = new MageInt(2);
+
+        // {T}: Another target creature you control gains protection from colorless or from the color of your choice until end of turn.
+        Ability ability = new SimpleActivatedAbility(new GiverOfRunesEffect(), new TapSourceCost());
+        ability.addTarget(new TargetPermanent(filter));
+        this.addAbility(ability);
+    }
+
+    private GiverOfRunes(final GiverOfRunes card) {
+        super(card);
+    }
+
+    @Override
+    public GiverOfRunes copy() {
+        return new GiverOfRunes(this);
+    }
+}
+
+class GiverOfRunesEffect extends OneShotEffect {
+
+    private static final FilterObject filter = new FilterObject("colorless");
+
+    static {
+        filter.add(ColorlessPredicate.instance);
+    }
+
+    GiverOfRunesEffect() {
+        super(Outcome.Benefit);
+        staticText = "Another target creature you control gains protection from colorless " +
+                "or from the color of your choice until end of turn.";
+    }
+
+    private GiverOfRunesEffect(final GiverOfRunesEffect effect) {
+        super(effect);
+    }
+
+    @Override
+    public GiverOfRunesEffect copy() {
+        return new GiverOfRunesEffect(this);
+    }
+
+    @Override
+    public boolean apply(Game game, Ability source) {
+        Player player = game.getPlayer(source.getControllerId());
+        if (player == null) {
+            return false;
+        }
+        if (player.chooseUse(outcome, "Give the targeted creature protection from colorless?", null, "Yes", "No (choose a color instead)", source, game)) {
+            game.addEffect(new GainAbilityTargetEffect(new ProtectionAbility(filter), Duration.EndOfTurn), source);
+            return true;
+        }
+        game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
+        return true;
+    }
+}
diff --git a/Mage.Sets/src/mage/sets/ModernHorizons.java b/Mage.Sets/src/mage/sets/ModernHorizons.java
index 3da8faea4d..ac5ea35143 100644
--- a/Mage.Sets/src/mage/sets/ModernHorizons.java
+++ b/Mage.Sets/src/mage/sets/ModernHorizons.java
@@ -61,6 +61,7 @@ public final class ModernHorizons extends ExpansionSet {
         cards.add(new SetCardInfo("Frostwalk Bastion", 240, Rarity.UNCOMMON, mage.cards.f.FrostwalkBastion.class));
         cards.add(new SetCardInfo("Generous Gift", 11, Rarity.UNCOMMON, mage.cards.g.GenerousGift.class));
         cards.add(new SetCardInfo("Genesis", 166, Rarity.RARE, mage.cards.g.Genesis.class));
+        cards.add(new SetCardInfo("Giver of Runes", 13, Rarity.RARE, mage.cards.g.GiverOfRunes.class));
         cards.add(new SetCardInfo("Glacial Revelation", 167, Rarity.UNCOMMON, mage.cards.g.GlacialRevelation.class));
         cards.add(new SetCardInfo("Goatnap", 126, Rarity.COMMON, mage.cards.g.Goatnap.class));
         cards.add(new SetCardInfo("Goblin Engineer", 128, Rarity.RARE, mage.cards.g.GoblinEngineer.class));