1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-10 09:11:04 -09:00

* Fixed a problem of endless iteration with Reflecting Pool.

This commit is contained in:
LevelX2 2017-05-18 16:57:32 +02:00
parent 83cdd5570d
commit d686af8890
4 changed files with 9 additions and 7 deletions
Mage.Sets/src/mage/cards/r
Mage.Tests/src/test/java/org/mage/test/cards/mana
Mage/src/main/java/mage

View file

@ -206,13 +206,17 @@ class ReflectingPoolEffect extends ManaEffect {
} }
private Mana getManaTypes(Game game, Ability source) { private Mana getManaTypes(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana(); Mana types = new Mana();
if (game == null || game.getPhase() == null) {
return types;
}
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent land : lands) { for (Permanent land : lands) {
Abilities<Ability> manaAbilities = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD); Abilities<Ability> manaAbilities = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (Ability basicAbility : manaAbilities) { for (Ability basicAbility : manaAbilities) {
ManaAbility ability = (ManaAbility) basicAbility; ManaAbility ability = (ManaAbility) basicAbility;
if (!ability.equals(source) && ability.definesMana(game)) { if (!(ability instanceof ReflectingPoolManaAbility) // can't get types from own ability class
&& ability.definesMana(game)) {
for (Mana netMana : ability.getNetMana(game)) { for (Mana netMana : ability.getNetMana(game)) {
types.add(netMana); types.add(netMana);
if (netMana.getAny() > 0) { if (netMana.getAny() > 0) {

View file

@ -126,7 +126,7 @@ public class ReflectingPoolTest extends CardTestPlayerBase {
execute(); execute();
ManaOptions options = playerA.getAvailableManaTest(currentGame); ManaOptions options = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("Player should be able to create 2 red mana", "{R}{R}{R}", options.get(0).toString()); Assert.assertEquals("Player should be able to create 3 red mana", "{R}{R}{R}", options.get(0).toString());
} }

View file

@ -29,8 +29,6 @@ package mage.abilities.mana;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import mage.Mana; import mage.Mana;
import mage.abilities.Abilities; import mage.abilities.Abilities;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -163,7 +161,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
} }
private Mana getManaTypes(Game game, Ability source) { private Mana getManaTypes(Game game, Ability source) {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "needed to identify endless loop causing cards: {0}", source.getSourceObject(game).getName()); // Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "needed to identify endless loop causing cards: {0}", source.getSourceObject(game).getName());
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
Mana types = new Mana(); Mana types = new Mana();
for (Permanent land : lands) { for (Permanent land : lands) {

View file

@ -116,7 +116,7 @@ public class PermanentCard extends PermanentImpl {
this.cardType.clear(); this.cardType.clear();
this.cardType.addAll(card.getCardType()); this.cardType.addAll(card.getCardType());
this.color = card.getColor(null).copy(); this.color = card.getColor(null).copy();
this.frameColor = card.getFrameColor(null).copy(); this.frameColor = card.getFrameColor(game).copy();
this.frameStyle = card.getFrameStyle(); this.frameStyle = card.getFrameStyle();
this.manaCost = card.getManaCost().copy(); this.manaCost = card.getManaCost().copy();
if (card instanceof PermanentCard) { if (card instanceof PermanentCard) {