From fe0717cbc7cfbf598771a1b74efa0094628f1adb Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 12 Jan 2020 11:19:17 +0400 Subject: [PATCH] * Goblin Clearcutter - fixed that tapped for mana replacement effects ignore his mana; --- .../src/mage/cards/g/GoblinClearcutter.java | 48 +++++++++++-------- .../src/mage/cards/o/OrcishLumberjack.java | 9 ++-- .../TappedForManaFromMultipleEffects.java | 41 ++++++++++++++++ 3 files changed, 73 insertions(+), 25 deletions(-) diff --git a/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java b/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java index 3c412f53158..959d32c96a3 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java +++ b/Mage.Sets/src/mage/cards/g/GoblinClearcutter.java @@ -1,16 +1,12 @@ - package mage.cards.g; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.Ability; -import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ManaEffect; +import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.choices.Choice; @@ -24,6 +20,8 @@ import mage.game.Game; import mage.players.Player; import mage.target.common.TargetControlledPermanent; +import java.util.*; + /** * @author BursegSardaukar */ @@ -43,7 +41,7 @@ public final class GoblinClearcutter extends CardImpl { this.toughness = new MageInt(3); // {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G}. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinClearCutterEffect(), new TapSourceCost()); + Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new GoblinClearCutterManaEffect(), new TapSourceCost()); ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); this.addAbility(ability); } @@ -58,24 +56,37 @@ public final class GoblinClearcutter extends CardImpl { } } -class GoblinClearCutterEffect extends OneShotEffect { +// TODO: replace by mana effect to use with mana reflection +class GoblinClearCutterManaEffect extends ManaEffect { - public GoblinClearCutterEffect() { - super(Outcome.PutManaInPool); + private List netMana = new ArrayList<>(); + + public GoblinClearCutterManaEffect() { + super(); this.staticText = "Add 3 mana in any combination of {R} and/or {G}"; + netMana.add(new Mana(0, 3, 0, 0, 0, 0, 0, 0)); + netMana.add(new Mana(1, 2, 0, 0, 0, 0, 0, 0)); + netMana.add(new Mana(2, 1, 0, 0, 0, 0, 0, 0)); + netMana.add(new Mana(3, 0, 0, 0, 0, 0, 0, 0)); } - public GoblinClearCutterEffect(final GoblinClearCutterEffect effect) { + public GoblinClearCutterManaEffect(final GoblinClearCutterManaEffect effect) { super(effect); + netMana.addAll(effect.netMana); } @Override - public GoblinClearCutterEffect copy() { - return new GoblinClearCutterEffect(this); + public GoblinClearCutterManaEffect copy() { + return new GoblinClearCutterManaEffect(this); } @Override - public boolean apply(Game game, Ability source) { + public List getNetMana(Game game, Ability source) { + return netMana; + } + + @Override + public Mana produceMana(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Choice manaChoice = new ChoiceImpl(); @@ -85,10 +96,10 @@ class GoblinClearCutterEffect extends OneShotEffect { manaChoice.setChoices(choices); manaChoice.setMessage("Select color of mana to add"); + Mana mana = new Mana(); for (int i = 0; i < 3; i++) { - Mana mana = new Mana(); if (!player.choose(Outcome.Benefit, manaChoice, game)) { - return false; + return null; } switch (manaChoice.getChoice()) { case "Green": @@ -98,10 +109,9 @@ class GoblinClearCutterEffect extends OneShotEffect { mana.increaseRed(); break; } - player.getManaPool().addMana(mana, game, source); } - return true; + return mana; } - return false; + return null; } } diff --git a/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java b/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java index ba74701e971..93291d6a921 100644 --- a/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java +++ b/Mage.Sets/src/mage/cards/o/OrcishLumberjack.java @@ -1,10 +1,5 @@ package mage.cards.o; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.Ability; @@ -25,8 +20,9 @@ import mage.game.Game; import mage.players.Player; import mage.target.common.TargetControlledPermanent; +import java.util.*; + /** - * * @author LevelX2 */ public final class OrcishLumberjack extends CardImpl { @@ -76,6 +72,7 @@ class OrcishLumberjackManaEffect extends ManaEffect { public OrcishLumberjackManaEffect(final OrcishLumberjackManaEffect effect) { super(effect); + netMana.addAll(effect.netMana); } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java index 05b55fccd74..e8927641047 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java @@ -133,4 +133,45 @@ public class TappedForManaFromMultipleEffects extends CardTestPlayerBase { assertPermanentCount(playerA, "Chrome Mox", 1); assertExileCount(playerA, "Balduvian Bears", 1); } + + @Test + public void test_GoblinClearcutter_Direct() { + // {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G}. + addCard(Zone.BATTLEFIELD, playerA, "Goblin Clearcutter", 1); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice a Fo"); + setChoice(playerA, "Forest"); // sacrifice + setChoice(playerA, "Green"); + setChoice(playerA, "Green"); + setChoice(playerA, "Green"); + checkManaPool("must produce green", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "G", 3); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } + + @Test + public void test_GoblinClearcutter_WithManaReflect() { + // {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G}. + addCard(Zone.BATTLEFIELD, playerA, "Goblin Clearcutter", 1); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + // + // If you tap a permanent for mana, it produces twice as much of that mana instead. + addCard(Zone.BATTLEFIELD, playerA, "Mana Reflection", 1); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice a Fo"); + setChoice(playerA, "Forest"); // sacrifice + setChoice(playerA, "Green"); + setChoice(playerA, "Green"); + setChoice(playerA, "Green"); + checkManaPool("must produce green", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "G", 3 * 2); // double by mana reflect + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } } \ No newline at end of file