Skip to content

Commit

Permalink
* Some more fixes for ManaOptions #5023
Browse files Browse the repository at this point in the history
  • Loading branch information
LevelX2 committed Jun 24, 2018
1 parent 2ec3ebd commit 99cfd86
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Mage.Sets/src/mage/cards/n/NykthosShrineToNyx.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public NykthosShrineToNyxManaAbility copy() {

@Override
public List<Mana> getNetMana(Game game) {
netMana.clear();
ArrayList<Mana> netManaCopy = new ArrayList<>();
if (game != null) {
netMana.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
netManaCopy.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
}
return netMana;
return netManaCopy;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

package mage.abilities.mana;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
Expand Down Expand Up @@ -42,6 +42,7 @@ public CommanderColorIdentityManaAbility copy() {

@Override
public List<Mana> getNetMana(Game game) {
List<Mana> netManas = new ArrayList<>();
if (netMana.isEmpty() && game != null) {
Player controller = game.getPlayer(getControllerId());
if (controller != null) {
Expand All @@ -68,7 +69,8 @@ public List<Mana> getNetMana(Game game) {
}
}
}
return netMana;
netManas.addAll(netMana);
return netManas;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public ConditionalManaAbility copy() {

@Override
public List<Mana> getNetMana(Game game) {
List<Mana> newNetMana = new ArrayList<>();
newNetMana.addAll(conditionalManaEffect.getNetMana(game, this));
return newNetMana;
return new ArrayList<>(conditionalManaEffect.getNetMana(game, this));
}
}
2 changes: 1 addition & 1 deletion Mage/src/main/java/mage/abilities/mana/ManaOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void addMana(List<ActivatedManaAbilityImpl> abilities, Game game) {
boolean hasTapCost = hasTapCost(abilities.get(0));
for (Mana netMana : netManas) {
for (Mana mana : copy) {
if (!hasTapCost || checkTappedForManaReplacement(abilities.get(0), game, netMana)) {
if (!hasTapCost /* || checkTappedForManaReplacement(abilities.get(0), game, netMana) */) { // Seems to produce endless iterations so deactivated for now: https://github.com/magefree/mage/issues/5023

This comment has been minimized.

Copy link
@LevelX2

LevelX2 Jun 24, 2018

Author Contributor

This will let some tests fail.
But it should be mainly from available mana calculation. I need to test if this causes the massive CPU load described in #5023 that premanently crashes the server.

Mana newMana = new Mana();
newMana.add(mana);
newMana.add(netMana);
Expand Down
4 changes: 2 additions & 2 deletions Mage/src/main/java/mage/abilities/mana/SimpleManaAbility.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

package mage.abilities.mana;

import java.util.ArrayList;
import java.util.List;
import mage.Mana;
import mage.abilities.costs.Cost;
Expand Down Expand Up @@ -55,7 +55,7 @@ public List<Mana> getNetMana(Game game) {
if (predictable) {
return super.getNetMana(game);
}
return netMana;
return new ArrayList<Mana>(netMana);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package mage.abilities.mana;

import java.util.ArrayList;
Expand Down Expand Up @@ -54,7 +53,7 @@ public List<Mana> getNetMana(Game game) {
}
return newNetMana;
}
return netMana;
return new ArrayList<Mana>(netMana);
}

/**
Expand Down

0 comments on commit 99cfd86

Please sign in to comment.