diff --git a/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java b/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java index d3852b649f..3fc632ea51 100644 --- a/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java +++ b/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java @@ -32,13 +32,15 @@ import java.util.List; import java.util.UUID; import mage.Mana; import mage.abilities.Ability; +import mage.abilities.common.EmptyEffect; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.ColorlessManaAbility; -import mage.abilities.mana.SimpleManaAbility; +import mage.abilities.mana.CommanderColorIdentityManaAbility; +import mage.abilities.mana.ManaAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.choices.Choice; @@ -71,7 +73,7 @@ public class OpalPalace extends CardImpl { // {tap}: Add {1} to your mana pool. this.addAbility(new ColorlessManaAbility()); // {1}, {tap}: Add to your mana pool one mana of any color in your commander's color identity. If you spend this mana to cast your commander, it enters the battlefield with a number of +1/+1 counters on it equal to the number of times it's been cast from the command zone this game. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new OpalPalaceManaEffect(), new GenericManaCost(1)); + Ability ability = new CommanderColorIdentityManaAbility(new GenericManaCost(1)); ability.addCost(new TapSourceCost()); this.addAbility(ability); @@ -92,87 +94,9 @@ public class OpalPalace extends CardImpl { } } -class OpalPalaceManaEffect extends ManaEffect { - - public OpalPalaceManaEffect() { - super(); - this.staticText = "Add to your mana pool one mana of any color in your commander's color identity. If you spend this mana to cast your commander, it enters the battlefield with a number of +1/+1 counters on it equal to the number of times it's been cast from the command zone this game"; - } - - public OpalPalaceManaEffect(final OpalPalaceManaEffect effect) { - super(effect); - } - - @Override - public OpalPalaceManaEffect copy() { - return new OpalPalaceManaEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Card commander = game.getCard(controller.getCommanderId()); - if (commander != null) { - Mana commanderMana = commander.getManaCost().getMana(); - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (commanderMana.getBlack() > 0) { - choice.getChoices().add("Black"); - } - if (commanderMana.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (commanderMana.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (commanderMana.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (commanderMana.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (choice.getChoices().size() > 0) { - Mana mana = new Mana(); - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } else { - controller.choose(outcome, choice, game); - } - if (choice.getChoice().equals("Black")) { - mana.addBlack(); - } else if (choice.getChoice().equals("Blue")) { - mana.addBlue(); - } else if (choice.getChoice().equals("Red")) { - mana.addRed(); - } else if (choice.getChoice().equals("Green")) { - mana.addGreen(); - } else if (choice.getChoice().equals("White")) { - mana.addWhite(); - } - // set to indicate, that the mana can boost the commander - mana.setFlag(true); - checkToFirePossibleEvents(mana, game, source); - controller.getManaPool().addMana(mana, game, source); - - } - return true; - } - } - return false; - } - - @Override - public Mana getMana(Game game, Ability source) { - return null; - } - - -} - class OpalPalaceWatcher extends Watcher { - public List commanderId = new ArrayList(); + public List commanderId = new ArrayList<>(); public OpalPalaceWatcher() { super("ManaPaidFromOpalPalaceWatcher", WatcherScope.CARD); @@ -249,7 +173,7 @@ class OpalPalaceEntersBattlefieldEffect extends ReplacementEffectImpl { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null) { Integer castCount = (Integer)game.getState().getValue(permanent.getId() + "_castCount"); - if (castCount != null && castCount.intValue() > 0) { + if (castCount != null && castCount > 0) { permanent.addCounters(CounterType.P1P1.createInstance(castCount), game); } } diff --git a/Mage/src/mage/abilities/mana/CommanderColorIdentityManaAbility.java b/Mage/src/mage/abilities/mana/CommanderColorIdentityManaAbility.java index d355063621..2d4807cf89 100644 --- a/Mage/src/mage/abilities/mana/CommanderColorIdentityManaAbility.java +++ b/Mage/src/mage/abilities/mana/CommanderColorIdentityManaAbility.java @@ -36,12 +36,9 @@ import mage.abilities.effects.common.ManaEffect; import mage.cards.Card; import mage.choices.Choice; import mage.choices.ChoiceImpl; -import mage.constants.AbilityType; import mage.constants.ColoredManaSymbol; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ManaEvent; import mage.players.Player; /** @@ -54,7 +51,11 @@ public class CommanderColorIdentityManaAbility extends ManaAbility { public CommanderColorIdentityManaAbility() { super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(),new TapSourceCost()); } - + + public CommanderColorIdentityManaAbility(Cost cost) { + super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), cost); + } + public CommanderColorIdentityManaAbility(final CommanderColorIdentityManaAbility ability) { super(ability); } diff --git a/Mage/src/mage/abilities/mana/ManaAbility.java b/Mage/src/mage/abilities/mana/ManaAbility.java index bccdaaf9a4..15affee8ef 100644 --- a/Mage/src/mage/abilities/mana/ManaAbility.java +++ b/Mage/src/mage/abilities/mana/ManaAbility.java @@ -58,7 +58,7 @@ public abstract class ManaAbility extends ActivatedAbilityImpl { } } - public ManaAbility(ManaAbility ability) { + public ManaAbility(final ManaAbility ability) { super(ability); this.netMana.addAll(ability.netMana); } diff --git a/Mage/src/mage/abilities/mana/SimpleManaAbility.java b/Mage/src/mage/abilities/mana/SimpleManaAbility.java index 289b1031b2..fdc58c9826 100644 --- a/Mage/src/mage/abilities/mana/SimpleManaAbility.java +++ b/Mage/src/mage/abilities/mana/SimpleManaAbility.java @@ -28,11 +28,14 @@ package mage.abilities.mana; +import java.util.List; import mage.Mana; import mage.abilities.costs.Cost; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.BasicManaEffect; import mage.abilities.effects.common.ManaEffect; import mage.constants.Zone; +import mage.game.Game; /** * @@ -58,4 +61,19 @@ public class SimpleManaAbility extends ManaAbility { return new SimpleManaAbility(this); } + @Override + public List getNetMana(Game game) { + if (netMana.isEmpty()) { + for (Effect effect: getEffects()) { + if (effect instanceof ManaEffect) { + Mana effectMana =((ManaEffect)effect).getMana(game, this); + if (effectMana != null) { + netMana.add(effectMana); + } + } + } + } + return netMana; + } + }