From 22946bb35efdbf4e4854141ba70623b164daffc8 Mon Sep 17 00:00:00 2001
From: theelk801 <theelk801@gmail.com>
Date: Sun, 23 Apr 2023 16:48:52 -0400
Subject: [PATCH] [MOC] Implement Path of the Schemer

---
 .../src/mage/cards/p/PathOfTheSchemer.java    | 86 +++++++++++++++++++
 .../mage/sets/MarchOfTheMachineCommander.java |  9 +-
 .../common/WillOfThePlaneswalkersEffect.java  | 12 ++-
 3 files changed, 102 insertions(+), 5 deletions(-)
 create mode 100644 Mage.Sets/src/mage/cards/p/PathOfTheSchemer.java

diff --git a/Mage.Sets/src/mage/cards/p/PathOfTheSchemer.java b/Mage.Sets/src/mage/cards/p/PathOfTheSchemer.java
new file mode 100644
index 0000000000..ee4aaff7dd
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/p/PathOfTheSchemer.java
@@ -0,0 +1,86 @@
+package mage.cards.p;
+
+import mage.MageObjectReference;
+import mage.abilities.Ability;
+import mage.abilities.effects.OneShotEffect;
+import mage.abilities.effects.common.MillCardsEachPlayerEffect;
+import mage.abilities.effects.common.WillOfThePlaneswalkersEffect;
+import mage.abilities.effects.common.continuous.AddCardTypeTargetEffect;
+import mage.cards.Card;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.constants.*;
+import mage.filter.StaticFilters;
+import mage.game.Game;
+import mage.players.Player;
+import mage.target.TargetCard;
+import mage.target.common.TargetCardInGraveyard;
+import mage.target.targetpointer.FixedTarget;
+
+import java.util.UUID;
+
+/**
+ * @author TheElk801
+ */
+public final class PathOfTheSchemer extends CardImpl {
+
+    public PathOfTheSchemer(UUID ownerId, CardSetInfo setInfo) {
+        super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}");
+
+        // Each player mills two cards. Then you put a creature card from a graveyard onto the battlefield under your control. It's an artifact in addition to its other types.
+        this.getSpellAbility().addEffect(new MillCardsEachPlayerEffect(2, TargetController.EACH_PLAYER));
+        this.getSpellAbility().addEffect(new PathOfTheSchemerEffect());
+
+        // Will of the Planeswalkers -- Starting with you, each player votes for planeswalk or chaos. If planeswalk gets more votes, planeswalk. If chaos gets more votes or the vote is tied, chaos ensues.
+        this.getSpellAbility().addEffect(new WillOfThePlaneswalkersEffect());
+    }
+
+    private PathOfTheSchemer(final PathOfTheSchemer card) {
+        super(card);
+    }
+
+    @Override
+    public PathOfTheSchemer copy() {
+        return new PathOfTheSchemer(this);
+    }
+}
+
+class PathOfTheSchemerEffect extends OneShotEffect {
+
+    PathOfTheSchemerEffect() {
+        super(Outcome.Benefit);
+        staticText = "Then you put a creature card from a graveyard onto the battlefield " +
+                "under your control. It's an artifact in addition to its other types";
+    }
+
+    private PathOfTheSchemerEffect(final PathOfTheSchemerEffect effect) {
+        super(effect);
+    }
+
+    @Override
+    public PathOfTheSchemerEffect copy() {
+        return new PathOfTheSchemerEffect(this);
+    }
+
+    @Override
+    public boolean apply(Game game, Ability source) {
+        Player player = game.getPlayer(source.getControllerId());
+        if (player == null) {
+            return false;
+        }
+        TargetCard target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE);
+        target.setNotTarget(true);
+        if (!target.canChoose(source.getControllerId(), source, game)) {
+            return false;
+        }
+        player.choose(Outcome.PutCreatureInPlay, target, source, game);
+        Card card = game.getCard(target.getFirstTarget());
+        if (card == null) {
+            return false;
+        }
+        game.addEffect(new AddCardTypeTargetEffect(Duration.Custom, CardType.ARTIFACT)
+                .setTargetPointer(new FixedTarget(new MageObjectReference(card, game, 1))), source);
+        player.moveCards(card, Zone.BATTLEFIELD, source, game);
+        return true;
+    }
+}
diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java b/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java
index 08df5d1a71..8e8ce84157 100644
--- a/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java
+++ b/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java
@@ -231,10 +231,11 @@ public final class MarchOfTheMachineCommander extends ExpansionSet {
         cards.add(new SetCardInfo("Pain Distributor", 33, Rarity.RARE, mage.cards.p.PainDistributor.class));
         cards.add(new SetCardInfo("Painful Truths", 262, Rarity.RARE, mage.cards.p.PainfulTruths.class));
         cards.add(new SetCardInfo("Path of Ancestry", 418, Rarity.COMMON, mage.cards.p.PathOfAncestry.class));
-        cards.add(new SetCardInfo("Path of the Animist", 38, Rarity.RARE, mage.cards.p.PathOfTheAnimist.class));
-        cards.add(new SetCardInfo("Path of the Enigma", 23, Rarity.RARE, mage.cards.p.PathOfTheEnigma.class));
-        cards.add(new SetCardInfo("Path of the Ghosthunter", 18, Rarity.RARE, mage.cards.p.PathOfTheGhosthunter.class));
-        cards.add(new SetCardInfo("Path of the Pyromancer", 34, Rarity.RARE, mage.cards.p.PathOfThePyromancer.class));
+//        cards.add(new SetCardInfo("Path of the Animist", 38, Rarity.RARE, mage.cards.p.PathOfTheAnimist.class));
+//        cards.add(new SetCardInfo("Path of the Enigma", 23, Rarity.RARE, mage.cards.p.PathOfTheEnigma.class));
+//        cards.add(new SetCardInfo("Path of the Ghosthunter", 18, Rarity.RARE, mage.cards.p.PathOfTheGhosthunter.class));
+//        cards.add(new SetCardInfo("Path of the Pyromancer", 34, Rarity.RARE, mage.cards.p.PathOfThePyromancer.class));
+//        cards.add(new SetCardInfo("Path of the Schemer", 28, Rarity.RARE, mage.cards.p.PathOfTheSchemer.class));
         cards.add(new SetCardInfo("Path to Exile", 198, Rarity.UNCOMMON, mage.cards.p.PathToExile.class));
         cards.add(new SetCardInfo("Perplexing Test", 229, Rarity.RARE, mage.cards.p.PerplexingTest.class));
         cards.add(new SetCardInfo("Phyrexian Delver", 263, Rarity.RARE, mage.cards.p.PhyrexianDelver.class));
diff --git a/Mage/src/main/java/mage/abilities/effects/common/WillOfThePlaneswalkersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/WillOfThePlaneswalkersEffect.java
index 014762f7a0..c023b4d5e1 100644
--- a/Mage/src/main/java/mage/abilities/effects/common/WillOfThePlaneswalkersEffect.java
+++ b/Mage/src/main/java/mage/abilities/effects/common/WillOfThePlaneswalkersEffect.java
@@ -2,6 +2,7 @@ package mage.abilities.effects.common;
 
 import mage.abilities.Ability;
 import mage.abilities.effects.OneShotEffect;
+import mage.choices.TwoChoiceVote;
 import mage.constants.AbilityWord;
 import mage.constants.Outcome;
 import mage.game.Game;
@@ -13,7 +14,7 @@ public class WillOfThePlaneswalkersEffect extends OneShotEffect {
 
     public WillOfThePlaneswalkersEffect() {
         super(Outcome.Benefit);
-        staticText = AbilityWord.WILL_OF_THE_COUNCIL.formatWord() + "Starting with you, each player votes " +
+        staticText = AbilityWord.WILL_OF_THE_PLANESWALKERS.formatWord() + "Starting with you, each player votes " +
                 "for planeswalk or chaos. If planeswalk gets more votes, planeswalk. " +
                 "If chaos gets more votes or the vote is tied, chaos ensues";
         concatBy("<br>");
@@ -30,7 +31,16 @@ public class WillOfThePlaneswalkersEffect extends OneShotEffect {
 
     @Override
     public boolean apply(Game game, Ability source) {
+        TwoChoiceVote vote = new TwoChoiceVote("Planeswalk", "Chaos", Outcome.Benefit);
+        vote.doVotes(source, game);
+        int planeswalkCount = vote.getVoteCount(true);
+        int chaosCount = vote.getVoteCount(false);
         // TODO: Implement when planes have been refactored
+        if (planeswalkCount > chaosCount) {
+            // planeswalk to next plane
+        } else {
+            // chaos ensues
+        }
         return true;
     }
 }