* Goblin Clearcutter - fixed that tapped for mana replacement effects ignore his mana;

This commit is contained in:
Oleg Agafonov 2020-01-12 11:19:17 +04:00
parent 860c57d9d9
commit fe0717cbc7
3 changed files with 73 additions and 25 deletions

View file

@ -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<Mana> 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<Mana> 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;
}
}

View file

@ -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

View file

@ -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();
}
}