Merge origin/master

This commit is contained in:
LevelX2 2016-11-03 22:38:14 +01:00
commit a4e1c7aefd
41 changed files with 1395 additions and 640 deletions

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
@ -56,8 +57,12 @@ public class CommanderInPlayCondition implements Condition {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent commander = game.getPermanent(controller.getCommanderId());
return commander != null && commander.getControllerId().equals(source.getControllerId());
for (UUID commanderId : controller.getCommandersIds()) {
Permanent commander = game.getPermanent(commanderId);
if (commander != null && commander.getControllerId().equals(source.getControllerId())) {
return true;
}
}
}
return false;
}

View file

@ -28,6 +28,7 @@
package mage.abilities.mana;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
@ -49,20 +50,16 @@ import mage.util.CardUtil;
*/
public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl {
private FilterMana commanderMana;
public CommanderColorIdentityManaAbility() {
super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), new TapSourceCost());
}
public CommanderColorIdentityManaAbility(Cost cost) {
super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), cost);
commanderMana = null;
}
public CommanderColorIdentityManaAbility(final CommanderColorIdentityManaAbility ability) {
super(ability);
this.commanderMana = ability.commanderMana;
}
@Override
@ -75,30 +72,27 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl
if (netMana.isEmpty() && game != null) {
Player controller = game.getPlayer(getControllerId());
if (controller != null) {
if (commanderMana == null) {
Card commander = game.getCard(controller.getCommanderId());
for (UUID commanderId : controller.getCommandersIds()) {
Card commander = game.getCard(commanderId);
if (commander != null) {
commanderMana = CardUtil.getColorIdentity(commander);
} else {
// In formats other than Commander, Command Tower's ability produces no mana.
commanderMana = new FilterMana();
FilterMana commanderMana = CardUtil.getColorIdentity(commander);
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));
}
}
}
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;
@ -113,17 +107,13 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl
class CommanderIdentityManaEffect extends ManaEffect {
private FilterMana commanderMana;
public CommanderIdentityManaEffect() {
super();
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) {
super(effect);
this.commanderMana = effect.commanderMana;
}
@Override
@ -135,31 +125,28 @@ class CommanderIdentityManaEffect extends ManaEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (commanderMana == null) {
Card commander = game.getCard(controller.getCommanderId());
if (commander != null) {
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.setMessage("Pick a mana color");
if (commanderMana.isBlack()) {
choice.getChoices().add("Black");
}
if (commanderMana.isRed()) {
choice.getChoices().add("Red");
}
if (commanderMana.isBlue()) {
choice.getChoices().add("Blue");
}
if (commanderMana.isGreen()) {
choice.getChoices().add("Green");
}
if (commanderMana.isWhite()) {
choice.getChoices().add("White");
for (UUID commanderId : controller.getCommandersIds()) {
Card commander = game.getCard(commanderId);
if (commander != null) {
FilterMana commanderMana = CardUtil.getColorIdentity(commander);
if (commanderMana.isWhite()) {
choice.getChoices().add("White");
}
if (commanderMana.isBlue()) {
choice.getChoices().add("Blue");
}
if (commanderMana.isBlack()) {
choice.getChoices().add("Black");
}
if (commanderMana.isRed()) {
choice.getChoices().add("Red");
}
if (commanderMana.isGreen()) {
choice.getChoices().add("Green");
}
}
}
if (choice.getChoices().size() > 0) {
if (choice.getChoices().size() == 1) {