diff --git a/Mage.Sets/src/mage/sets/alarareborn/TraceOfAbundance.java b/Mage.Sets/src/mage/sets/alarareborn/TraceOfAbundance.java index 20aed299d9..4707f045e6 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/TraceOfAbundance.java +++ b/Mage.Sets/src/mage/sets/alarareborn/TraceOfAbundance.java @@ -31,6 +31,7 @@ import java.util.UUID; import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.AddManaAnyColorAttachedControllerEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; @@ -96,7 +97,7 @@ public class TraceOfAbundance extends CardImpl { class TraceOfAbundanceTriggeredAbility extends TriggeredManaAbility { public TraceOfAbundanceTriggeredAbility() { - super(Zone.BATTLEFIELD, new TraceOfAbundanceEffect()); + super(Zone.BATTLEFIELD, new AddManaAnyColorAttachedControllerEffect()); } public TraceOfAbundanceTriggeredAbility(final TraceOfAbundanceTriggeredAbility ability) { @@ -124,57 +125,3 @@ class TraceOfAbundanceTriggeredAbility extends TriggeredManaAbility { return "Whenever enchanted land is tapped for mana, its controller adds one mana of any color to his or her mana pool."; } } - -class TraceOfAbundanceEffect extends ManaEffect { - - public TraceOfAbundanceEffect() { - super(); - staticText = "its controller adds one mana of any color to his or her mana pool"; - } - - public TraceOfAbundanceEffect(final TraceOfAbundanceEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment != null) { - Permanent land = game.getPermanent(enchantment.getAttachedTo()); - if (land != null) { - Player player = game.getPlayer(land.getControllerId()); - if (player != null) { - ChoiceColor choice = new ChoiceColor(); - while (!player.choose(outcome, choice, game)) { - if (!player.isInGame()) { - return false; - } - } - int amount = 1; - Mana mana = null; - if (choice.getColor().isBlack()) { - mana = Mana.BlackMana(amount); - } else if (choice.getColor().isBlue()) { - mana = Mana.BlueMana(amount); - } else if (choice.getColor().isRed()) { - mana = Mana.RedMana(amount); - } else if (choice.getColor().isGreen()) { - mana = Mana.GreenMana(amount); - } else if (choice.getColor().isWhite()) { - mana = Mana.WhiteMana(amount); - } - if (player != null && mana != null) { - player.getManaPool().addMana(mana, game, source); - return true; - } - } - } - } - return false; - } - - @Override - public TraceOfAbundanceEffect copy() { - return new TraceOfAbundanceEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/MarkOfSakiko.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/MarkOfSakiko.java index e663d48bea..289dd783ad 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/MarkOfSakiko.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/MarkOfSakiko.java @@ -33,7 +33,7 @@ import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; @@ -108,7 +108,7 @@ class MarkOfSakikoTriggeredAbility extends TriggeredAbilityImpl { if (((DamagedPlayerEvent) event).isCombatDamage()) { if (event.getSourceId().equals(getSourceId())) { this.getEffects().clear(); - Effect effect = new AddManaToManaPoolEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true); + Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true); effect.setTargetPointer(new FixedTarget(getControllerId())); effect.setText("add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end"); this.addEffect(effect); diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/PetalmaneBaku.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/PetalmaneBaku.java index 9a408f6faf..b58ee477a4 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/PetalmaneBaku.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/PetalmaneBaku.java @@ -141,9 +141,16 @@ public class PetalmaneBaku extends CardImpl { return false; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + @Override public PetalmaneBakuManaEffect copy() { return new PetalmaneBakuManaEffect(this); } } + + } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakikoMotherOfSummer.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakikoMotherOfSummer.java index bf9948764d..8caa79eb15 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakikoMotherOfSummer.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakikoMotherOfSummer.java @@ -32,7 +32,7 @@ import mage.MageInt; import mage.Mana; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; @@ -99,7 +99,7 @@ class SakikoMotherOfSummerTriggeredAbility extends TriggeredAbilityImpl { Permanent creature = game.getPermanent(event.getSourceId()); if (creature != null && creature.getControllerId().equals(controllerId)) { this.getEffects().clear(); - Effect effect = new AddManaToManaPoolEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true); + Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true); effect.setTargetPointer(new FixedTarget(creature.getControllerId())); effect.setText("add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end"); this.addEffect(effect); diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakuraTribeSpringcaller.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakuraTribeSpringcaller.java index 7ee0a1b095..8404484395 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakuraTribeSpringcaller.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/SakuraTribeSpringcaller.java @@ -32,7 +32,7 @@ import mage.MageInt; import mage.Mana; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -56,7 +56,7 @@ public class SakuraTribeSpringcaller extends CardImpl { this.toughness = new MageInt(4); // At the beginning of your upkeep, add {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end. - Effect effect = new AddManaToManaPoolEffect(new Mana(Mana.GreenMana), "your", true); + Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(Mana.GreenMana), "your", true); effect.setText("add {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end"); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false)); } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShizukoCallerOfAutumn.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShizukoCallerOfAutumn.java index 26b476203e..95a2eb2e0f 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShizukoCallerOfAutumn.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShizukoCallerOfAutumn.java @@ -32,7 +32,7 @@ import mage.MageInt; import mage.Mana; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -57,7 +57,7 @@ public class ShizukoCallerOfAutumn extends CardImpl { this.toughness = new MageInt(3); // At the beginning of each player's upkeep, that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end. - Effect effect = new AddManaToManaPoolEffect(new Mana(0,3,0,0,0,0,0), "that player", true); + Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,3,0,0,0,0,0), "that player", true); effect.setText("that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end"); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, false)); diff --git a/Mage.Sets/src/mage/sets/bornofthegods/AstralCornucopia.java b/Mage.Sets/src/mage/sets/bornofthegods/AstralCornucopia.java index 2c58d2c07a..72046e837c 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/AstralCornucopia.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/AstralCornucopia.java @@ -186,10 +186,17 @@ class AstralCornucopiaManaEffect extends ManaEffect { break; } } - game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source); + checkToFirePossibleEvents(computedMana, game, source); + controller.getManaPool().addMana(computedMana, game, source); return true; } } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/HeartbeatOfSpring.java b/Mage.Sets/src/mage/sets/championsofkamigawa/HeartbeatOfSpring.java index 7f038d2d9f..2850ae8195 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/HeartbeatOfSpring.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/HeartbeatOfSpring.java @@ -28,23 +28,13 @@ package mage.sets.championsofkamigawa; import java.util.UUID; -import mage.Mana; -import mage.abilities.Abilities; -import mage.abilities.Ability; -import mage.abilities.effects.common.ManaEffect; -import mage.abilities.mana.ManaAbility; -import mage.abilities.mana.TriggeredManaAbility; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; +import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; import mage.cards.CardImpl; -import mage.choices.Choice; -import mage.choices.ChoiceImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.targetpointer.FixedTarget; +import mage.constants.SetTargetPointer; +import mage.filter.common.FilterLandPermanent; /** * @@ -56,8 +46,12 @@ public class HeartbeatOfSpring extends CardImpl { super(ownerId, 212, "Heartbeat of Spring", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); this.expansionSetCode = "CHK"; this.color.setGreen(true); + // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. - this.addAbility(new HeartbeatOfSpringAbility()); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaOfAnyColorTargetCanProduceEffect(), + new FilterLandPermanent("a player taps a land"), + SetTargetPointer.PERMANENT)); } public HeartbeatOfSpring(final HeartbeatOfSpring card) { @@ -69,122 +63,3 @@ public class HeartbeatOfSpring extends CardImpl { return new HeartbeatOfSpring(this); } } - -class HeartbeatOfSpringAbility extends TriggeredManaAbility { - - private static final String staticText = "Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced."; - - public HeartbeatOfSpringAbility() { - super(Zone.BATTLEFIELD, new HeartbeatOfSpringEffect()); - } - - public HeartbeatOfSpringAbility(HeartbeatOfSpringAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent == null) { - permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); - } - if (permanent != null && permanent.getCardType().contains(CardType.LAND)) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); - return true; - } - } - return false; - } - - @Override - public HeartbeatOfSpringAbility copy() { - return new HeartbeatOfSpringAbility(this); - } - - @Override - public String getRule() { - return staticText; - } -} - -class HeartbeatOfSpringEffect extends ManaEffect { - - public HeartbeatOfSpringEffect() { - super(); - staticText = "that player adds one mana to his or her mana pool of any type that land produced"; - } - - public HeartbeatOfSpringEffect(final HeartbeatOfSpringEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source)); - if (land != null) { - Abilities mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD); - Mana types = new Mana(); - for (ManaAbility ability : mana) { - for (Mana netMana: ability.getNetMana(game)) { - types.add(netMana); - } - } - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (types.getBlack() > 0) { - choice.getChoices().add("Black"); - } - if (types.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (types.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (types.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (types.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (types.getColorless() > 0) { - choice.getChoices().add("Colorless"); - } - if (choice.getChoices().size() > 0) { - Player player = game.getPlayer(land.getControllerId()); - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } else { - player.choose(outcome, choice, game); - } - switch (choice.getChoice()) { - case "Black": - player.getManaPool().addMana(Mana.BlackMana, game, source); - return true; - case "Blue": - player.getManaPool().addMana(Mana.BlueMana, game, source); - return true; - case "Red": - player.getManaPool().addMana(Mana.RedMana, game, source); - return true; - case "Green": - player.getManaPool().addMana(Mana.GreenMana, game, source); - return true; - case "White": - player.getManaPool().addMana(Mana.WhiteMana, game, source); - return true; - case "Colorless": - player.getManaPool().addMana(Mana.ColorlessMana, game, source); - return true; - } - } - return true; - } - return false; - } - - @Override - public HeartbeatOfSpringEffect copy() { - return new HeartbeatOfSpringEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/coldsnap/ColdsteelHeart.java b/Mage.Sets/src/mage/sets/coldsnap/ColdsteelHeart.java index 33be1dc2fe..14bfb69089 100644 --- a/Mage.Sets/src/mage/sets/coldsnap/ColdsteelHeart.java +++ b/Mage.Sets/src/mage/sets/coldsnap/ColdsteelHeart.java @@ -39,6 +39,7 @@ import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; @@ -89,27 +90,19 @@ class ColdsteelHeartManaEffect extends ManaEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); - switch(color.toString()) { - case "W": - player.getManaPool().addMana(Mana.WhiteMana, game, source); - break; - case "B": - player.getManaPool().addMana(Mana.BlackMana, game, source); - break; - case "U": - player.getManaPool().addMana(Mana.BlueMana, game, source); - break; - case "G": - player.getManaPool().addMana(Mana.GreenMana, game, source); - break; - case "R": - player.getManaPool().addMana(Mana.RedMana, game, source); - break; - } - return true; + player.getManaPool().addMana(getMana(game, source), game, source); + } + return true; + } + + @Override + public Mana getMana(Game game, Ability source) { + ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); + if (color != null) { + return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0))); + } else { + return null; } - return false; } @Override diff --git a/Mage.Sets/src/mage/sets/coldsnap/RiteOfFlame.java b/Mage.Sets/src/mage/sets/coldsnap/RiteOfFlame.java index 9893044eee..4ca7e46e84 100644 --- a/Mage.Sets/src/mage/sets/coldsnap/RiteOfFlame.java +++ b/Mage.Sets/src/mage/sets/coldsnap/RiteOfFlame.java @@ -100,4 +100,10 @@ class RiteOfFlameManaEffect extends ManaEffect { public RiteOfFlameManaEffect copy() { return new RiteOfFlameManaEffect(this); } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/commander/DreadshipReef.java b/Mage.Sets/src/mage/sets/commander/DreadshipReef.java index b7f12b3a29..1e7a8d0e5d 100644 --- a/Mage.Sets/src/mage/sets/commander/DreadshipReef.java +++ b/Mage.Sets/src/mage/sets/commander/DreadshipReef.java @@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; -import mage.abilities.effects.common.ManaInAnyCombinationEffect; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -62,7 +62,7 @@ public class DreadshipReef extends CardImpl { this.addAbility(ability); // {1}, Remove X storage counters from Dreadship Reef: Add X mana in any combination of {U} and/or {B} to your mana pool. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.U, ColoredManaSymbol.B), + new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.U, ColoredManaSymbol.B), new GenericManaCost(1)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/commander/FungalReaches.java b/Mage.Sets/src/mage/sets/commander/FungalReaches.java index 57c9f055a9..275bb376e6 100644 --- a/Mage.Sets/src/mage/sets/commander/FungalReaches.java +++ b/Mage.Sets/src/mage/sets/commander/FungalReaches.java @@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; -import mage.abilities.effects.common.ManaInAnyCombinationEffect; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -64,7 +64,7 @@ public class FungalReaches extends CardImpl { // {1}, Remove X storage counters from Fungal Reaches: Add X mana in any combination of {R} and/or {G} to your mana pool. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.R, ColoredManaSymbol.G), + new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.R, ColoredManaSymbol.G), new GenericManaCost(1)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/commander/MagusOfTheVineyard.java b/Mage.Sets/src/mage/sets/commander/MagusOfTheVineyard.java index c258310c31..6b30f4561a 100644 --- a/Mage.Sets/src/mage/sets/commander/MagusOfTheVineyard.java +++ b/Mage.Sets/src/mage/sets/commander/MagusOfTheVineyard.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.MageInt; import static mage.Mana.GreenMana; import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -56,7 +56,7 @@ public class MagusOfTheVineyard extends CardImpl { // At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool. this.addAbility(new BeginningOfPreCombatMainTriggeredAbility( - Zone.BATTLEFIELD, new AddManaToManaPoolEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true)); + Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true)); } public MagusOfTheVineyard(final MagusOfTheVineyard card) { diff --git a/Mage.Sets/src/mage/sets/commander/ScatteringStroke.java b/Mage.Sets/src/mage/sets/commander/ScatteringStroke.java index 16a3e42ec0..43f2c5e821 100644 --- a/Mage.Sets/src/mage/sets/commander/ScatteringStroke.java +++ b/Mage.Sets/src/mage/sets/commander/ScatteringStroke.java @@ -33,7 +33,8 @@ import mage.abilities.Ability; import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.ClashEffect; import mage.cards.CardImpl; import mage.constants.CardType; @@ -97,8 +98,7 @@ class ScatteringStrokeEffect extends OneShotEffect { if (controller != null && spell != null) { game.getStack().counter(spell.getId(), source.getSourceId(), game); if (ClashEffect.getInstance().apply(game, source)) { - Effect effect = new AddManaToManaPoolEffect(new Mana(0,0,0,0,0,spell.getConvertedManaCost(),0), "your"); - effect.setTargetPointer(new FixedTarget(source.getControllerId())); + Effect effect = new AddManaToManaPoolSourceControllerEffect(new Mana(0,0,0,0,0,spell.getConvertedManaCost(),0)); AtTheBeginOMainPhaseDelayedTriggeredAbility delayedAbility = new AtTheBeginOMainPhaseDelayedTriggeredAbility(effect, true, TargetController.YOU, AtTheBeginOMainPhaseDelayedTriggeredAbility.PhaseSelection.NEXT_MAIN); delayedAbility.setSourceId(source.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/commander2013/MoltenSlagheap.java b/Mage.Sets/src/mage/sets/commander2013/MoltenSlagheap.java index c17cd11b95..f7e82a2415 100644 --- a/Mage.Sets/src/mage/sets/commander2013/MoltenSlagheap.java +++ b/Mage.Sets/src/mage/sets/commander2013/MoltenSlagheap.java @@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; -import mage.abilities.effects.common.ManaInAnyCombinationEffect; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -62,7 +62,7 @@ public class MoltenSlagheap extends CardImpl { this.addAbility(ability); // {1}, Remove X storage counters from Molten Slagheap: Add X mana in any combination of {B} and/or {R} to your mana pool. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.B, ColoredManaSymbol.R), + new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.B, ColoredManaSymbol.R), new GenericManaCost(1)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java b/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java index 7dbb734fc9..d3852b649f 100644 --- a/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java +++ b/Mage.Sets/src/mage/sets/commander2013/OpalPalace.java @@ -152,6 +152,7 @@ class OpalPalaceManaEffect extends ManaEffect { } // set to indicate, that the mana can boost the commander mana.setFlag(true); + checkToFirePossibleEvents(mana, game, source); controller.getManaPool().addMana(mana, game, source); } @@ -160,6 +161,13 @@ class OpalPalaceManaEffect extends ManaEffect { } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + } class OpalPalaceWatcher extends Watcher { diff --git a/Mage.Sets/src/mage/sets/commander2013/SaltcrustedSteppe.java b/Mage.Sets/src/mage/sets/commander2013/SaltcrustedSteppe.java index 9c1fd1b216..75920199ae 100644 --- a/Mage.Sets/src/mage/sets/commander2013/SaltcrustedSteppe.java +++ b/Mage.Sets/src/mage/sets/commander2013/SaltcrustedSteppe.java @@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; -import mage.abilities.effects.common.ManaInAnyCombinationEffect; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -62,7 +62,7 @@ public class SaltcrustedSteppe extends CardImpl { this.addAbility(ability); // {1}, Remove X storage counters from Saltcrusted Steppe: Add X mana in any combination of {G} and/or {W} to your mana pool. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.G, ColoredManaSymbol.W), + new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.G, ColoredManaSymbol.W), new GenericManaCost(1)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/commander2014/MagusOfTheCoffers.java b/Mage.Sets/src/mage/sets/commander2014/MagusOfTheCoffers.java index 63d1f525a8..9b0a087aa2 100644 --- a/Mage.Sets/src/mage/sets/commander2014/MagusOfTheCoffers.java +++ b/Mage.Sets/src/mage/sets/commander2014/MagusOfTheCoffers.java @@ -34,12 +34,10 @@ import mage.abilities.Ability; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; -import mage.abilities.effects.common.DynamicManaEffect; -import mage.abilities.mana.SimpleManaAbility; +import mage.abilities.mana.DynamicManaAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -66,9 +64,7 @@ public class MagusOfTheCoffers extends CardImpl { this.toughness = new MageInt(4); // {2}, {T}: Add {B} to your mana pool for each Swamp you control. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, - new DynamicManaEffect(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter)), - new GenericManaCost(2)); + Ability ability = new DynamicManaAbility(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter), new GenericManaCost(2)); ability.addCost(new TapSourceCost()); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/darkascension/CurseOfBloodletting.java b/Mage.Sets/src/mage/sets/darkascension/CurseOfBloodletting.java index 214f7e981c..522e49f38d 100644 --- a/Mage.Sets/src/mage/sets/darkascension/CurseOfBloodletting.java +++ b/Mage.Sets/src/mage/sets/darkascension/CurseOfBloodletting.java @@ -28,18 +28,21 @@ package mage.sets.darkascension; import java.util.UUID; - -import mage.constants.*; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.AttachEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import static mage.game.events.GameEvent.EventType.DAMAGE_PLAYER; import mage.game.permanent.Permanent; -import mage.game.stack.StackObject; import mage.players.Player; import mage.target.TargetPlayer; @@ -98,11 +101,10 @@ class CurseOfBloodlettingEffect extends ReplacementEffectImpl { switch (event.getType()) { case DAMAGE_PLAYER: Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment != null && enchantment.getAttachedTo() != null) { - Player player = game.getPlayer(enchantment.getAttachedTo()); - if (player != null && event.getTargetId().equals(player.getId())) { - event.setAmount(event.getAmount() * 2); - } + if (enchantment != null && + enchantment.getAttachedTo() != null && + event.getTargetId().equals(enchantment.getAttachedTo())) { + return true; } } return false; @@ -115,7 +117,8 @@ class CurseOfBloodlettingEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return apply(game, source); + event.setAmount(event.getAmount() * 2); + return false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/dissension/UtopiaSprawl.java b/Mage.Sets/src/mage/sets/dissension/UtopiaSprawl.java index dc6a707faf..5137108041 100644 --- a/Mage.Sets/src/mage/sets/dissension/UtopiaSprawl.java +++ b/Mage.Sets/src/mage/sets/dissension/UtopiaSprawl.java @@ -43,6 +43,7 @@ import mage.abilities.keyword.EnchantAbility; import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; import mage.choices.ChoiceColor; +import mage.constants.ColoredManaSymbol; import mage.constants.Outcome; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -180,24 +181,7 @@ class UtopiaSprawlEffect extends ManaEffect { if(land != null){ Player player = game.getPlayer(land.getControllerId()); if (player != null) { - ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); - switch(color.toString()) { - case "W": - player.getManaPool().addMana(Mana.WhiteMana, game, source); - break; - case "B": - player.getManaPool().addMana(Mana.BlackMana, game, source); - break; - case "U": - player.getManaPool().addMana(Mana.BlueMana, game, source); - break; - case "G": - player.getManaPool().addMana(Mana.GreenMana, game, source); - break; - case "R": - player.getManaPool().addMana(Mana.RedMana, game, source); - break; - } + player.getManaPool().addMana(getMana(game, source), game, source); return true; } } @@ -205,6 +189,16 @@ class UtopiaSprawlEffect extends ManaEffect { return false; } + @Override + public Mana getMana(Game game, Ability source) { + ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); + if (color != null) { + return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0))); + } else { + return null; + } + } + @Override public UtopiaSprawlEffect copy() { return new UtopiaSprawlEffect(this); diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java b/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java index 212489fd14..503bba812c 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java @@ -160,4 +160,10 @@ class PlasmCaptureManaEffect extends ManaEffect { } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + } diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/ZhurTaaAncient.java b/Mage.Sets/src/mage/sets/dragonsmaze/ZhurTaaAncient.java index 1af4290f4a..e844d069cf 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/ZhurTaaAncient.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/ZhurTaaAncient.java @@ -28,25 +28,14 @@ package mage.sets.dragonsmaze; import java.util.UUID; - +import mage.MageInt; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; +import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; +import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.MageInt; -import mage.Mana; -import mage.abilities.Abilities; -import mage.abilities.Ability; -import mage.abilities.effects.common.ManaEffect; -import mage.abilities.mana.ManaAbility; -import mage.abilities.mana.TriggeredManaAbility; -import mage.cards.CardImpl; -import mage.choices.Choice; -import mage.choices.ChoiceImpl; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.targetpointer.FixedTarget; +import mage.constants.SetTargetPointer; +import mage.filter.common.FilterLandPermanent; /** * @@ -65,7 +54,10 @@ public class ZhurTaaAncient extends CardImpl { this.toughness = new MageInt(5); // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. - this.addAbility(new ZhurTaaAncientAbility()); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaOfAnyColorTargetCanProduceEffect(), + new FilterLandPermanent("a player taps a land"), + SetTargetPointer.PERMANENT)); } public ZhurTaaAncient(final ZhurTaaAncient card) { @@ -77,119 +69,3 @@ public class ZhurTaaAncient extends CardImpl { return new ZhurTaaAncient(this); } } - -class ZhurTaaAncientAbility extends TriggeredManaAbility { - - private static final String staticText = "Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced."; - - public ZhurTaaAncientAbility() { - super(Zone.BATTLEFIELD, new ZhurTaaAncientEffect()); - } - - public ZhurTaaAncientAbility(ZhurTaaAncientAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent == null) { - permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); - } - if (permanent != null && permanent.getCardType().contains(CardType.LAND)) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); - return true; - } - } - return false; - } - - @Override - public ZhurTaaAncientAbility copy() { - return new ZhurTaaAncientAbility(this); - } - - @Override - public String getRule() { - return staticText; - } -} - -class ZhurTaaAncientEffect extends ManaEffect { - - public ZhurTaaAncientEffect() { - super(); - staticText = "that player adds one mana to his or her mana pool of any type that land produced"; - } - - public ZhurTaaAncientEffect(final ZhurTaaAncientEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source)); - Abilities mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD); - Mana types = new Mana(); - for (ManaAbility ability : mana) { - for (Mana netMana: ability.getNetMana(game)) { - types.add(netMana); - } - } - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (types.getBlack() > 0) { - choice.getChoices().add("Black"); - } - if (types.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (types.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (types.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (types.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (types.getColorless() > 0) { - choice.getChoices().add("Colorless"); - } - if (choice.getChoices().size() > 0) { - Player player = game.getPlayer(land.getControllerId()); - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } else { - player.choose(outcome, choice, game); - } - switch (choice.getChoice()) { - case "Black": - player.getManaPool().addMana(Mana.BlackMana, game, source); - return true; - case "Blue": - player.getManaPool().addMana(Mana.BlueMana, game, source); - return true; - case "Red": - player.getManaPool().addMana(Mana.RedMana, game, source); - return true; - case "Green": - player.getManaPool().addMana(Mana.GreenMana, game, source); - return true; - case "White": - player.getManaPool().addMana(Mana.WhiteMana, game, source); - return true; - case "Colorless": - player.getManaPool().addMana(Mana.ColorlessMana, game, source); - return true; - } - } - return true; - } - - @Override - public ZhurTaaAncientEffect copy() { - return new ZhurTaaAncientEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/eventide/BloomTender.java b/Mage.Sets/src/mage/sets/eventide/BloomTender.java index 4d66f22e02..132cd3af2f 100644 --- a/Mage.Sets/src/mage/sets/eventide/BloomTender.java +++ b/Mage.Sets/src/mage/sets/eventide/BloomTender.java @@ -58,7 +58,7 @@ public class BloomTender extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); - // {tap}: For each color among permanents you control, add one mana of that color to your mana pool. + // {T}: For each color among permanents you control, add one mana of that color to your mana pool. this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new BloomTenderEffect(), new TapSourceCost())); } @@ -91,10 +91,22 @@ class BloomTenderEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Mana mana = getMana(game, source); + checkToFirePossibleEvents(mana, game, source); + controller.getManaPool().addMana(mana, game, source); + return true; + } + return false; + } + + @Override + public Mana getMana(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { Mana mana = new Mana(); - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(you.getId())) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) { if (mana.getBlack() == 0 && permanent.getColor().isBlack()) { mana.addBlack(); } @@ -111,9 +123,10 @@ class BloomTenderEffect extends ManaEffect { mana.addWhite(); } } - you.getManaPool().addMana(mana, game, source); - return true; + return mana; } - return false; + return null; } + + } diff --git a/Mage.Sets/src/mage/sets/fallenempires/HighTide.java b/Mage.Sets/src/mage/sets/fallenempires/HighTide.java index eadcfa322c..73cc0684a8 100644 --- a/Mage.Sets/src/mage/sets/fallenempires/HighTide.java +++ b/Mage.Sets/src/mage/sets/fallenempires/HighTide.java @@ -32,19 +32,18 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.Mana; -import mage.abilities.Ability; import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; -import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.DelayedTriggeredManaAbility; import mage.cards.CardImpl; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.targetpointer.FixedTarget; /** @@ -77,12 +76,13 @@ public class HighTide extends CardImpl { class HighTideTriggeredAbility extends DelayedTriggeredManaAbility { private static final FilterLandPermanent filter = new FilterLandPermanent("Island"); + static { filter.add(new SubtypePredicate("Island")); } public HighTideTriggeredAbility() { - super(new AddBlueToTargetEffect(), Duration.EndOfTurn, false); + super(new AddManaToManaPoolTargetControllerEffect(new Mana(ColoredManaSymbol.U), "his or her"), Duration.EndOfTurn, false); this.usesStack = false; } @@ -112,34 +112,3 @@ class HighTideTriggeredAbility extends DelayedTriggeredManaAbility { return "Until end of turn, whenever a player taps an Island for mana, that player adds {U} to his or her mana pool"; } } - -class AddBlueToTargetEffect extends ManaEffect { - - - public AddBlueToTargetEffect() { - super(); - staticText = "that player adds {U} to his or her mana pool"; - } - - - public AddBlueToTargetEffect(final AddBlueToTargetEffect effect) { - super(effect); - } - - @Override - public AddBlueToTargetEffect copy() { - return new AddBlueToTargetEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - if(player != null) - { - player.getManaPool().addMana(Mana.BlueMana(1), game, source); - - } - return true; - } - -} diff --git a/Mage.Sets/src/mage/sets/fifthdawn/ChannelTheSuns.java b/Mage.Sets/src/mage/sets/fifthdawn/ChannelTheSuns.java index 573de83199..d90476041b 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/ChannelTheSuns.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/ChannelTheSuns.java @@ -29,7 +29,7 @@ package mage.sets.fifthdawn; import mage.Mana; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.AddManaToControllersManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -49,7 +49,7 @@ public class ChannelTheSuns extends CardImpl { this.color.setGreen(true); // Add {W}{U}{B}{R}{G} to your mana pool. - Effect effect = new AddManaToControllersManaPoolEffect(new Mana(1, 1, 1, 1, 1, 0, 0)); + Effect effect = new AddManaToManaPoolSourceControllerEffect(new Mana(1, 1, 1, 1, 1, 0, 0)); this.getSpellAbility().addEffect(effect); } diff --git a/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java b/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java index e924d59bf5..c499b810fa 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java @@ -160,4 +160,11 @@ class DawnsReflectionManaEffect extends ManaEffect { } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + } diff --git a/Mage.Sets/src/mage/sets/gatecrash/GyreSage.java b/Mage.Sets/src/mage/sets/gatecrash/GyreSage.java index 5e0ba86b04..3382bcc437 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/GyreSage.java +++ b/Mage.Sets/src/mage/sets/gatecrash/GyreSage.java @@ -1,4 +1,4 @@ -/* + /* /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * diff --git a/Mage.Sets/src/mage/sets/gatecrash/VerdantHaven.java b/Mage.Sets/src/mage/sets/gatecrash/VerdantHaven.java index 73360d9bf9..12b13d025c 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/VerdantHaven.java +++ b/Mage.Sets/src/mage/sets/gatecrash/VerdantHaven.java @@ -28,25 +28,21 @@ package mage.sets.gatecrash; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; -import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.common.AddManaAnyColorAttachedControllerEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.GainLifeEffect; -import mage.abilities.effects.common.ManaEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; -import mage.choices.ChoiceColor; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetLandPermanent; @@ -90,7 +86,7 @@ public class VerdantHaven extends CardImpl { class VerdantHavenTriggeredAbility extends TriggeredManaAbility { public VerdantHavenTriggeredAbility() { - super(Zone.BATTLEFIELD, new VerdantHavenManaEffect()); + super(Zone.BATTLEFIELD, new AddManaAnyColorAttachedControllerEffect()); } public VerdantHavenTriggeredAbility(final VerdantHavenTriggeredAbility ability) { @@ -119,57 +115,3 @@ class VerdantHavenTriggeredAbility extends TriggeredManaAbility { return "Whenever enchanted land is tapped for mana, its controller adds one mana of any color to his or her mana pool."; } } - -class VerdantHavenManaEffect extends ManaEffect { - - public VerdantHavenManaEffect() { - super(); - staticText = "its controller adds one mana of any color to his or her mana pool"; - } - - public VerdantHavenManaEffect(final VerdantHavenManaEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if(enchantment != null){ - Permanent land = game.getPermanent(enchantment.getAttachedTo()); - if(land != null){ - Player player = game.getPlayer(land.getControllerId()); - if (player != null) { - ChoiceColor choice = new ChoiceColor(); - while (!player.choose(outcome, choice, game)) { - if (!player.isInGame()) { - return false; - } - } - int amount = 1; - Mana mana = null; - if (choice.getColor().isBlack()) { - mana = Mana.BlackMana(amount); - } else if (choice.getColor().isBlue()) { - mana = Mana.BlueMana(amount); - } else if (choice.getColor().isRed()) { - mana = Mana.RedMana(amount); - } else if (choice.getColor().isGreen()) { - mana = Mana.GreenMana(amount); - } else if (choice.getColor().isWhite()) { - mana = Mana.WhiteMana(amount); - } - if (player != null && mana != null) { - player.getManaPool().addMana(mana, game, source); - return true; - } - } - } - } - return false; - } - - @Override - public VerdantHavenManaEffect copy() { - return new VerdantHavenManaEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java b/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java index 08793e14e3..1228a3aa73 100644 --- a/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java +++ b/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java @@ -115,8 +115,8 @@ class OrcishLumberjackManaEffect extends ManaEffect { manaChoice.setChoices(choices); manaChoice.setMessage("Select color of mana to add"); - for(int i = 0; i < 3; i++){ - Mana mana = new Mana(); + Mana mana = new Mana(); + for(int i = 0; i < 3; i++){ while (!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.isInGame()) { return false; @@ -130,10 +130,19 @@ class OrcishLumberjackManaEffect extends ManaEffect { mana.addRed(); break; } - player.getManaPool().addMana(mana, game, source); + } + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); return true; } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + } diff --git a/Mage.Sets/src/mage/sets/iceage/WildGrowth.java b/Mage.Sets/src/mage/sets/iceage/WildGrowth.java index 6615096b78..6f59e2ae67 100644 --- a/Mage.Sets/src/mage/sets/iceage/WildGrowth.java +++ b/Mage.Sets/src/mage/sets/iceage/WildGrowth.java @@ -33,11 +33,13 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.Mana; import mage.abilities.Ability; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ManaEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; +import mage.constants.ColoredManaSymbol; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; @@ -84,7 +86,7 @@ class WildGrowthTriggeredAbility extends TriggeredManaAbility { public WildGrowthTriggeredAbility() { - super(Zone.BATTLEFIELD, new WildGrowthEffect()); + super(Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(new Mana(ColoredManaSymbol.G), "his or her")); } public WildGrowthTriggeredAbility(final WildGrowthTriggeredAbility ability) { @@ -113,36 +115,3 @@ class WildGrowthTriggeredAbility extends TriggeredManaAbility { return "Whenever enchanted land is tapped for mana, its controller adds {G} to his or her mana pool"; } } - -class WildGrowthEffect extends ManaEffect { - - public WildGrowthEffect() { - super(); - staticText = "its controller adds {G} to his or her mana pool"; - } - - public WildGrowthEffect(final WildGrowthEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if(enchantment != null){ - Permanent land = game.getPermanent(enchantment.getAttachedTo()); - if(land != null){ - Player player = game.getPlayer(land.getControllerId()); - if (player != null) { - player.getManaPool().addMana(Mana.GreenMana, game, source); - return true; - } - } - } - return false; - } - - @Override - public WildGrowthEffect copy() { - return new WildGrowthEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfKarametra.java b/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfKarametra.java index fe8a04fc0a..dbc335daec 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfKarametra.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfKarametra.java @@ -28,12 +28,14 @@ package mage.sets.journeyintonyx; import java.util.UUID; -import mage.abilities.common.TapLandForManaAllTriggeredManaAbility; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; import mage.abilities.keyword.FlashAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; +import mage.constants.SetTargetPointer; +import mage.filter.common.FilterLandPermanent; /** * @@ -50,7 +52,10 @@ public class DictateOfKarametra extends CardImpl { // Flash this.addAbility(FlashAbility.getInstance()); // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. - this.addAbility(new TapLandForManaAllTriggeredManaAbility(new AddManaOfAnyColorTargetCanProduceEffect(), false, true)); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaOfAnyColorTargetCanProduceEffect(), + new FilterLandPermanent("a player taps a land"), + SetTargetPointer.PERMANENT)); } diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java b/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java index 2116abb39e..ab27a8de48 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java @@ -165,11 +165,17 @@ class MarketFestivalManaEffect extends ManaEffect { mana.addWhite(); } } - + checkToFirePossibleEvents(mana, game, source); controller.getManaPool().addMana(mana, game, source); return true; } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + } diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/RevelOfTheFallenGod.java b/Mage.Sets/src/mage/sets/journeyintonyx/RevelOfTheFallenGod.java index d86fbdd98c..bb7af5ad49 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/RevelOfTheFallenGod.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/RevelOfTheFallenGod.java @@ -69,7 +69,7 @@ class RevelOfTheFallenGodSatyrToken extends Token { public RevelOfTheFallenGodSatyrToken() { super("Satyr", "2/2 red and green Satyr creature tokens with haste"); - this.setOriginalExpansionSetCode("JOU"); + this.setOriginalExpansionSetCode("THS"); cardType.add(CardType.CREATURE); color.setColor(ObjectColor.RED); color.setColor(ObjectColor.GREEN); diff --git a/Mage.Sets/src/mage/sets/judgment/MirarisWake.java b/Mage.Sets/src/mage/sets/judgment/MirarisWake.java index bd4c2c4f90..27cf5bff08 100644 --- a/Mage.Sets/src/mage/sets/judgment/MirarisWake.java +++ b/Mage.Sets/src/mage/sets/judgment/MirarisWake.java @@ -28,26 +28,17 @@ package mage.sets.judgment; import java.util.UUID; -import mage.Mana; -import mage.abilities.Abilities; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.common.ManaEffect; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; +import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; import mage.abilities.effects.common.continious.BoostControlledEffect; -import mage.abilities.mana.ManaAbility; -import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; -import mage.choices.Choice; -import mage.choices.ChoiceImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; +import mage.constants.SetTargetPointer; import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.targetpointer.FixedTarget; +import mage.filter.common.FilterControlledLandPermanent; /** * @@ -65,7 +56,10 @@ public class MirarisWake extends CardImpl { // Creatures you control get +1/+1. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1,1,Duration.WhileOnBattlefield))); // Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced. - this.addAbility(new MirarisWakeManaAbility()); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaOfAnyColorTargetCanProduceEffect(), + new FilterControlledLandPermanent("you tap a land"), + SetTargetPointer.PERMANENT)); } @@ -78,117 +72,3 @@ public class MirarisWake extends CardImpl { return new MirarisWake(this); } } -class MirarisWakeManaAbility extends TriggeredManaAbility { - - private static final String staticText = "Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced."; - - public MirarisWakeManaAbility() { - super(Zone.BATTLEFIELD, new MirarisWakeManaEffect()); - } - - public MirarisWakeManaAbility(MirarisWakeManaAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && event.getPlayerId().equals(controllerId)) { - Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); - if (permanent != null && permanent.getCardType().contains(CardType.LAND)) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); - return true; - } - } - return false; - } - - @Override - public MirarisWakeManaAbility copy() { - return new MirarisWakeManaAbility(this); - } - - @Override - public String getRule() { - return staticText; - } -} - - -class MirarisWakeManaEffect extends ManaEffect { - - public MirarisWakeManaEffect() { - super(); - staticText = "add one mana to your mana pool of any type that land produced"; - } - - public MirarisWakeManaEffect(final MirarisWakeManaEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source)); - Abilities mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD); - Mana types = new Mana(); - for (ManaAbility ability: mana) { - for (Mana netMana: ability.getNetMana(game)) { - types.add(netMana); - } - } - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (types.getBlack() > 0) { - choice.getChoices().add("Black"); - } - if (types.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (types.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (types.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (types.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (types.getColorless() > 0) { - choice.getChoices().add("Colorless"); - } - if (choice.getChoices().size() > 0) { - Player player = game.getPlayer(source.getControllerId()); - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } else { - player.choose(outcome, choice, game); - } - switch (choice.getChoice()) { - case "Black": - player.getManaPool().addMana(Mana.BlackMana, game, source); - return true; - case "Blue": - player.getManaPool().addMana(Mana.BlueMana, game, source); - return true; - case "Red": - player.getManaPool().addMana(Mana.RedMana, game, source); - return true; - case "Green": - player.getManaPool().addMana(Mana.GreenMana, game, source); - return true; - case "White": - player.getManaPool().addMana(Mana.WhiteMana, game, source); - return true; - case "Colorless": - player.getManaPool().addMana(Mana.ColorlessMana, game, source); - return true; - } - } - return true; - } - - @Override - public MirarisWakeManaEffect copy() { - return new MirarisWakeManaEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/MarduWarshrieker.java b/Mage.Sets/src/mage/sets/khansoftarkir/MarduWarshrieker.java index 2ffbb8667e..38ee5baae0 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/MarduWarshrieker.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/MarduWarshrieker.java @@ -33,7 +33,7 @@ import mage.Mana; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.condition.common.RaidCondition; import mage.abilities.decorator.ConditionalTriggeredAbility; -import mage.abilities.effects.common.AddManaToControllersManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -56,7 +56,7 @@ public class MarduWarshrieker extends CardImpl { this.toughness = new MageInt(3); // Raid - When Mardu Warshrieker enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool. - this.addAbility(new ConditionalTriggeredAbility(new EntersBattlefieldTriggeredAbility(new AddManaToControllersManaPoolEffect(new Mana(1,0,0,1,1,0,0))), RaidCondition.getInstance(), + this.addAbility(new ConditionalTriggeredAbility(new EntersBattlefieldTriggeredAbility(new AddManaToManaPoolSourceControllerEffect(new Mana(1,0,0,1,1,0,0))), RaidCondition.getInstance(), "Raid - When {this} enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool.", false)); this.addWatcher(new PlayerAttackedWatcher()); } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/RattleclawMystic.java b/Mage.Sets/src/mage/sets/khansoftarkir/RattleclawMystic.java index e053267f4a..debc565a3f 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/RattleclawMystic.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/RattleclawMystic.java @@ -32,7 +32,7 @@ import mage.MageInt; import mage.Mana; import mage.abilities.common.TurnedFaceUpSourceTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.common.AddManaToControllersManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect; import mage.abilities.keyword.MorphAbility; import mage.abilities.mana.BlueManaAbility; import mage.abilities.mana.GreenManaAbility; @@ -66,7 +66,7 @@ public class RattleclawMystic extends CardImpl { this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}"))); // When Rattleclaw Mystic is turned face up, add {G}{U}{R} to your mana pool. - this.addAbility(new TurnedFaceUpSourceTriggeredAbility(new AddManaToControllersManaPoolEffect(new Mana(1,1,1,0,0,0,0)))); + this.addAbility(new TurnedFaceUpSourceTriggeredAbility(new AddManaToManaPoolSourceControllerEffect(new Mana(1,1,1,0,0,0,0)))); } diff --git a/Mage.Sets/src/mage/sets/legions/WirewoodChanneler.java b/Mage.Sets/src/mage/sets/legions/WirewoodChanneler.java index 247ba712a4..b3af010a32 100644 --- a/Mage.Sets/src/mage/sets/legions/WirewoodChanneler.java +++ b/Mage.Sets/src/mage/sets/legions/WirewoodChanneler.java @@ -30,20 +30,13 @@ package mage.sets.legions; import java.util.UUID; import mage.MageInt; import mage.Mana; -import mage.abilities.Ability; -import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.common.ManaEffect; -import mage.abilities.mana.SimpleManaAbility; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.mana.DynamicManaAbility; import mage.cards.CardImpl; -import mage.choices.ChoiceColor; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; import mage.filter.FilterPermanent; -import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.players.Player; /** * @@ -51,6 +44,12 @@ import mage.players.Player; */ public class WirewoodChanneler extends CardImpl { + private static final FilterPermanent filter = new FilterPermanent("Elves"); + + static { + filter.add(new SubtypePredicate(("Elf"))); + } + public WirewoodChanneler(UUID ownerId) { super(ownerId, 144, "Wirewood Channeler", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{G}"); this.expansionSetCode = "LGN"; @@ -61,9 +60,9 @@ public class WirewoodChanneler extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); - // {tap}: Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new WirewoodChannelerManaEffect(), new TapSourceCost()); - ability.addChoice(new ChoiceColor()); + // {T}: Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield. + DynamicManaAbility ability = new DynamicManaAbility(new Mana(0,0,0,0,0,0,1), new PermanentsOnBattlefieldCount(filter), + "Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield"); this.addAbility(ability); } @@ -76,50 +75,3 @@ public class WirewoodChanneler extends CardImpl { return new WirewoodChanneler(this); } } - - -class WirewoodChannelerManaEffect extends ManaEffect { - private static final FilterPermanent filter = new FilterPermanent(); - - static { - filter.add(new SubtypePredicate("Elf")); - } - - WirewoodChannelerManaEffect() { - super(); - staticText = "Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield"; - } - - WirewoodChannelerManaEffect(final WirewoodChannelerManaEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - ChoiceColor choice = (ChoiceColor) source.getChoices().get(0); - Player player = game.getPlayer(source.getControllerId()); - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); - if (choice.getColor().isBlack()) { - player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source); - return true; - } else if (choice.getColor().isBlue()) { - player.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isRed()) { - player.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isGreen()) { - player.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isWhite()) { - player.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source); - return true; - } - return false; - } - - @Override - public WirewoodChannelerManaEffect copy() { - return new WirewoodChannelerManaEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/magic2010/DjinnOfWishes.java b/Mage.Sets/src/mage/sets/magic2010/DjinnOfWishes.java index 05838cacf2..82d9180f71 100644 --- a/Mage.Sets/src/mage/sets/magic2010/DjinnOfWishes.java +++ b/Mage.Sets/src/mage/sets/magic2010/DjinnOfWishes.java @@ -56,7 +56,7 @@ import mage.players.Player; */ public class DjinnOfWishes extends CardImpl { - private static final String ruleText = "Djinn of Wishes enters the battlefield with three wish counters on it"; + private static final String ruleText = "{this} enters the battlefield with three wish counters on it"; public DjinnOfWishes(UUID ownerId) { super(ownerId, 50, "Djinn of Wishes", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}{U}"); diff --git a/Mage.Sets/src/mage/sets/magic2014/BurningEarth.java b/Mage.Sets/src/mage/sets/magic2014/BurningEarth.java index 53d6266dc1..4737d18cd1 100644 --- a/Mage.Sets/src/mage/sets/magic2014/BurningEarth.java +++ b/Mage.Sets/src/mage/sets/magic2014/BurningEarth.java @@ -28,16 +28,13 @@ package mage.sets.magic2014; import java.util.UUID; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.TapForManaAllTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.target.targetpointer.FixedTarget; +import mage.constants.SetTargetPointer; +import mage.filter.common.FilterNonlandPermanent; /** * @@ -52,7 +49,10 @@ public class BurningEarth extends CardImpl { this.color.setRed(true); // Whenever a player taps a nonbasic land for mana, Burning Earth deals 1 damage to that player. - this.addAbility(new BurningEarthTriggeredAbility()); + this.addAbility(new TapForManaAllTriggeredAbility( + new DamageTargetEffect(1, true, "that player"), + new FilterNonlandPermanent("a player taps a nonbasic land"), + SetTargetPointer.PLAYER)); } public BurningEarth(final BurningEarth card) { @@ -64,41 +64,3 @@ public class BurningEarth extends CardImpl { return new BurningEarth(this); } } - -class BurningEarthTriggeredAbility extends TriggeredAbilityImpl { - - public BurningEarthTriggeredAbility() { - super(Zone.BATTLEFIELD, new DamageTargetEffect(1)); - } - - public BurningEarthTriggeredAbility(BurningEarthTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent == null) { - permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); - } - if (permanent != null - && permanent.getCardType().contains(CardType.LAND) - && !permanent.getSupertype().contains("Basic")) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId())); - return true; - } - } - return false; - } - - @Override - public BurningEarthTriggeredAbility copy() { - return new BurningEarthTriggeredAbility(this); - } - - @Override - public String getRule() { - return "Whenever a player taps a nonbasic land for mana, {this} deals 1 damage to that player."; - } -} diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/FoodChain.java b/Mage.Sets/src/mage/sets/mercadianmasques/FoodChain.java index 4bc1b29ea6..7e30d30bfa 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/FoodChain.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/FoodChain.java @@ -134,9 +134,17 @@ class FoodChainManaEffect extends ManaEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null && mana != null) { + checkToFirePossibleEvents(mana, game, source); player.getManaPool().addMana(mana, game, source); return true; } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + } diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/KyrenToy.java b/Mage.Sets/src/mage/sets/mercadianmasques/KyrenToy.java index fb4022bf39..0cd408cb37 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/KyrenToy.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/KyrenToy.java @@ -113,13 +113,20 @@ public class KyrenToy extends CardImpl { if (cost instanceof RemoveVariableCountersSourceCost) { numberOfMana = ((RemoveVariableCountersSourceCost)cost).getAmount(); } - } - player.getManaPool().addMana(new Mana(0, 0, 0, 0, 0, numberOfMana + 1, 0), game, source); + } + Mana mana = new Mana(0, 0, 0, 0, 0, numberOfMana + 1, 0); + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); return true; } return false; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + @Override public KyrenToyManaEffect copy() { return new KyrenToyManaEffect(this); diff --git a/Mage.Sets/src/mage/sets/mirrodin/ChromeMox.java b/Mage.Sets/src/mage/sets/mirrodin/ChromeMox.java index 376927de4e..dab4e360d8 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/ChromeMox.java +++ b/Mage.Sets/src/mage/sets/mirrodin/ChromeMox.java @@ -29,9 +29,6 @@ package mage.sets.mirrodin; import java.util.List; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.Mana; import mage.ObjectColor; import mage.abilities.Ability; @@ -44,7 +41,9 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.choices.Choice; import mage.choices.ChoiceImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; @@ -168,8 +167,9 @@ class ChromeMoxManaEffect extends ManaEffect { if (color.isWhite()) { 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 { @@ -188,12 +188,18 @@ class ChromeMoxManaEffect extends ManaEffect { } else if (choice.getChoice().equals("Colorless")) { player.getManaPool().addMana(Mana.ColorlessMana, game, source); } + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); } } - } } return true; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java index 323e58f3ab..a06c16a25b 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java @@ -28,14 +28,14 @@ package mage.sets.mirrodinbesieged; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import java.util.UUID; import mage.abilities.common.DiesTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; - -import java.util.UUID; +import mage.constants.CardType; +import mage.constants.Rarity; /** * @author ayratn @@ -45,8 +45,10 @@ public class IchorWellspring extends CardImpl { public IchorWellspring(UUID ownerId) { super(ownerId, 110, "Ichor Wellspring", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "MBS"; + + // When Ichor Wellspring enters the battlefield or is put into a graveyard from the battlefield, draw a card. this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); - this.addAbility(new DiesTriggeredAbility(new DrawCardSourceControllerEffect(1))); + this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); } public IchorWellspring(final IchorWellspring card) { diff --git a/Mage.Sets/src/mage/sets/modernmasters/JhoiraOfTheGhitu.java b/Mage.Sets/src/mage/sets/modernmasters/JhoiraOfTheGhitu.java index 4a52469e7a..111b094bea 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/JhoiraOfTheGhitu.java +++ b/Mage.Sets/src/mage/sets/modernmasters/JhoiraOfTheGhitu.java @@ -108,7 +108,7 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect { if (controller == null) { return false; } - List cards = new ArrayList(); + List cards = new ArrayList<>(); for (Cost cost: source.getCosts()) { if (cost instanceof ExileFromHandCost) { cards = ((ExileFromHandCost) cost).getCards(); diff --git a/Mage.Sets/src/mage/sets/newphyrexia/CagedSun.java b/Mage.Sets/src/mage/sets/newphyrexia/CagedSun.java index 45e52d3e50..67e7b0fdfc 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/CagedSun.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/CagedSun.java @@ -40,10 +40,12 @@ import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ChooseColorEffect; import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; import mage.choices.ChoiceColor; +import mage.constants.ColoredManaSymbol; import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; @@ -65,7 +67,7 @@ public class CagedSun extends CardImpl { this.expansionSetCode = "NPH"; // As Caged Sun enters the battlefield, choose a color. - this.addAbility(new AsEntersBattlefieldAbility(new CagedSunEffect1())); + this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit))); // Creatures you control of the chosen color get +1/+1. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CagedSunEffect2())); @@ -84,39 +86,6 @@ public class CagedSun extends CardImpl { } } -class CagedSunEffect1 extends OneShotEffect { - - public CagedSunEffect1() { - super(Outcome.BoostCreature); - staticText = "choose a color"; - } - - public CagedSunEffect1(final CagedSunEffect1 effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - if (player != null && permanent != null) { - ChoiceColor colorChoice = new ChoiceColor(); - if (player.choose(Outcome.BoostCreature, colorChoice, game)) { - game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + colorChoice.getChoice()); - game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor()); - permanent.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + colorChoice.getColor().getDescription())); - } - } - return false; - } - - @Override - public CagedSunEffect1 copy() { - return new CagedSunEffect1(this); - } - -} - class CagedSunEffect2 extends ContinuousEffectImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); @@ -207,22 +176,22 @@ class CagedSunEffect extends ManaEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); - if (color.isBlack()) { - player.getManaPool().addMana(Mana.BlackMana, game, source); - } else if (color.isBlue()) { - player.getManaPool().addMana(Mana.BlueMana, game, source); - } else if (color.isRed()) { - player.getManaPool().addMana(Mana.RedMana, game, source); - } else if (color.isGreen()) { - player.getManaPool().addMana(Mana.GreenMana, game, source); - } else if (color.isWhite()) { - player.getManaPool().addMana(Mana.WhiteMana, game, source); - } + player.getManaPool().addMana(getMana(game, source), game, source); } return true; } + @Override + public Mana getMana(Game game, Ability source) { + ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); + if (color != null) { + return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0))); + } else { + return null; + } + } + + @Override public CagedSunEffect copy() { return new CagedSunEffect(this); diff --git a/Mage.Sets/src/mage/sets/newphyrexia/ShrineOfBoundlessGrowth.java b/Mage.Sets/src/mage/sets/newphyrexia/ShrineOfBoundlessGrowth.java index ac5bb05143..efd5f53a02 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/ShrineOfBoundlessGrowth.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/ShrineOfBoundlessGrowth.java @@ -32,18 +32,16 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.TargetController; -import mage.constants.Zone; import mage.Mana; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.dynamicvalue.common.CountersCount; -import mage.abilities.effects.common.DynamicManaEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.mana.DynamicManaAbility; import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.FilterSpell; @@ -65,12 +63,15 @@ public class ShrineOfBoundlessGrowth extends CardImpl { super(ownerId, 152, "Shrine of Boundless Growth", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{3}"); this.expansionSetCode = "NPH"; + // At the beginning of your upkeep or whenever you cast a green spell, put a charge counter on Shrine of Boundless Growth. this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, false)); this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false)); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DynamicManaEffect(Mana.ColorlessMana, new CountersCount(CounterType.CHARGE)), new TapSourceCost()); + // {T}, Sacrifice Shrine of Boundless Growth: Add {1} to your mana pool for each charge counter on Shrine of Boundless Growth. + Ability ability = new DynamicManaAbility(Mana.BlackMana, new CountersCount(CounterType.CHARGE), new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); + } public ShrineOfBoundlessGrowth (final ShrineOfBoundlessGrowth card) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java b/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java index 0de9ccda69..ee0e7bf585 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java @@ -29,25 +29,20 @@ package mage.sets.newphyrexia; import java.util.UUID; import mage.MageInt; -import mage.Mana; -import mage.abilities.Abilities; -import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.common.ManaEffect; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; +import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.abilities.keyword.TrampleAbility; -import mage.abilities.mana.ManaAbility; -import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; -import mage.choices.Choice; -import mage.choices.ChoiceImpl; import mage.constants.CardType; import mage.constants.Rarity; +import mage.constants.SetTargetPointer; import mage.constants.Zone; +import mage.filter.common.FilterControlledLandPermanent; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.targetpointer.FixedTarget; /** @@ -68,7 +63,10 @@ public class VorinclexVoiceOfHunger extends CardImpl { this.addAbility(TrampleAbility.getInstance()); // Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced. - this.addAbility(new VorinclexTriggeredAbility1()); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaOfAnyColorTargetCanProduceEffect(), + new FilterControlledLandPermanent("you tap a land"), + SetTargetPointer.PERMANENT)); // Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step. this.addAbility(new VorinclexTriggeredAbility2()); @@ -84,121 +82,6 @@ public class VorinclexVoiceOfHunger extends CardImpl { } } -class VorinclexTriggeredAbility1 extends TriggeredManaAbility { - - private static final String staticText = "Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced."; - - public VorinclexTriggeredAbility1() { - super(Zone.BATTLEFIELD, new VorinclexEffect()); - } - - public VorinclexTriggeredAbility1(VorinclexTriggeredAbility1 ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && event.getPlayerId().equals(controllerId)) { - Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); - if (permanent != null && permanent.getCardType().contains(CardType.LAND)) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); - return true; - } - } - return false; - } - - @Override - public VorinclexTriggeredAbility1 copy() { - return new VorinclexTriggeredAbility1(this); - } - - @Override - public String getRule() { - return staticText; - } -} - - -class VorinclexEffect extends ManaEffect { - - public VorinclexEffect() { - super(); - staticText = "add one mana to your mana pool of any type that land produced"; - } - - public VorinclexEffect(final VorinclexEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source)); - Abilities mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD); - Mana types = new Mana(); - for (ManaAbility ability: mana) { - for (Mana netMana: ability.getNetMana(game)) { - types.add(netMana); - } - } - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (types.getBlack() > 0) { - choice.getChoices().add("Black"); - } - if (types.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (types.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (types.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (types.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (types.getColorless() > 0) { - choice.getChoices().add("Colorless"); - } - if (choice.getChoices().size() > 0) { - Player player = game.getPlayer(source.getControllerId()); - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } else { - player.choose(outcome, choice, game); - } - switch (choice.getChoice()) { - case "Black": - player.getManaPool().addMana(Mana.BlackMana, game, source); - return true; - case "Blue": - player.getManaPool().addMana(Mana.BlueMana, game, source); - return true; - case "Red": - player.getManaPool().addMana(Mana.RedMana, game, source); - return true; - case "Green": - player.getManaPool().addMana(Mana.GreenMana, game, source); - return true; - case "White": - player.getManaPool().addMana(Mana.WhiteMana, game, source); - return true; - case "Colorless": - player.getManaPool().addMana(Mana.ColorlessMana, game, source); - return true; - } - } - return true; - } - - @Override - public VorinclexEffect copy() { - return new VorinclexEffect(this); - } - -} - class VorinclexTriggeredAbility2 extends TriggeredAbilityImpl { private static final String staticText = "Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step."; diff --git a/Mage.Sets/src/mage/sets/planechase/CabalCoffers.java b/Mage.Sets/src/mage/sets/planechase/CabalCoffers.java index 4dfeda45d0..965e0eefa7 100644 --- a/Mage.Sets/src/mage/sets/planechase/CabalCoffers.java +++ b/Mage.Sets/src/mage/sets/planechase/CabalCoffers.java @@ -33,12 +33,10 @@ import mage.abilities.Ability; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; -import mage.abilities.effects.common.DynamicManaEffect; -import mage.abilities.mana.SimpleManaAbility; +import mage.abilities.mana.DynamicManaAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -59,9 +57,7 @@ public class CabalCoffers extends CardImpl { this.expansionSetCode = "HOP"; // {2}, {tap}: Add {B} to your mana pool for each Swamp you control. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, - new DynamicManaEffect(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter)), - new GenericManaCost(2)); + Ability ability = new DynamicManaAbility(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter), new GenericManaCost(2)); ability.addCost(new TapSourceCost()); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/planechase/VedalkenEngineer.java b/Mage.Sets/src/mage/sets/planechase/VedalkenEngineer.java index b0483bcaee..67bc367860 100644 --- a/Mage.Sets/src/mage/sets/planechase/VedalkenEngineer.java +++ b/Mage.Sets/src/mage/sets/planechase/VedalkenEngineer.java @@ -43,6 +43,7 @@ import mage.abilities.mana.ManaAbility; import mage.abilities.mana.builder.ConditionalManaBuilder; import mage.cards.CardImpl; import mage.choices.ChoiceColor; +import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -114,7 +115,6 @@ class VedalkenEngineerAbility extends ManaAbility { public VedalkenEngineerAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) { super(Zone.BATTLEFIELD, new VedalkenEngineerEffect(amount, manaBuilder), cost); - this.addChoice(new ChoiceColor()); this.netMana.add(new Mana(0,0,0,0,0,0, amount)); } @@ -153,31 +153,38 @@ class VedalkenEngineerEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { return false; } - boolean result = false; - for (int i = 0; i < amount; i++) { - ChoiceColor choice = (ChoiceColor) source.getChoices().get(0); - Mana mana = null; - if (choice.getColor().isBlack()) { - mana = manaBuilder.setMana(Mana.BlackMana(1), source, game).build(); - } else if (choice.getColor().isBlue()) { - mana = manaBuilder.setMana(Mana.BlueMana(1), source, game).build(); - } else if (choice.getColor().isRed()) { - mana = manaBuilder.setMana(Mana.RedMana(1), source, game).build(); - } else if (choice.getColor().isGreen()) { - mana = manaBuilder.setMana(Mana.GreenMana(1), source, game).build(); - } else if (choice.getColor().isWhite()) { - mana = manaBuilder.setMana(Mana.WhiteMana(1), source, game).build(); - } - if (mana != null) { - player.getManaPool().addMana(mana, game, source); - result = true; + Mana mana = new Mana(); + ChoiceColor choiceColor = (ChoiceColor) source.getChoices().get(0); + while (!controller.choose(Outcome.Benefit, choiceColor, game)) { + if (!controller.isInGame()) { + return false; } } - return result; + if (choiceColor.getColor().isBlack()) { + mana.setBlack(amount); + } else if (choiceColor.getColor().isBlue()) { + mana.setBlue(amount); + } else if (choiceColor.getColor().isRed()) { + mana.setRed(amount); + } else if (choiceColor.getColor().isGreen()) { + mana.setGreen(amount); + } else if (choiceColor.getColor().isWhite()) { + mana.setWhite(amount); + } + Mana condMana = manaBuilder.setMana(mana, source, game).build(); + checkToFirePossibleEvents(condMana, game, source); + controller.getManaPool().addMana(condMana, game, source); + return true; } -} \ No newline at end of file + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + +} diff --git a/Mage.Sets/src/mage/sets/ravnika/Terrarion.java b/Mage.Sets/src/mage/sets/ravnika/Terrarion.java index 95c39c9339..efb356e633 100644 --- a/Mage.Sets/src/mage/sets/ravnika/Terrarion.java +++ b/Mage.Sets/src/mage/sets/ravnika/Terrarion.java @@ -28,23 +28,19 @@ package mage.sets.ravnika; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; -import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; -import mage.choices.ChoiceColor; -import mage.game.Game; -import mage.players.Player; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; /** * @@ -58,12 +54,10 @@ public class Terrarion extends CardImpl { // Terrarion enters the battlefield tapped. this.addAbility(new EntersBattlefieldTappedAbility()); - // {2}, {tap}, Sacrifice Terrarion: Add two mana in any combination of colors to your mana pool. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new TerrarionManaEffect(), new GenericManaCost(2)); + // {2}, {T}, Sacrifice Terrarion: Add two mana in any combination of colors to your mana pool. + Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaInAnyCombinationEffect(2), new GenericManaCost(2)); ability.addCost(new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); - ability.addChoice(new ChoiceColor()); - ability.addChoice(new ChoiceColor()); this.addAbility(ability); // When Terrarion is put into a graveyard from the battlefield, draw a card. this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); @@ -78,51 +72,3 @@ public class Terrarion extends CardImpl { return new Terrarion(this); } } - -class TerrarionManaEffect extends ManaEffect { - - public TerrarionManaEffect() { - super(); - this.staticText = "Add two mana in any combination of colors to your mana pool"; - } - - public TerrarionManaEffect(final TerrarionManaEffect effect) { - super(effect); - } - - @Override - public TerrarionManaEffect copy() { - return new TerrarionManaEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { - return false; - } - - boolean result = false; - for (int i = 0; i < 2; i++) { - ChoiceColor choice = (ChoiceColor) source.getChoices().get(i); - Mana mana = null; - if (choice.getColor().isBlack()) { - mana = Mana.BlackMana(1); - } else if (choice.getColor().isBlue()) { - mana = Mana.BlueMana(1); - } else if (choice.getColor().isRed()) { - mana = Mana.RedMana(1); - } else if (choice.getColor().isGreen()) { - mana = Mana.GreenMana(1); - } else if (choice.getColor().isWhite()) { - mana = Mana.WhiteMana(1); - } - - if (mana != null) { - player.getManaPool().addMana(mana, game, source); - result = true; - } - } - return result; - } -} diff --git a/Mage.Sets/src/mage/sets/shadowmoor/Manamorphose.java b/Mage.Sets/src/mage/sets/shadowmoor/Manamorphose.java index 6211575baf..8ded173666 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/Manamorphose.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/Manamorphose.java @@ -28,18 +28,11 @@ package mage.sets.shadowmoor; import java.util.UUID; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; +import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.Mana; -import mage.ObjectColor; -import mage.abilities.Ability; -import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.abilities.effects.common.ManaEffect; -import mage.cards.CardImpl; -import mage.choices.ChoiceColor; -import mage.constants.Outcome; -import mage.game.Game; -import mage.players.Player; /** * @@ -55,7 +48,7 @@ public class Manamorphose extends CardImpl { this.color.setGreen(true); // Add two mana in any combination of colors to your mana pool. - this.getSpellAbility().addEffect(new ManamorphoseEffect()); + this.getSpellAbility().addEffect(new AddManaInAnyCombinationEffect(2)); // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); @@ -70,68 +63,3 @@ public class Manamorphose extends CardImpl { return new Manamorphose(this); } } - -class ManamorphoseEffect extends ManaEffect { - - public ManamorphoseEffect() { - super(); - this.staticText = "Add two mana in any combination of colors to your mana pool"; - } - - public ManamorphoseEffect(final ManamorphoseEffect effect) { - super(effect); - } - - @Override - public ManamorphoseEffect copy() { - return new ManamorphoseEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { - return false; - } - - - boolean result = false; - for (int i = 0; i < 2; i++) { - ChoiceColor choice = getManaChoice(player, game); - if (choice == null) { - return false; - } - Mana mana = null; - if (choice.getColor().isBlack()) { - mana = Mana.BlackMana(1); - } else if (choice.getColor().isBlue()) { - mana = Mana.BlueMana(1); - } else if (choice.getColor().isRed()) { - mana = Mana.RedMana(1); - } else if (choice.getColor().isGreen()) { - mana = Mana.GreenMana(1); - } else if (choice.getColor().isWhite()) { - mana = Mana.WhiteMana(1); - } - - if (mana != null) { - player.getManaPool().addMana(mana, game, source); - result = true; - } - } - return result; - } - - private ChoiceColor getManaChoice(Player controller, Game game) { - ChoiceColor choice = new ChoiceColor(); - while (!choice.isChosen()) { - controller.choose(Outcome.PutManaInPool, choice, game); - if (!controller.isInGame()) { - return null; - } - } - return choice; - } - -} - diff --git a/Mage.Sets/src/mage/sets/shardsofalara/KeeperOfProgenitus.java b/Mage.Sets/src/mage/sets/shardsofalara/KeeperOfProgenitus.java index 887e753394..daeed72c38 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/KeeperOfProgenitus.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/KeeperOfProgenitus.java @@ -1,4 +1,4 @@ -/* + /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are @@ -28,24 +28,16 @@ package mage.sets.shardsofalara; import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; +import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; +import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.MageInt; -import mage.Mana; -import mage.abilities.Abilities; -import mage.abilities.Ability; -import mage.abilities.effects.common.ManaEffect; -import mage.abilities.mana.ManaAbility; -import mage.abilities.mana.TriggeredManaAbility; -import mage.cards.CardImpl; -import mage.choices.Choice; -import mage.choices.ChoiceImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.targetpointer.FixedTarget; +import mage.constants.SetTargetPointer; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.SubtypePredicate; /** * @@ -53,6 +45,16 @@ import mage.target.targetpointer.FixedTarget; */ public class KeeperOfProgenitus extends CardImpl { + private static final FilterLandPermanent filter = new FilterLandPermanent("a player taps a Mountain, Forest, or Plains"); + + static { + filter.add(Predicates.or( + new SubtypePredicate("Mountain"), + new SubtypePredicate("Forest"), + new SubtypePredicate("Plains") + )); + } + public KeeperOfProgenitus(UUID ownerId) { super(ownerId, 135, "Keeper of Progenitus", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{G}"); this.expansionSetCode = "ALA"; @@ -64,7 +66,9 @@ public class KeeperOfProgenitus extends CardImpl { this.toughness = new MageInt(3); // Whenever a player taps a Mountain, Forest, or Plains for mana, that player adds one mana to his or her mana pool of any type that land produced. - this.addAbility(new HeartbeatOfSpringAbility()); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaOfAnyColorTargetCanProduceEffect(), + filter, SetTargetPointer.PERMANENT)); } public KeeperOfProgenitus(final KeeperOfProgenitus card) { @@ -76,127 +80,3 @@ public class KeeperOfProgenitus extends CardImpl { return new KeeperOfProgenitus(this); } } - -class HeartbeatOfSpringAbility extends TriggeredManaAbility { - - private static final String staticText = "Whenever a player taps a Mountain, Forest, or Plains for mana, that player adds one mana to his or her mana pool of any type that land produced."; - - public HeartbeatOfSpringAbility() { - super(Zone.BATTLEFIELD, new HeartbeatOfSpringEffect()); - } - - public HeartbeatOfSpringAbility(HeartbeatOfSpringAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA ) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent == null) { - permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); - } - if (permanent != null && permanent.getCardType().contains(CardType.LAND)){ - if(permanent.getSubtype().contains("Mountain") || permanent.getSubtype().contains("Forest") || permanent.getSubtype().contains("Plains")){ - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); - return true; - } - } - } - return false; - } - - @Override - public HeartbeatOfSpringAbility copy() { - return new HeartbeatOfSpringAbility(this); - } - - @Override - public String getRule() { - return staticText; - } -} - -class HeartbeatOfSpringEffect extends ManaEffect { - - public HeartbeatOfSpringEffect() { - super(); - staticText = "that player adds one mana to his or her mana pool of any type that land produced"; - } - - public HeartbeatOfSpringEffect(final HeartbeatOfSpringEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source)); - Player player = game.getPlayer(land.getControllerId()); - Abilities mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD); - Mana types = new Mana(); - for (ManaAbility ability: mana) { - for (Mana netMana: ability.getNetMana(game)) { - types.add(netMana); - } - } - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (types.getBlack() > 0) { - choice.getChoices().add("Black"); - } - if (types.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (types.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (types.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (types.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (types.getColorless() > 0) { - choice.getChoices().add("Colorless"); - } - if (choice.getChoices().size() > 0) { - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } - else { - player.choose(outcome, choice, game); - } - if (choice.getChoice().equals("Black")) { - player.getManaPool().addMana(Mana.BlackMana, game, source); - return true; - } - else if (choice.getChoice().equals("Blue")) { - player.getManaPool().addMana(Mana.BlueMana, game, source); - return true; - } - else if (choice.getChoice().equals("Red")) { - player.getManaPool().addMana(Mana.RedMana, game, source); - return true; - } - else if (choice.getChoice().equals("Green")) { - player.getManaPool().addMana(Mana.GreenMana, game, source); - return true; - } - else if (choice.getChoice().equals("White")) { - player.getManaPool().addMana(Mana.WhiteMana, game, source); - return true; - } - else if (choice.getChoice().equals("Colorless")) { - player.getManaPool().addMana(Mana.ColorlessMana, game, source); - return true; - } - } - return true; - } - - @Override - public HeartbeatOfSpringEffect copy() { - return new HeartbeatOfSpringEffect(this); - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/shardsofalara/SacellumGodspeaker.java b/Mage.Sets/src/mage/sets/shardsofalara/SacellumGodspeaker.java index 25d6b412dd..6570933c5b 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/SacellumGodspeaker.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/SacellumGodspeaker.java @@ -62,7 +62,7 @@ public class SacellumGodspeaker extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); - // {tap}: Reveal any number of creature cards with power 5 or greater from your hand. Add {G} to your mana pool for each card revealed this way. + // {T}: Reveal any number of creature cards with power 5 or greater from your hand. Add {G} to your mana pool for each card revealed this way. this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new SacellumGodspeakerEffect(), new TapSourceCost())); } @@ -103,9 +103,18 @@ class SacellumGodspeakerEffect extends ManaEffect { public boolean apply(Game game, Ability source) { TargetCardInHand target = new TargetCardInHand(0,Integer.MAX_VALUE, filter); if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) { - game.getPlayer(source.getControllerId()).getManaPool().addMana(Mana.GreenMana(target.getTargets().size()), game, source); + Mana mana = Mana.GreenMana(target.getTargets().size()); + checkToFirePossibleEvents(mana, game, source); + game.getPlayer(source.getControllerId()).getManaPool().addMana(mana, game, source); return true; } return false; } + + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/stronghold/Overgrowth.java b/Mage.Sets/src/mage/sets/stronghold/Overgrowth.java index e32db4373e..16b5937697 100644 --- a/Mage.Sets/src/mage/sets/stronghold/Overgrowth.java +++ b/Mage.Sets/src/mage/sets/stronghold/Overgrowth.java @@ -30,8 +30,8 @@ package mage.sets.stronghold; import java.util.UUID; import mage.Mana; import mage.abilities.Ability; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.ManaEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardImpl; @@ -42,9 +42,9 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetLandPermanent; +import mage.target.targetpointer.FixedTarget; /** * @@ -65,8 +65,7 @@ public class Overgrowth extends CardImpl { this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); - // Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool. - + // Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool. this.addAbility(new OvergrowthTriggeredAbility()); } @@ -84,7 +83,7 @@ class OvergrowthTriggeredAbility extends TriggeredManaAbility { public OvergrowthTriggeredAbility() { - super(Zone.BATTLEFIELD, new OvergrowthEffect()); + super(Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(new Mana(0,2,0,0,0,0,0), "his or her")); } public OvergrowthTriggeredAbility(final OvergrowthTriggeredAbility ability) { @@ -101,7 +100,11 @@ class OvergrowthTriggeredAbility extends TriggeredManaAbility { Permanent enchantment = game.getPermanent(this.getSourceId()); if(event.getType() == GameEvent.EventType.TAPPED_FOR_MANA){ if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) { - return true; + Permanent enchanted = game.getPermanent(enchantment.getAttachedTo()); + if (enchanted != null) { + getEffects().get(0).setTargetPointer(new FixedTarget(enchanted.getControllerId())); + return true; + } } } return false; @@ -113,36 +116,3 @@ class OvergrowthTriggeredAbility extends TriggeredManaAbility { return "Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool"; } } - -class OvergrowthEffect extends ManaEffect { - - public OvergrowthEffect() { - super(); - staticText = "its controller adds {G}{G} to his or her mana pool"; - } - - public OvergrowthEffect(final OvergrowthEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if(enchantment != null){ - Permanent land = game.getPermanent(enchantment.getAttachedTo()); - if(land != null){ - Player player = game.getPlayer(land.getControllerId()); - if (player != null) { - player.getManaPool().addMana(Mana.GreenMana(2), game, source); - return true; - } - } - } - return false; - } - - @Override - public OvergrowthEffect copy() { - return new OvergrowthEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/tempest/EladamrisVineyard.java b/Mage.Sets/src/mage/sets/tempest/EladamrisVineyard.java index ed27cae6ac..dd38f1cb86 100644 --- a/Mage.Sets/src/mage/sets/tempest/EladamrisVineyard.java +++ b/Mage.Sets/src/mage/sets/tempest/EladamrisVineyard.java @@ -30,7 +30,7 @@ package mage.sets.tempest; import java.util.UUID; import static mage.Mana.GreenMana; import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -51,7 +51,7 @@ public class EladamrisVineyard extends CardImpl { // At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool. this.addAbility(new BeginningOfPreCombatMainTriggeredAbility( - Zone.BATTLEFIELD, new AddManaToManaPoolEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true)); + Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true)); } public EladamrisVineyard(final EladamrisVineyard card) { diff --git a/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java b/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java index 780dd8afa0..c0c8f64313 100644 --- a/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java +++ b/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java @@ -146,26 +146,29 @@ class ReflectingPoolEffect extends ManaEffect { player.choose(outcome, choice, game); } if (choice.getChoice() != null) { + Mana mana = new Mana(); switch (choice.getChoice()) { case "Black": - player.getManaPool().addMana(Mana.BlackMana, game, source); + mana.setBlack(1); break; case "Blue": - player.getManaPool().addMana(Mana.BlueMana, game, source); + mana.setBlue(1); break; case "Red": - player.getManaPool().addMana(Mana.RedMana, game, source); + mana.setRed(1); break; case "Green": - player.getManaPool().addMana(Mana.GreenMana, game, source); + mana.setGreen(1); break; case "White": - player.getManaPool().addMana(Mana.WhiteMana, game, source); + mana.setWhite(1); break; case "Colorless": - player.getManaPool().addMana(Mana.ColorlessMana, game, source); + mana.setColorless(1); break; } + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); return true; } return false; @@ -213,6 +216,11 @@ class ReflectingPoolEffect extends ManaEffect { return types; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + @Override public ReflectingPoolEffect copy() { return new ReflectingPoolEffect(this); diff --git a/Mage.Sets/src/mage/sets/tenth/DoublingCube.java b/Mage.Sets/src/mage/sets/tenth/DoublingCube.java index c5e844d22a..4eb50b4c3e 100644 --- a/Mage.Sets/src/mage/sets/tenth/DoublingCube.java +++ b/Mage.Sets/src/mage/sets/tenth/DoublingCube.java @@ -53,7 +53,7 @@ public class DoublingCube extends CardImpl { super(ownerId, 321, "Doubling Cube", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "10E"; - // {3}, {tap}: Double the amount of each type of mana in your mana pool. + // {3}, {T}: Double the amount of each type of mana in your mana pool. Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new DoublingCubeEffect(), new ManaCostsImpl("{3}")); ability.addCost(new TapSourceCost()); this.addAbility(ability); @@ -93,11 +93,19 @@ class DoublingCubeEffect extends ManaEffect { int blueMana = pool.getBlue(); int greenMana = pool.getGreen(); int redMana = pool.getRed(); - int colorlessMana = pool.getColorless(); - pool.addMana(new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, colorlessMana, 0), game, source); + int colorlessMana = pool.getColorless(); + Mana mana = new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, colorlessMana, 0); + checkToFirePossibleEvents(mana, game, source); + pool.addMana(mana, game, source); return true; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + @Override public DoublingCubeEffect copy() { return new DoublingCubeEffect(this); diff --git a/Mage.Sets/src/mage/sets/tenth/Manabarbs.java b/Mage.Sets/src/mage/sets/tenth/Manabarbs.java index ef45d1792a..c4767f0c9a 100644 --- a/Mage.Sets/src/mage/sets/tenth/Manabarbs.java +++ b/Mage.Sets/src/mage/sets/tenth/Manabarbs.java @@ -29,17 +29,14 @@ package mage.sets.tenth; import java.util.UUID; -import mage.constants.Zone; import mage.constants.CardType; import mage.constants.Rarity; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.TapForManaAllTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.target.targetpointer.FixedTarget; +import mage.constants.SetTargetPointer; +import mage.filter.common.FilterLandPermanent; /** * @@ -54,7 +51,9 @@ public class Manabarbs extends CardImpl { this.color.setRed(true); // Whenever a player taps a land for mana, Manabarbs deals 1 damage to that player. - this.addAbility(new ManabarbsTriggeredAbility()); + this.addAbility(new TapForManaAllTriggeredAbility( + new DamageTargetEffect(1, true, "that player"), + new FilterLandPermanent("a player taps a land"), SetTargetPointer.PLAYER)); } public Manabarbs(final Manabarbs card) { @@ -66,41 +65,3 @@ public class Manabarbs extends CardImpl { return new Manabarbs(this); } } - -class ManabarbsTriggeredAbility extends TriggeredAbilityImpl { - - private static final String staticText = "Whenever a player taps a land for mana, Manabarbs deals 1 damage to that player."; - - public ManabarbsTriggeredAbility() { - super(Zone.BATTLEFIELD, new DamageTargetEffect(1)); - } - - public ManabarbsTriggeredAbility(ManabarbsTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent == null) { - permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); - } - if (permanent != null && permanent.getCardType().contains(CardType.LAND)) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId())); - return true; - } - } - return false; - } - - @Override - public ManabarbsTriggeredAbility copy() { - return new ManabarbsTriggeredAbility(this); - } - - @Override - public String getRule() { - return staticText; - } -} diff --git a/Mage.Sets/src/mage/sets/theros/NykthosShrineToNyx.java b/Mage.Sets/src/mage/sets/theros/NykthosShrineToNyx.java index 023b1f1271..d3c9aa2742 100644 --- a/Mage.Sets/src/mage/sets/theros/NykthosShrineToNyx.java +++ b/Mage.Sets/src/mage/sets/theros/NykthosShrineToNyx.java @@ -131,6 +131,7 @@ class NykthosDynamicManaEffect extends ManaEffect { choice.setMessage("Choose a color for devotion of Nykthos"); if (controller.choose(outcome, choice, game)) { computeMana(choice.getChoice(), game, source); + checkToFirePossibleEvents(computedMana, game, source); game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source); return true; } @@ -139,6 +140,12 @@ class NykthosDynamicManaEffect extends ManaEffect { } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + public Mana computeMana(String color, Game game, Ability source){ this.computedMana.clear(); if (color !=null && !color.isEmpty()) { diff --git a/Mage.Sets/src/mage/sets/timespiral/AcademyRuins.java b/Mage.Sets/src/mage/sets/timespiral/AcademyRuins.java index 0aa5487907..c7d91fdb76 100644 --- a/Mage.Sets/src/mage/sets/timespiral/AcademyRuins.java +++ b/Mage.Sets/src/mage/sets/timespiral/AcademyRuins.java @@ -28,9 +28,6 @@ package mage.sets.timespiral; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; @@ -38,6 +35,8 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.PutOnLibraryTargetEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterArtifactCard; import mage.target.common.TargetCardInYourGraveyard; diff --git a/Mage.Sets/src/mage/sets/timespiral/CalciformPools.java b/Mage.Sets/src/mage/sets/timespiral/CalciformPools.java index 0bbd2a01a9..3e67c5bee9 100644 --- a/Mage.Sets/src/mage/sets/timespiral/CalciformPools.java +++ b/Mage.Sets/src/mage/sets/timespiral/CalciformPools.java @@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; -import mage.abilities.effects.common.ManaInAnyCombinationEffect; +import mage.abilities.effects.common.AddManaInAnyCombinationEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -62,7 +62,7 @@ public class CalciformPools extends CardImpl { this.addAbility(ability); // {1}, Remove X storage counters from Calciform Pools: Add X mana in any combination of {W} and/or {U} to your mana pool. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.W, ColoredManaSymbol.U), + new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.W, ColoredManaSymbol.U), new GenericManaCost(1)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/urzasdestiny/Metalworker.java b/Mage.Sets/src/mage/sets/urzasdestiny/Metalworker.java index 7a98011994..14bb54ff87 100644 --- a/Mage.Sets/src/mage/sets/urzasdestiny/Metalworker.java +++ b/Mage.Sets/src/mage/sets/urzasdestiny/Metalworker.java @@ -114,7 +114,10 @@ class MetalworkerManaEffect extends ManaEffect { cards.add(player.getHand().get(uuid, game)); } player.revealCards("Revealed card", cards, game); - player.getManaPool().addMana(Mana.ColorlessMana(target.getTargets().size()*2), game, source); + Mana mana = Mana.ColorlessMana(target.getTargets().size()*2); + checkToFirePossibleEvents(mana, game, source); + player.getManaPool().addMana(mana, game, source); + } } @@ -122,4 +125,10 @@ class MetalworkerManaEffect extends ManaEffect { return true; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + + } diff --git a/Mage.Sets/src/mage/sets/urzassaga/CarpetOfFlowers.java b/Mage.Sets/src/mage/sets/urzassaga/CarpetOfFlowers.java index b63c5459a3..0969dfbbd7 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/CarpetOfFlowers.java +++ b/Mage.Sets/src/mage/sets/urzassaga/CarpetOfFlowers.java @@ -181,26 +181,41 @@ class CarpetOfFlowersEffect extends ManaEffect { choiceCount.setMessage("Choose number of mana"); controller.choose(Outcome.PutManaInPool, choiceCount, game); int count = Integer.parseInt(choiceCount.getChoice()); - if (choice.getColor().isBlack()) { - controller.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source); - return true; - } else if (choice.getColor().isBlue()) { - controller.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isRed()) { - controller.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isGreen()) { - controller.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isWhite()) { - controller.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source); - return true; + if (count > 0) { + Mana mana = new Mana(); + switch (choice.getChoice()) { + case "Black": + mana.setBlack(count); + break; + case "Blue": + mana.setBlue(count); + break; + case "Red": + mana.setRed(count); + break; + case "Green": + mana.setGreen(count); + break; + case "White": + mana.setWhite(count); + break; + case "Colorless": + mana.setColorless(count); + break; + } + checkToFirePossibleEvents(mana, game, source); + controller.getManaPool().addMana(mana, game, source); } + return true; } return false; } + @Override + public Mana getMana(Game game, Ability source) { + return null; + } + @Override public CarpetOfFlowersEffect copy() { return new CarpetOfFlowersEffect(this); diff --git a/Mage.Sets/src/mage/sets/urzassaga/FertileGround.java b/Mage.Sets/src/mage/sets/urzassaga/FertileGround.java index c7331e9c8c..83aafe645c 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/FertileGround.java +++ b/Mage.Sets/src/mage/sets/urzassaga/FertileGround.java @@ -28,8 +28,10 @@ package mage.sets.urzassaga; import java.util.UUID; +import mage.Mana; import mage.abilities.Ability; -import mage.abilities.effects.common.AddManaOfAnyColorEffect; +import mage.abilities.effects.common.AddManaAnyColorAttachedControllerEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.mana.TriggeredManaAbility; @@ -43,6 +45,7 @@ import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetLandPermanent; +import mage.target.targetpointer.FixedTarget; /** * @@ -81,7 +84,7 @@ class FertileGroundTriggeredAbility extends TriggeredManaAbility { public FertileGroundTriggeredAbility() { - super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect()); + super(Zone.BATTLEFIELD, new AddManaAnyColorAttachedControllerEffect()); } public FertileGroundTriggeredAbility(FertileGroundTriggeredAbility ability) { @@ -90,10 +93,14 @@ class FertileGroundTriggeredAbility extends TriggeredManaAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - Permanent enchantment = game.getPermanent(this.getSourceId()); if(event.getType() == GameEvent.EventType.TAPPED_FOR_MANA){ + Permanent enchantment = game.getPermanent(this.getSourceId()); if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) { - return true; + Permanent enchanted = game.getPermanent(enchantment.getAttachedTo()); + if (enchanted != null) { + getEffects().get(0).setTargetPointer(new FixedTarget(enchanted.getControllerId())); + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/sets/urzassaga/VernalBloom.java b/Mage.Sets/src/mage/sets/urzassaga/VernalBloom.java index 8d03a9e1af..5981568b8f 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/VernalBloom.java +++ b/Mage.Sets/src/mage/sets/urzassaga/VernalBloom.java @@ -28,23 +28,16 @@ package mage.sets.urzassaga; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.Mana; -import mage.abilities.Ability; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.ManaEffect; -import mage.abilities.mana.TriggeredManaAbility; +import mage.abilities.common.TapForManaAllTriggeredManaAbility; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.cards.CardImpl; -import mage.constants.Zone; +import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; +import mage.constants.Rarity; +import mage.constants.SetTargetPointer; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.targetpointer.FixedTarget; /** * @@ -52,6 +45,11 @@ import mage.target.targetpointer.FixedTarget; */ public class VernalBloom extends CardImpl { + private static final FilterLandPermanent filter = new FilterLandPermanent("a Forest"); + + static { + filter.add(new SubtypePredicate("Forest")); + } public VernalBloom(UUID ownerId) { super(ownerId, 281, "Vernal Bloom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); this.expansionSetCode = "USG"; @@ -59,7 +57,9 @@ public class VernalBloom extends CardImpl { this.color.setGreen(true); // Whenever a Forest is tapped for mana, its controller adds {G} to his or her mana pool. - this.addAbility(new VernalBloomTriggeredAbility()); + this.addAbility(new TapForManaAllTriggeredManaAbility( + new AddManaToManaPoolTargetControllerEffect(new Mana(ColoredManaSymbol.G), "his or her"), + filter, SetTargetPointer.PLAYER)); } public VernalBloom(final VernalBloom card) { @@ -71,73 +71,3 @@ public class VernalBloom extends CardImpl { return new VernalBloom(this); } } - -class VernalBloomTriggeredAbility extends TriggeredManaAbility { - - private static final FilterLandPermanent filter = new FilterLandPermanent("Forest"); - static { - filter.add(new SubtypePredicate("Forest")); - } - - public VernalBloomTriggeredAbility() { - super(Zone.BATTLEFIELD, new AddGreenToTargetEffect()); - this.usesStack = false; - } - - public VernalBloomTriggeredAbility(VernalBloomTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - Permanent land = game.getPermanent(event.getTargetId()); - if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && land != null && filter.match(land, game)) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(land.getControllerId())); - } - return true; - } - return false; - } - - @Override - public VernalBloomTriggeredAbility copy() { - return new VernalBloomTriggeredAbility(this); - } - - @Override - public String getRule() { - return "Whenever a Forest is tapped for mana, its controller adds {G} to his or her mana pool"; - } -} - -class AddGreenToTargetEffect extends ManaEffect { - - - public AddGreenToTargetEffect() { - super(); - staticText = "its controller adds {G} to his or her mana pool"; - } - - - public AddGreenToTargetEffect(final AddGreenToTargetEffect effect) { - super(effect); - } - - @Override - public AddGreenToTargetEffect copy() { - return new AddGreenToTargetEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - if(player != null) - { - player.getManaPool().addMana(Mana.GreenMana(1), game, source); - - } - return true; - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java b/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java index eadac35446..cac95952d2 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java @@ -34,7 +34,7 @@ import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility.PhaseSelection; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.AddManaToManaPoolEffect; +import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; @@ -95,7 +95,7 @@ class ManaDrainCounterEffect extends OneShotEffect { game.getStack().counter(getTargetPointer().getFirst(game, source), source.getSourceId(), game); // mana gets added also if counter is not successful int cmc = spell.getConvertedManaCost(); - Effect effect = new AddManaToManaPoolEffect(new Mana(0,0,0,0,0,cmc,0), "your"); + Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,0,0,0,0,cmc,0), "your"); effect.setTargetPointer(new FixedTarget(source.getControllerId())); AtTheBeginOMainPhaseDelayedTriggeredAbility delayedAbility = new AtTheBeginOMainPhaseDelayedTriggeredAbility(effect, false, TargetController.YOU, PhaseSelection.NEXT_MAIN); diff --git a/Mage.Sets/src/mage/sets/worldwake/HarabazDruid.java b/Mage.Sets/src/mage/sets/worldwake/HarabazDruid.java index 945fdcbc30..0905f4d815 100644 --- a/Mage.Sets/src/mage/sets/worldwake/HarabazDruid.java +++ b/Mage.Sets/src/mage/sets/worldwake/HarabazDruid.java @@ -28,26 +28,27 @@ package mage.sets.worldwake; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; import mage.Mana; -import mage.abilities.Ability; -import mage.abilities.effects.common.ManaEffect; -import mage.abilities.mana.BasicManaAbility; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.mana.DynamicManaAbility; import mage.cards.CardImpl; -import mage.choices.ChoiceColor; -import mage.filter.common.FilterControlledPermanent; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.players.Player; /** * @author Loki */ public class HarabazDruid extends CardImpl { + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Allies you control"); + + static { + filter.add(new SubtypePredicate("Ally")); + } + public HarabazDruid(UUID ownerId) { super(ownerId, 105, "Harabaz Druid", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{G}"); this.expansionSetCode = "WWK"; @@ -59,8 +60,9 @@ public class HarabazDruid extends CardImpl { this.power = new MageInt(0); this.toughness = new MageInt(1); - // {tap}: Add X mana of any one color to your mana pool, where X is the number of Allies you control. - this.addAbility(new HarabazDruidManaAbility()); + // {T}: Add X mana of any one color to your mana pool, where X is the number of Allies you control. + this.addAbility(new DynamicManaAbility(new Mana(0,0,0,0,0,0,1), new PermanentsOnBattlefieldCount(filter), + "Add X mana of any one color to your mana pool, where X is the number of Allies you control")); } public HarabazDruid(final HarabazDruid card) { @@ -72,65 +74,3 @@ public class HarabazDruid extends CardImpl { return new HarabazDruid(this); } } - -class HarabazDruidManaAbility extends BasicManaAbility { - HarabazDruidManaAbility() { - super(new HarabazDruidManaEffect()); - this.addChoice(new ChoiceColor()); - } - - HarabazDruidManaAbility(final HarabazDruidManaAbility ability) { - super(ability); - } - - @Override - public HarabazDruidManaAbility copy() { - return new HarabazDruidManaAbility(this); - } -} - -class HarabazDruidManaEffect extends ManaEffect { - private static final FilterControlledPermanent filter = new FilterControlledPermanent(); - - static { - filter.add(new SubtypePredicate("Ally")); - } - - HarabazDruidManaEffect() { - super(); - staticText = "Add X mana of any one color to your mana pool, where X is the number of Allies you control"; - } - - HarabazDruidManaEffect(final HarabazDruidManaEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - ChoiceColor choice = (ChoiceColor) source.getChoices().get(0); - Player player = game.getPlayer(source.getControllerId()); - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); - if (choice.getColor().isBlack()) { - player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source); - return true; - } else if (choice.getColor().isBlue()) { - player.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isRed()) { - player.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isGreen()) { - player.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source); - return true; - } else if (choice.getColor().isWhite()) { - player.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source); - return true; - } - return false; - } - - @Override - public HarabazDruidManaEffect copy() { - return new HarabazDruidManaEffect(this); - } -} \ No newline at end of file