From 219ab89bcc968aac36e7bdae1d021cb68cd80b09 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 11 Jul 2020 21:01:40 +0400 Subject: [PATCH] Fixed test --- Mage.Sets/src/mage/cards/b/BirchloreRangers.java | 10 ++++++---- Mage.Sets/src/mage/cards/g/GrandArchitect.java | 14 ++++++++------ Mage.Sets/src/mage/cards/h/HeritageDruid.java | 6 ++++-- .../src/mage/cards/s/SetonKrosanProtector.java | 6 ++++-- .../src/mage/cards/u/UrzaLordHighArtificer.java | 6 ++++-- .../mana/ConditionalAnyColorManaAbility.java | 12 ++++++++---- .../mage/abilities/mana/DynamicManaAbility.java | 6 +++--- .../mage/abilities/mana/TriggeredManaAbility.java | 6 +++--- 8 files changed, 40 insertions(+), 26 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/BirchloreRangers.java b/Mage.Sets/src/mage/cards/b/BirchloreRangers.java index c130b15d1c..1afa11758a 100644 --- a/Mage.Sets/src/mage/cards/b/BirchloreRangers.java +++ b/Mage.Sets/src/mage/cards/b/BirchloreRangers.java @@ -80,11 +80,13 @@ class BirchloreRangersManaEffect extends AddManaOfAnyColorEffect { @Override public List getNetMana(Game game, Ability source) { - if (game.inCheckPlayableState()) { + if (game != null && game.inCheckPlayableState()) { int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 2; - List netManaCalculated = new ArrayList<>(); - netManaCalculated.add(new Mana(0, 0, 0, 0, 0, 0, count * 2, 0)); - return netManaCalculated; + List netMana = new ArrayList<>(); + if (count > 0) { + netMana.add(Mana.AnyMana(count * 2)); + } + return netMana; } return super.getNetMana(game, source); } diff --git a/Mage.Sets/src/mage/cards/g/GrandArchitect.java b/Mage.Sets/src/mage/cards/g/GrandArchitect.java index 5818a306fc..a864996b17 100644 --- a/Mage.Sets/src/mage/cards/g/GrandArchitect.java +++ b/Mage.Sets/src/mage/cards/g/GrandArchitect.java @@ -126,13 +126,15 @@ class GrandArchitectManaAbility extends ActivatedManaAbilityImpl { @Override public List getNetMana(Game game) { - if (game.inCheckPlayableState()) { + if (game != null && game.inCheckPlayableState()) { int count = game.getBattlefield().count(filter, getSourceId(), getControllerId(), game); - List netManaCalculated = new ArrayList<>(); - ConditionalMana mana = new GrandArchitectConditionalMana(); - mana.setColorless(count * 2); - netManaCalculated.add(mana); - return netManaCalculated; + List netMana = new ArrayList<>(); + if (count > 0) { + ConditionalMana mana = new GrandArchitectConditionalMana(); + mana.setColorless(count * 2); + netMana.add(mana); + } + return netMana; } return super.getNetMana(game); } diff --git a/Mage.Sets/src/mage/cards/h/HeritageDruid.java b/Mage.Sets/src/mage/cards/h/HeritageDruid.java index 844eab75f4..cbfc1b23d6 100644 --- a/Mage.Sets/src/mage/cards/h/HeritageDruid.java +++ b/Mage.Sets/src/mage/cards/h/HeritageDruid.java @@ -75,10 +75,12 @@ class HeritageDruidManaEffect extends BasicManaEffect { @Override public List getNetMana(Game game, Ability source) { - if (game.inCheckPlayableState()) { + if (game != null && game.inCheckPlayableState()) { int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3; List netMana = new ArrayList<>(); - netMana.add(new Mana(0, count * 3, 0, 0, 0, 0, 0, 0)); + if (count > 0) { + netMana.add(Mana.GreenMana(count * 3)); + } return netMana; } return super.getNetMana(game, source); diff --git a/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java b/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java index 892bcefe34..8edf79240a 100644 --- a/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java +++ b/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java @@ -79,11 +79,13 @@ class SetonKrosanProtectorManaEffect extends BasicManaEffect { @Override public List getNetMana(Game game, Ability source) { - if (game.inCheckPlayableState()) { + if (game != null && game.inCheckPlayableState()) { // Because the ability can be used multiple times, multiply with untapped druids int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); List netMana = new ArrayList<>(); - netMana.add(new Mana(0, count, 0,0,0,0,0,0)); + if (count > 0) { + netMana.add(Mana.GreenMana(count)); + } return netMana; } diff --git a/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java b/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java index 5754b27288..0599b62e1e 100644 --- a/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java +++ b/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java @@ -125,10 +125,12 @@ class UrzaLordHighArtificerManaEffect extends BasicManaEffect { @Override public List getNetMana(Game game, Ability source) { - if (game.inCheckPlayableState()) { + if (game != null && game.inCheckPlayableState()) { int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); List netMana = new ArrayList<>(); - netMana.add(new Mana(0, 0, count, 0,0,0,0,0)); + if (count > 0) { + netMana.add(Mana.BlueMana(count)); + } return netMana; } return super.getNetMana(game, source); diff --git a/Mage/src/main/java/mage/abilities/mana/ConditionalAnyColorManaAbility.java b/Mage/src/main/java/mage/abilities/mana/ConditionalAnyColorManaAbility.java index c8d9cf3ac4..fd4920d583 100644 --- a/Mage/src/main/java/mage/abilities/mana/ConditionalAnyColorManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/ConditionalAnyColorManaAbility.java @@ -1,7 +1,6 @@ package mage.abilities.mana; -import java.util.List; import mage.Mana; import mage.abilities.costs.Cost; import mage.abilities.costs.common.TapSourceCost; @@ -12,9 +11,11 @@ import mage.abilities.mana.builder.ConditionalManaBuilder; import mage.constants.Zone; import mage.game.Game; +import java.util.List; + /** * For cards like: - * {tap}: Add three mana of any one color. Spend this mana only to cast creature spells. + * {tap}: Add three mana of any one color. Spend this mana only to cast creature spells. * * @author noxx */ @@ -47,7 +48,10 @@ public class ConditionalAnyColorManaAbility extends ActivatedManaAbilityImpl { @Override public List getNetMana(Game game) { this.netMana.clear(); - this.netMana.add(new Mana(0,0,0,0,0,0, amount.calculate(game, this, null), 0)); + int count = amount.calculate(game, this, null); + if (count > 0) { + this.netMana.add(Mana.AnyMana(count)); + } return super.getNetMana(game); } @@ -56,7 +60,7 @@ public class ConditionalAnyColorManaAbility extends ActivatedManaAbilityImpl { return true; } - + @Override public ConditionalAnyColorManaAbility copy() { return new ConditionalAnyColorManaAbility(this); diff --git a/Mage/src/main/java/mage/abilities/mana/DynamicManaAbility.java b/Mage/src/main/java/mage/abilities/mana/DynamicManaAbility.java index 087a1d23c6..7400c17f3b 100644 --- a/Mage/src/main/java/mage/abilities/mana/DynamicManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/DynamicManaAbility.java @@ -81,13 +81,13 @@ public class DynamicManaAbility extends ActivatedManaAbilityImpl { @Override public List getNetMana(Game game) { - List newNetMana = new ArrayList<>(); + List netMana = new ArrayList<>(); if (game != null) { // TODO: effects from replacement effects like Mana Reflection are not considered yet // TODO: effects that need a X payment (e.g. Mage-Ring Network) return always 0 - newNetMana.addAll(manaEffect.getNetMana(game, this)); + netMana.addAll(manaEffect.getNetMana(game, this)); } - return newNetMana; + return netMana; } @Override diff --git a/Mage/src/main/java/mage/abilities/mana/TriggeredManaAbility.java b/Mage/src/main/java/mage/abilities/mana/TriggeredManaAbility.java index 9e19220464..abb6c7f838 100644 --- a/Mage/src/main/java/mage/abilities/mana/TriggeredManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/TriggeredManaAbility.java @@ -46,13 +46,13 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen @Override public List getNetMana(Game game) { if (game != null) { - List newNetMana = new ArrayList<>(); + List netMana = new ArrayList<>(); for (Effect effect : getEffects()) { if (effect instanceof ManaEffect) { - newNetMana.addAll(((ManaEffect) effect).getNetMana(game, this)); + netMana.addAll(((ManaEffect) effect).getNetMana(game, this)); } } - return newNetMana; + return netMana; } return new ArrayList<>(netMana); }