From d00765c2d5b4c56a6dbcf9ac2db471f6779f5f00 Mon Sep 17 00:00:00 2001
From: Evan Kranzler <theelk801@gmail.com>
Date: Wed, 14 Jul 2021 09:15:41 -0400
Subject: [PATCH] [AFR] Implemented Song of Inspiration

---
 .../src/mage/cards/s/SongOfInspiration.java   | 80 +++++++++++++++++++
 .../mage/sets/ForgottenRealmsCommander.java   |  1 +
 2 files changed, 81 insertions(+)
 create mode 100644 Mage.Sets/src/mage/cards/s/SongOfInspiration.java

diff --git a/Mage.Sets/src/mage/cards/s/SongOfInspiration.java b/Mage.Sets/src/mage/cards/s/SongOfInspiration.java
new file mode 100644
index 0000000000..9ae653357b
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/s/SongOfInspiration.java
@@ -0,0 +1,80 @@
+package mage.cards.s;
+
+import mage.MageObject;
+import mage.abilities.Ability;
+import mage.abilities.effects.OneShotEffect;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.cards.Cards;
+import mage.cards.CardsImpl;
+import mage.constants.CardType;
+import mage.constants.Outcome;
+import mage.constants.Zone;
+import mage.filter.StaticFilters;
+import mage.game.Game;
+import mage.players.Player;
+import mage.target.common.TargetCardInYourGraveyard;
+
+import java.util.UUID;
+
+/**
+ * @author TheElk801
+ */
+public final class SongOfInspiration extends CardImpl {
+
+    public SongOfInspiration(UUID ownerId, CardSetInfo setInfo) {
+        super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{G}{G}");
+
+        // Choose up to two target permanent cards in your graveyard. Roll a d20 and add the total mana value of those cards.
+        // 1-14 | Return those cards to your hand.
+        // 15+ | Return those cards to your hand. You gain life equal to their total mana value.
+        this.getSpellAbility().addEffect(new SongOfInspirationEffect());
+        this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(
+                0, 2, StaticFilters.FILTER_CARD_PERMANENT
+        ));
+    }
+
+    private SongOfInspiration(final SongOfInspiration card) {
+        super(card);
+    }
+
+    @Override
+    public SongOfInspiration copy() {
+        return new SongOfInspiration(this);
+    }
+}
+
+class SongOfInspirationEffect extends OneShotEffect {
+
+    SongOfInspirationEffect() {
+        super(Outcome.Benefit);
+        staticText = "choose up to two target permanent cards in your graveyard. Roll a d20 " +
+                "and add the total mana value of those cards.<br>1-14 | Return those cards to your hand." +
+                "<br>15+ | Return those cards to your hand. You gain life equal to their total mana value";
+    }
+
+    private SongOfInspirationEffect(final SongOfInspirationEffect effect) {
+        super(effect);
+    }
+
+    @Override
+    public SongOfInspirationEffect copy() {
+        return new SongOfInspirationEffect(this);
+    }
+
+    @Override
+    public boolean apply(Game game, Ability source) {
+        Player player = game.getPlayer(source.getControllerId());
+        if (player == null) {
+            return false;
+        }
+        Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source));
+        int totalMv = cards.getCards(game).stream().mapToInt(MageObject::getManaValue).sum();
+        int result = player.rollDice(source, game, 20);
+        player.moveCards(cards, Zone.HAND, source, game);
+        if (result + totalMv >= 15) {
+            player.gainLife(totalMv, game, source);
+        }
+        return true;
+    }
+}
diff --git a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java
index 33e22e7ec9..940fff4aee 100644
--- a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java
+++ b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java
@@ -199,6 +199,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet {
         cards.add(new SetCardInfo("Smoldering Marsh", 262, Rarity.RARE, mage.cards.s.SmolderingMarsh.class));
         cards.add(new SetCardInfo("Sol Ring", 215, Rarity.UNCOMMON, mage.cards.s.SolRing.class));
         cards.add(new SetCardInfo("Solemn Simulacrum", 216, Rarity.RARE, mage.cards.s.SolemnSimulacrum.class));
+        cards.add(new SetCardInfo("Song of Inspiration", 42, Rarity.RARE, mage.cards.s.SongOfInspiration.class));
         cards.add(new SetCardInfo("Spinerock Knoll", 263, Rarity.RARE, mage.cards.s.SpinerockKnoll.class));
         cards.add(new SetCardInfo("Spit Flame", 142, Rarity.RARE, mage.cards.s.SpitFlame.class));
         cards.add(new SetCardInfo("Sram, Senior Edificer", 72, Rarity.RARE, mage.cards.s.SramSeniorEdificer.class));