Additional fixes for getNetMana from #6132

This commit is contained in:
Oleg Agafonov 2020-01-02 23:33:20 +04:00
parent 3fa88d1c88
commit 62636b5071
12 changed files with 243 additions and 247 deletions

View file

@ -1,9 +1,5 @@
package mage.cards.a;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -21,8 +17,11 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class AstralCornucopia extends CardImpl {
@ -67,6 +66,19 @@ class AstralCornucopiaManaEffect extends ManaEffect {
return new AstralCornucopiaManaEffect(this);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
if (counters > 0) {
netMana.add(Mana.AnyMana(counters));
}
}
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
@ -107,16 +119,4 @@ class AstralCornucopiaManaEffect extends ManaEffect {
return mana;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
List<Mana> netMana = new ArrayList<>();
netMana.add(new Mana(0, 0, 0, 0, 0, 0, counters, 0));
return netMana;
}
return null;
}
}

View file

@ -1,8 +1,5 @@
package mage.cards.b;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Abilities;
@ -13,16 +10,11 @@ import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.Choice;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.predicate.permanent.TappedPredicate;
@ -32,8 +24,11 @@ import mage.players.Player;
import mage.target.common.TargetLandPermanent;
import mage.util.CardUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class BenthicExplorers extends CardImpl {
@ -87,7 +82,7 @@ class BenthicExplorersCost extends CostImpl {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
if (target.choose(Outcome.Untap, controllerId, sourceId, game)) {
for (UUID targetId : (List<UUID>) target.getTargets()) {
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null) {
return false;
@ -123,6 +118,34 @@ class BenthicExplorersManaEffect extends ManaEffect {
super(effect);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
@ -215,34 +238,6 @@ class BenthicExplorersManaEffect extends ManaEffect {
return types;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}
@Override
public BenthicExplorersManaEffect copy() {
return new BenthicExplorersManaEffect(this);

View file

@ -20,6 +20,8 @@ import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
@ -85,8 +87,8 @@ class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
boolean value = super.resolve(game);
if (value == true) {
game.getState().setValue(this.originalId.toString()
+ "addMana"
+ game.getState().getZoneChangeCounter(sourceId),
+ "addMana"
+ game.getState().getZoneChangeCounter(sourceId),
Boolean.TRUE);
}
return value;
@ -95,8 +97,8 @@ class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
@Override
public void reset(Game game) {
game.getState().setValue(this.originalId.toString()
+ "addMana"
+ game.getState().getZoneChangeCounter(sourceId),
+ "addMana"
+ game.getState().getZoneChangeCounter(sourceId),
Boolean.FALSE);
}
@ -127,6 +129,16 @@ class CarpetOfFlowersEffect extends ManaEffect {
super(effect);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
if (count > 0) {
netMana.add(Mana.AnyMana(count));
}
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());

View file

@ -1,22 +1,11 @@
package mage.cards.c;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PutTopCardOfYourLibraryToGraveyardCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.costs.mana.ColorlessManaCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.MonoHybridManaCost;
import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.costs.mana.*;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
@ -31,8 +20,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.List;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class CharmedPendant extends CardImpl {
@ -107,6 +99,25 @@ class CharmedPendantManaEffect extends ManaEffect {
return new CharmedPendantManaEffect(this);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.isTopCardRevealed()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
List<Mana> netMana = card.getManaCost().getManaOptions();
for (Mana mana : netMana) {
mana.setColorless(0);
mana.setGeneric(0);
}
return netMana;
}
}
}
return null;
}
@Override
public Mana produceMana(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -157,23 +168,4 @@ class CharmedPendantManaEffect extends ManaEffect {
return null;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.isTopCardRevealed()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
List<Mana> netMana = card.getManaCost().getManaOptions();
for (Mana mana : netMana) {
mana.setColorless(0);
mana.setGeneric(0);
}
return netMana;
}
}
}
return null;
}
}

View file

@ -1,9 +1,5 @@
package mage.cards.c;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -22,8 +18,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author spjspj
*/
public final class CorruptedGrafstone extends CardImpl {
@ -89,6 +88,31 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
return new CorruptedGrafstoneManaEffect(this);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypesInGraveyard(game, source);
if (types == null) {
return null;
}
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
return netManas;
}
@Override
public Mana produceMana(Game game, Ability source) {
Mana types = getManaTypesInGraveyard(game, source);
@ -144,31 +168,6 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
return null;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypesInGraveyard(game, source);
if (types == null) {
return null;
}
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
return netManas;
}
private Mana getManaTypesInGraveyard(Game game, Ability source) {
if (source != null && source.getControllerId() != null) {

View file

@ -1,9 +1,5 @@
package mage.cards.d;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.AttachEffect;
@ -12,7 +8,6 @@ import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor;
import mage.choices.ManaChoice;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -26,8 +21,11 @@ import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class DawnsReflection extends CardImpl {
@ -116,17 +114,16 @@ class DawnsReflectionManaEffect extends ManaEffect {
return null;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(2));
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
Player player = getPlayer(game, source);
return ManaChoice.chooseAnyColor(player, game, 2);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
netMana.add(new Mana(0, 0, 0, 0, 0, 0, 2, 0));
return netMana;
}
}

View file

@ -49,7 +49,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
return netMana;
return new ArrayList<>(this.netMana);
}
@Override

View file

@ -23,16 +23,16 @@ public class AddManaOfTwoDifferentColorsEffect extends ManaEffect {
}
@Override
public Mana produceMana(Game game, Ability source) {
Player player = getPlayer(game, source);
return ManaChoice.chooseTwoDifferentColors(player, game);
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(2));
return netMana;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
netMana.add(new Mana(0, 0, 0, 0, 0, 0, 2, 0));
return netMana;
public Mana produceMana(Game game, Ability source) {
Player player = getPlayer(game, source);
return ManaChoice.chooseTwoDifferentColors(player, game);
}
@Override

View file

@ -11,10 +11,10 @@ import mage.abilities.effects.common.ManaEffect;
import mage.game.Game;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author LevelX2
*/
public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
@ -29,12 +29,11 @@ public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
/**
* Adds mana to the mana pool of target pointer player
*
* @param mana mana that will be added to the pool
* @param mana mana that will be added to the pool
* @param textManaPoolOwner text that references to the mana pool owner
* (e.g. "damaged player's")
* @param emptyOnTurnsEnd if set, the mana will empty only on end of
* turnstep
*
* (e.g. "damaged player's")
* @param emptyOnTurnsEnd if set, the mana will empty only on end of
* turnstep
*/
public AddManaToManaPoolTargetControllerEffect(Mana mana, String textManaPoolOwner, boolean emptyOnTurnsEnd) {
super();
@ -59,6 +58,13 @@ public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
return game.getPlayer(getTargetPointer().getFirst(game, source));
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
netMana.add(mana.copy());
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
return mana.copy();
@ -68,9 +74,4 @@ public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
protected void addManaToPool(Player player, Mana manaToAdd, Game game, Ability source) {
player.getManaPool().addMana(manaToAdd, game, source, emptyOnlyOnTurnsEnd);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
return null;
}
}

View file

@ -1,4 +1,3 @@
package mage.abilities.mana;
import mage.Mana;
@ -86,6 +85,34 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
this.onlyColors = effect.onlyColors;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (!onlyColors && types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
@ -181,34 +208,6 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
return types;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}
@Override
public AnyColorLandsProduceManaEffect copy() {
return new AnyColorLandsProduceManaEffect(this);

View file

@ -5,8 +5,6 @@
*/
package mage.abilities.mana;
import java.util.ArrayList;
import java.util.List;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -23,8 +21,10 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author CountAndromalius
*/
public class AnyColorPermanentTypesManaAbility extends ActivatedManaAbilityImpl {
@ -80,6 +80,34 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
this.onlyColors = effect.onlyColors;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (!onlyColors && types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
@ -181,34 +209,6 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
return types;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}
@Override
public AnyColorPermanentTypesManaEffect copy() {
return new AnyColorPermanentTypesManaEffect(this);

View file

@ -14,7 +14,9 @@ import mage.filter.FilterMana;
import mage.game.Game;
import mage.players.Player;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author LevelX2
@ -61,6 +63,36 @@ class CommanderIdentityManaEffect extends ManaEffect {
return new CommanderIdentityManaEffect(this);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID commanderId : game.getCommandersIds(controller)) {
Card commander = game.getCard(commanderId);
if (commander != null) {
FilterMana commanderMana = commander.getColorIdentity();
if (commanderMana.isBlack()) {
netMana.add(new Mana(ColoredManaSymbol.B));
}
if (commanderMana.isBlue()) {
netMana.add(new Mana(ColoredManaSymbol.U));
}
if (commanderMana.isGreen()) {
netMana.add(new Mana(ColoredManaSymbol.G));
}
if (commanderMana.isRed()) {
netMana.add(new Mana(ColoredManaSymbol.R));
}
if (commanderMana.isWhite()) {
netMana.add(new Mana(ColoredManaSymbol.W));
}
}
}
}
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
@ -120,35 +152,4 @@ class CommanderIdentityManaEffect extends ManaEffect {
}
return mana;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID commanderId : game.getCommandersIds(controller)) {
Card commander = game.getCard(commanderId);
if (commander != null) {
FilterMana commanderMana = commander.getColorIdentity();
if (commanderMana.isBlack()) {
netMana.add(new Mana(ColoredManaSymbol.B));
}
if (commanderMana.isBlue()) {
netMana.add(new Mana(ColoredManaSymbol.U));
}
if (commanderMana.isGreen()) {
netMana.add(new Mana(ColoredManaSymbol.G));
}
if (commanderMana.isRed()) {
netMana.add(new Mana(ColoredManaSymbol.R));
}
if (commanderMana.isWhite()) {
netMana.add(new Mana(ColoredManaSymbol.W));
}
}
}
}
return netMana;
}
}