mirror of
https://github.com/correl/mage.git
synced 2025-04-11 17:00:08 -09:00
Fixed multiple calls of mana choice dialogs, related to #6132
This commit is contained in:
parent
ff9b1b5b13
commit
4445f8556e
5 changed files with 47 additions and 44 deletions
Mage/src/main/java/mage/abilities/effects/mana
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.mana;
|
||||
|
||||
import mage.ConditionalMana;
|
||||
|
@ -14,6 +13,9 @@ import mage.players.Player;
|
|||
import mage.util.CardUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
|
@ -40,10 +42,10 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
|
|||
this.oneChoice = oneChoice;
|
||||
//
|
||||
staticText = "Add "
|
||||
+ (amount instanceof StaticValue ? (CardUtil.numberToText(((StaticValue) amount).toString())) : "")
|
||||
+ (amount instanceof StaticValue ? (CardUtil.numberToText(amount.toString())) : "")
|
||||
+ " mana "
|
||||
+ (oneChoice || (amount instanceof StaticValue && (((StaticValue) amount).toString()).equals("1"))
|
||||
? "of any" + (amount instanceof StaticValue && (((StaticValue) amount).toString()).equals("1") ? "" : " one") + " color"
|
||||
+ (oneChoice || (amount instanceof StaticValue && (amount.toString()).equals("1"))
|
||||
? "of any" + (amount instanceof StaticValue && (amount.toString()).equals("1") ? "" : " one") + " color"
|
||||
: "in any combination of colors")
|
||||
+ ". " + manaBuilder.getRule();
|
||||
}
|
||||
|
@ -60,6 +62,18 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
|
|||
return new AddConditionalManaOfAnyColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
|
||||
int value = amount.calculate(game, source, this);
|
||||
if (value > 0) {
|
||||
netMana.add(Mana.AnyMana(value));
|
||||
}
|
||||
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.abilities.effects.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
|
@ -11,8 +8,10 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
|
||||
|
@ -43,6 +42,13 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
|
|||
return new AddManaAnyColorAttachedControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
ArrayList<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.AnyMana(1));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
|
@ -58,16 +64,4 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
|
|||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
ArrayList<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.GreenMana(1));
|
||||
netMana.add(Mana.WhiteMana(1));
|
||||
netMana.add(Mana.BlueMana(1));
|
||||
netMana.add(Mana.RedMana(1));
|
||||
netMana.add(Mana.BlackMana(1));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,10 +11,8 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AddManaChosenColorEffect extends ManaEffect {
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
|
||||
package mage.abilities.effects.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
|
@ -14,8 +10,11 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AddManaInAnyCombinationEffect extends ManaEffect {
|
||||
|
@ -64,6 +63,16 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
return new AddManaInAnyCombinationEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
ArrayList<Mana> netMana = new ArrayList<>();
|
||||
int amountOfManaLeft = amount.calculate(game, source, this);
|
||||
if (amountOfManaLeft > 0) {
|
||||
netMana.add(Mana.AnyMana(amountOfManaLeft));
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
@ -93,13 +102,6 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
ArrayList<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(new Mana(0, 0, 0, 0, 0, 0, amount.calculate(game, source, this), 0));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Add ");
|
||||
sb.append(CardUtil.numberToText(amount.toString()));
|
||||
|
@ -116,7 +118,6 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
sb.append('{').append(coloredManaSymbol.toString()).append('}');
|
||||
}
|
||||
}
|
||||
sb.append("");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package mage.abilities.effects.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
@ -9,6 +7,9 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
@ -29,11 +30,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
|
|||
public AddManaOfAnyColorEffect(int amount, boolean setFlag) {
|
||||
super(new Mana(0, 0, 0, 0, 0, 0, amount, 0));
|
||||
this.amount = amount;
|
||||
netMana.add(Mana.GreenMana(amount));
|
||||
netMana.add(Mana.BlueMana(amount));
|
||||
netMana.add(Mana.BlackMana(amount));
|
||||
netMana.add(Mana.WhiteMana(amount));
|
||||
netMana.add(Mana.RedMana(amount));
|
||||
netMana.add(Mana.AnyMana(amount));
|
||||
this.staticText = "add " + CardUtil.numberToText(amount) + " mana of any " + (amount > 1 ? "one " : "") + "color";
|
||||
this.setFlag = setFlag;
|
||||
}
|
||||
|
@ -80,7 +77,6 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana getManaTemplate() {
|
||||
return new Mana(0, 0, 0, 0, 0, 0, amount, 0);
|
||||
return Mana.AnyMana(amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue