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,25 +76,30 @@ 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) {
Card commander = game.getCard(controller.getCommanderId()); if (commanderMana == null) {
if (commander != null) { Card commander = game.getCard(controller.getCommanderId());
Mana commanderMana = commander.getManaCost().getMana(); if (commander != null) {
if (commanderMana.getBlack() > 0) { commanderMana = CardUtil.getColorIdentity(commander);
netMana.add(new Mana(ColoredManaSymbol.B)); } else {
} // In formats other than Commander, Command Tower's ability produces no mana.
if (commanderMana.getBlue() > 0) { commanderMana = new FilterMana();
netMana.add(new Mana(ColoredManaSymbol.U));
}
if (commanderMana.getGreen() > 0) {
netMana.add(new Mana(ColoredManaSymbol.G));
}
if (commanderMana.getRed() > 0) {
netMana.add(new Mana(ColoredManaSymbol.R));
}
if (commanderMana.getWhite() > 0) {
netMana.add(new Mana(ColoredManaSymbol.W));
} }
} }
if (commanderMana.isBlack()) {
netMana.add(new Mana(ColoredManaSymbol.B));
}
if (commanderMana.isBlue()) {
netMana.add(new Mana(ColoredManaSymbol.U));
}
if (commanderMana.isGreen()) {
netMana.add(new Mana(ColoredManaSymbol.G));
}
if (commanderMana.isRed()) {
netMana.add(new Mana(ColoredManaSymbol.R));
}
if (commanderMana.isWhite()) {
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,56 +137,61 @@ 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) {
Card commander = game.getCard(controller.getCommanderId()); if (commanderMana == null) {
if (commander != null) { Card commander = game.getCard(controller.getCommanderId());
Mana commanderMana = commander.getManaCost().getMana(); if (commander != null) {
Choice choice = new ChoiceImpl(); commanderMana = CardUtil.getColorIdentity(commander);
choice.setMessage("Pick a mana color"); } else {
if (commanderMana.getBlack() > 0) { // In formats other than Commander, Command Tower's ability produces no mana.
choice.getChoices().add("Black"); commanderMana = new FilterMana();
} }
if (commanderMana.getRed() > 0) { }
choice.getChoices().add("Red"); Choice choice = new ChoiceImpl();
} choice.setMessage("Pick a mana color");
if (commanderMana.getBlue() > 0) { if (commanderMana.isBlack()) {
choice.getChoices().add("Blue"); choice.getChoices().add("Black");
} }
if (commanderMana.getGreen() > 0) { if (commanderMana.isRed()) {
choice.getChoices().add("Green"); choice.getChoices().add("Red");
} }
if (commanderMana.getWhite() > 0) { if (commanderMana.isBlue()) {
choice.getChoices().add("White"); choice.getChoices().add("Blue");
} }
if (choice.getChoices().size() > 0) { if (commanderMana.isGreen()) {
if (choice.getChoices().size() == 1) { choice.getChoices().add("Green");
choice.setChoice(choice.getChoices().iterator().next()); }
} else { if (commanderMana.isWhite()) {
if (!controller.choose(outcome, choice, game)) { choice.getChoices().add("White");
return false; }
} if (choice.getChoices().size() > 0) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!controller.choose(outcome, choice, game)) {
return false;
} }
Mana mana = new Mana();
switch (choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
}
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);
return true;
} }
Mana mana = new Mana();
switch (choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
}
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);
return true;
} }
} }
return false; return false;