Fixed that commander mana sources could not produce mana where the symbols were only included in the rule text (Command Tower, Commanders Sphere, Opal Palace).

This commit is contained in:
LevelX2 2015-02-21 14:50:10 +01:00
parent 9450407b5a
commit 7fa7cf910e

View file

@ -38,8 +38,10 @@ import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.ColoredManaSymbol; import mage.constants.ColoredManaSymbol;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterMana;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
/** /**
* *
@ -48,16 +50,20 @@ import mage.players.Player;
public class CommanderColorIdentityManaAbility extends ManaAbility { public class CommanderColorIdentityManaAbility extends ManaAbility {
private FilterMana commanderMana;
public CommanderColorIdentityManaAbility() { public CommanderColorIdentityManaAbility() {
super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(),new TapSourceCost()); super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(),new TapSourceCost());
} }
public CommanderColorIdentityManaAbility(Cost cost) { public CommanderColorIdentityManaAbility(Cost cost) {
super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), cost); super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), cost);
commanderMana = null;
} }
public CommanderColorIdentityManaAbility(final CommanderColorIdentityManaAbility ability) { public CommanderColorIdentityManaAbility(final CommanderColorIdentityManaAbility ability) {
super(ability); super(ability);
this.commanderMana = ability.commanderMana;
} }
@Override @Override
@ -70,27 +76,32 @@ public class CommanderColorIdentityManaAbility extends ManaAbility {
if (netMana.isEmpty()) { if (netMana.isEmpty()) {
Player controller = game.getPlayer(getControllerId()); Player controller = game.getPlayer(getControllerId());
if (controller != null) { if (controller != null) {
if (commanderMana == null) {
Card commander = game.getCard(controller.getCommanderId()); Card commander = game.getCard(controller.getCommanderId());
if (commander != null) { if (commander != null) {
Mana commanderMana = commander.getManaCost().getMana(); commanderMana = CardUtil.getColorIdentity(commander);
if (commanderMana.getBlack() > 0) { } else {
// In formats other than Commander, Command Tower's ability produces no mana.
commanderMana = new FilterMana();
}
}
if (commanderMana.isBlack()) {
netMana.add(new Mana(ColoredManaSymbol.B)); netMana.add(new Mana(ColoredManaSymbol.B));
} }
if (commanderMana.getBlue() > 0) { if (commanderMana.isBlue()) {
netMana.add(new Mana(ColoredManaSymbol.U)); netMana.add(new Mana(ColoredManaSymbol.U));
} }
if (commanderMana.getGreen() > 0) { if (commanderMana.isGreen()) {
netMana.add(new Mana(ColoredManaSymbol.G)); netMana.add(new Mana(ColoredManaSymbol.G));
} }
if (commanderMana.getRed() > 0) { if (commanderMana.isRed()) {
netMana.add(new Mana(ColoredManaSymbol.R)); netMana.add(new Mana(ColoredManaSymbol.R));
} }
if (commanderMana.getWhite() > 0) { if (commanderMana.isWhite()) {
netMana.add(new Mana(ColoredManaSymbol.W)); netMana.add(new Mana(ColoredManaSymbol.W));
} }
} }
} }
}
return netMana; return netMana;
} }
@ -104,13 +115,17 @@ public class CommanderColorIdentityManaAbility extends ManaAbility {
class CommanderIdentityManaEffect extends ManaEffect { class CommanderIdentityManaEffect extends ManaEffect {
private FilterMana commanderMana;
public CommanderIdentityManaEffect() { public CommanderIdentityManaEffect() {
super(); super();
this.staticText = "Add to your mana pool one mana of any color in your commander's color identity"; this.staticText = "Add to your mana pool one mana of any color in your commander's color identity";
commanderMana = null;
} }
public CommanderIdentityManaEffect(final CommanderIdentityManaEffect effect) { public CommanderIdentityManaEffect(final CommanderIdentityManaEffect effect) {
super(effect); super(effect);
this.commanderMana = effect.commanderMana;
} }
@Override @Override
@ -122,24 +137,30 @@ class CommanderIdentityManaEffect extends ManaEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
if (commanderMana == null) {
Card commander = game.getCard(controller.getCommanderId()); Card commander = game.getCard(controller.getCommanderId());
if (commander != null) { if (commander != null) {
Mana commanderMana = commander.getManaCost().getMana(); commanderMana = CardUtil.getColorIdentity(commander);
} else {
// In formats other than Commander, Command Tower's ability produces no mana.
commanderMana = new FilterMana();
}
}
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setMessage("Pick a mana color"); choice.setMessage("Pick a mana color");
if (commanderMana.getBlack() > 0) { if (commanderMana.isBlack()) {
choice.getChoices().add("Black"); choice.getChoices().add("Black");
} }
if (commanderMana.getRed() > 0) { if (commanderMana.isRed()) {
choice.getChoices().add("Red"); choice.getChoices().add("Red");
} }
if (commanderMana.getBlue() > 0) { if (commanderMana.isBlue()) {
choice.getChoices().add("Blue"); choice.getChoices().add("Blue");
} }
if (commanderMana.getGreen() > 0) { if (commanderMana.isGreen()) {
choice.getChoices().add("Green"); choice.getChoices().add("Green");
} }
if (commanderMana.getWhite() > 0) { if (commanderMana.isWhite()) {
choice.getChoices().add("White"); choice.getChoices().add("White");
} }
if (choice.getChoices().size() > 0) { if (choice.getChoices().size() > 0) {
@ -173,7 +194,6 @@ class CommanderIdentityManaEffect extends ManaEffect {
return true; return true;
} }
} }
}
return false; return false;
} }