diff --git a/Mage.Sets/src/mage/cards/k/KozileksTranslator.java b/Mage.Sets/src/mage/cards/k/KozileksTranslator.java index 7ddcabb5432..8d0b401ef54 100644 --- a/Mage.Sets/src/mage/cards/k/KozileksTranslator.java +++ b/Mage.Sets/src/mage/cards/k/KozileksTranslator.java @@ -1,19 +1,20 @@ package mage.cards.k; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.costs.common.PayLifeCost; import mage.abilities.effects.mana.BasicManaEffect; import mage.abilities.keyword.DevoidAbility; -import mage.abilities.mana.ActivateOncePerTurnManaAbility; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; +import java.util.UUID; + /** * * @author LevelX2 @@ -21,7 +22,7 @@ import mage.constants.Zone; public final class KozileksTranslator extends CardImpl { public KozileksTranslator(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}"); this.subtype.add(SubType.ELDRAZI); this.subtype.add(SubType.DRONE); this.power = new MageInt(3); @@ -31,7 +32,9 @@ public final class KozileksTranslator extends CardImpl { this.addAbility(new DevoidAbility(this.color)); // Pay 1 life: Add {C}. Activate this ability only once each turn. - this.addAbility(new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new BasicManaEffect(Mana.ColorlessMana(1)), new PayLifeCost(1))); + this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( + Zone.BATTLEFIELD, new BasicManaEffect(Mana.ColorlessMana(1)), new PayLifeCost(1) + )); } private KozileksTranslator(final KozileksTranslator card) { diff --git a/Mage.Sets/src/mage/cards/m/ManaBloom.java b/Mage.Sets/src/mage/cards/m/ManaBloom.java index 65ef885dae8..a1df6055064 100644 --- a/Mage.Sets/src/mage/cards/m/ManaBloom.java +++ b/Mage.Sets/src/mage/cards/m/ManaBloom.java @@ -1,7 +1,6 @@ package mage.cards.m; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -9,10 +8,10 @@ import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.condition.common.SourceHasCounterCondition; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; -import mage.abilities.effects.mana.AddManaOfAnyColorEffect; import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; -import mage.abilities.mana.ActivateOncePerTurnManaAbility; +import mage.abilities.effects.mana.AddManaOfAnyColorEffect; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -20,6 +19,8 @@ import mage.constants.TargetController; import mage.constants.Zone; import mage.counters.CounterType; +import java.util.UUID; + /** * * @author LevelX2 @@ -29,13 +30,16 @@ public final class ManaBloom extends CardImpl { static final String rule = "with X charge counters on it"; public ManaBloom(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{X}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{X}{G}"); // Mana Bloom enters the battlefield with X charge counters on it. this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.CHARGE.createInstance()))); // Remove a charge counter from Mana Bloom: Add one mana of any color. Activate this ability only once each turn. - Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())); + Ability ability = new LimitedTimesPerTurnActivatedManaAbility( + Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), + new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()) + ); this.addAbility(ability); // At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand. diff --git a/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java b/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java index ecb53d1174c..8723a39bdbd 100644 --- a/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java +++ b/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java @@ -1,29 +1,29 @@ package mage.cards.m; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.Ability; -import mage.abilities.common.LimitedTimesPerTurnActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.mana.ManaEffect; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.choices.Choice; -import mage.choices.ChoiceImpl; +import mage.choices.ChoiceColor; import mage.constants.CardType; -import mage.constants.Outcome; +import mage.constants.ColoredManaSymbol; import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.players.Player; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** - * - * @author jeffwadsworth + * @author Susucr */ public final class ManaforgeCinder extends CardImpl { @@ -35,7 +35,11 @@ public final class ManaforgeCinder extends CardImpl { this.toughness = new MageInt(1); // {1}: Add {B} or {R}. Activate this ability no more than three times each turn. - this.addAbility(new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new ManaforgeCinderManaEffect(), new ManaCostsImpl<>("{1}"), 3)); + this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( + Zone.BATTLEFIELD, new ManaforgeCinderManaEffect(), + new ManaCostsImpl<>("{1}"), 3, + ManaforgeCinderManaEffect.netMana + )); } @@ -49,10 +53,18 @@ public final class ManaforgeCinder extends CardImpl { } } -class ManaforgeCinderManaEffect extends OneShotEffect { +class ManaforgeCinderManaEffect extends ManaEffect { + + static final List netMana = new ArrayList<>(); + + static { + netMana.add(new Mana(ColoredManaSymbol.R)); + netMana.add(new Mana(ColoredManaSymbol.B)); + } + public ManaforgeCinderManaEffect() { - super(Outcome.PutManaInPool); + super(); this.staticText = "Add {B} or {R}"; } @@ -66,33 +78,36 @@ class ManaforgeCinderManaEffect extends OneShotEffect { } @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Choice manaChoice = new ChoiceImpl(); - Set choices = new LinkedHashSet<>(); - choices.add("Black"); - choices.add("Red"); - manaChoice.setChoices(choices); - manaChoice.setMessage("Select black or red mana to add"); - Mana mana = new Mana(); - if (!controller.choose(Outcome.Benefit, manaChoice, game)) { - return false; + public List getNetMana(Game game, Ability source) { + return netMana; + } + + @Override + public Mana produceMana(Game game, Ability source) { + Mana mana = new Mana(); + if (game == null) { + return mana; + } + Choice choice = new ChoiceColor(true); + choice.getChoices().clear(); + choice.setMessage("Pick a mana color"); + choice.getChoices().add("Red"); + choice.getChoices().add("Black"); + + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + if (!player.choose(outcome, choice, game)) { + return mana; } - if (manaChoice.getChoice() == null) { - return false; - } - switch (manaChoice.getChoice()) { + switch (choice.getChoice()) { case "Black": - mana.increaseBlack(); + mana.setBlack(1); break; case "Red": - mana.increaseRed(); + mana.setRed(1); break; } - controller.getManaPool().addMana(mana, game, source); - return true; } - return false; + return mana; } } diff --git a/Mage.Sets/src/mage/cards/r/RamosDragonEngine.java b/Mage.Sets/src/mage/cards/r/RamosDragonEngine.java index b1f3f879942..908f1fb8b05 100644 --- a/Mage.Sets/src/mage/cards/r/RamosDragonEngine.java +++ b/Mage.Sets/src/mage/cards/r/RamosDragonEngine.java @@ -9,7 +9,7 @@ import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.mana.BasicManaEffect; import mage.abilities.keyword.FlyingAbility; -import mage.abilities.mana.ActivateOncePerTurnManaAbility; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; @@ -45,7 +45,10 @@ public final class RamosDragonEngine extends CardImpl { )); // Remove five +1/+1 counters from Ramos: Add {W}{W}{U}{U}{B}{B}{R}{R}{G}{G}. Activate this ability only once each turn. - Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new BasicManaEffect(new Mana(2, 2, 2, 2, 2, 0, 0, 0)), new RemoveCountersSourceCost(CounterType.P1P1.createInstance(5))); + Ability ability = new LimitedTimesPerTurnActivatedManaAbility( + Zone.BATTLEFIELD, new BasicManaEffect(new Mana(2, 2, 2, 2, 2, 0, 0, 0)), + new RemoveCountersSourceCost(CounterType.P1P1.createInstance(5)) + ); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/s/SalvagedManaworker.java b/Mage.Sets/src/mage/cards/s/SalvagedManaworker.java index f8bc208f6ad..dd0244309a6 100644 --- a/Mage.Sets/src/mage/cards/s/SalvagedManaworker.java +++ b/Mage.Sets/src/mage/cards/s/SalvagedManaworker.java @@ -1,16 +1,17 @@ package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.mana.AddManaOfAnyColorEffect; -import mage.abilities.mana.ActivateOncePerTurnManaAbility; -import mage.constants.SubType; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.SubType; import mage.constants.Zone; +import java.util.UUID; + /** * * @author weirddan455 @@ -25,7 +26,7 @@ public final class SalvagedManaworker extends CardImpl { this.toughness = new MageInt(3); // {1}: Add one mana of any color. Activate only once each turn. - this.addAbility(new ActivateOncePerTurnManaAbility( + this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new GenericManaCost(1) diff --git a/Mage.Sets/src/mage/cards/s/ShireScarecrow.java b/Mage.Sets/src/mage/cards/s/ShireScarecrow.java index 716ca264ddb..15ff62cfae0 100644 --- a/Mage.Sets/src/mage/cards/s/ShireScarecrow.java +++ b/Mage.Sets/src/mage/cards/s/ShireScarecrow.java @@ -4,7 +4,7 @@ import mage.MageInt; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.mana.AddManaOfAnyColorEffect; import mage.abilities.keyword.DefenderAbility; -import mage.abilities.mana.ActivateOncePerTurnManaAbility; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -29,7 +29,7 @@ public final class ShireScarecrow extends CardImpl { this.addAbility(DefenderAbility.getInstance()); // {1}: Add one mana of any color. Activate only once each turn. - this.addAbility(new ActivateOncePerTurnManaAbility( + this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new GenericManaCost(1) )); } diff --git a/Mage.Sets/src/mage/cards/w/WallOfRoots.java b/Mage.Sets/src/mage/cards/w/WallOfRoots.java index 470989450e9..3de00e533f3 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfRoots.java +++ b/Mage.Sets/src/mage/cards/w/WallOfRoots.java @@ -1,13 +1,12 @@ package mage.cards.w; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.costs.common.PutCountersSourceCost; import mage.abilities.effects.mana.BasicManaEffect; import mage.abilities.keyword.DefenderAbility; -import mage.abilities.mana.ActivateOncePerTurnManaAbility; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -15,6 +14,8 @@ import mage.constants.SubType; import mage.constants.Zone; import mage.counters.CounterType; +import java.util.UUID; + /** * * @author North @@ -22,7 +23,7 @@ import mage.counters.CounterType; public final class WallOfRoots extends CardImpl { public WallOfRoots(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); this.subtype.add(SubType.PLANT); this.subtype.add(SubType.WALL); @@ -32,7 +33,10 @@ public final class WallOfRoots extends CardImpl { // Defender this.addAbility(DefenderAbility.getInstance()); // Put a -0/-1 counter on Wall of Roots: Add {G}. Activate this ability only once each turn. - this.addAbility(new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new BasicManaEffect(Mana.GreenMana(1)), new PutCountersSourceCost(CounterType.M0M1.createInstance()))); + this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( + Zone.BATTLEFIELD, new BasicManaEffect(Mana.GreenMana(1)), + new PutCountersSourceCost(CounterType.M0M1.createInstance()) + )); } private WallOfRoots(final WallOfRoots card) { diff --git a/Mage/src/main/java/mage/abilities/mana/ActivateOncePerTurnManaAbility.java b/Mage/src/main/java/mage/abilities/mana/ActivateOncePerTurnManaAbility.java deleted file mode 100644 index 9f729d37806..00000000000 --- a/Mage/src/main/java/mage/abilities/mana/ActivateOncePerTurnManaAbility.java +++ /dev/null @@ -1,51 +0,0 @@ - -package mage.abilities.mana; - -import mage.Mana; -import mage.abilities.costs.Cost; -import mage.abilities.effects.mana.AddManaOfAnyColorEffect; -import mage.abilities.effects.mana.BasicManaEffect; -import mage.constants.Zone; -import mage.game.Game; - -/** - * - * @author LevelX2 - */ -public class ActivateOncePerTurnManaAbility extends ActivatedManaAbilityImpl { - - public ActivateOncePerTurnManaAbility(Zone zone, BasicManaEffect effect, Cost cost) { - super(zone, effect, cost); - this.netMana.add(effect.getManaTemplate()); - this.maxActivationsPerTurn = 1; - } - - public ActivateOncePerTurnManaAbility(Zone zone, AddManaOfAnyColorEffect effect, Cost cost) { - super(zone, effect, cost); - this.netMana.add(new Mana(0, 0, 0, 0, 0, 0, effect.getAmount(), 0)); - this.maxActivationsPerTurn = 1; - } - - public ActivateOncePerTurnManaAbility(ActivateOncePerTurnManaAbility ability) { - super(ability); - } - - @Override - public boolean activate(Game game, boolean noMana) { - if (canActivate(this.controllerId, game).canActivate()) { - return super.activate(game, noMana); - } - return false; - } - - @Override - public String getRule() { - return super.getRule() + " Activate only once each turn."; - } - - @Override - public ActivateOncePerTurnManaAbility copy() { - return new ActivateOncePerTurnManaAbility(this); - } - -} diff --git a/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java b/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java new file mode 100644 index 00000000000..54c1058d629 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java @@ -0,0 +1,75 @@ + +package mage.abilities.mana; + +import mage.Mana; +import mage.abilities.costs.Cost; +import mage.abilities.effects.mana.AddManaOfAnyColorEffect; +import mage.abilities.effects.mana.BasicManaEffect; +import mage.abilities.effects.mana.ManaEffect; +import mage.constants.Zone; +import mage.game.Game; +import mage.util.CardUtil; + +import java.util.Arrays; +import java.util.List; + +/** + * @author LevelX2, Susucr + */ +public class LimitedTimesPerTurnActivatedManaAbility extends ActivatedManaAbilityImpl { + + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, BasicManaEffect effect, Cost cost) { + this(zone, effect, cost, 1); + } + + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, BasicManaEffect effect, Cost cost, int maxActivationPerTurn) { + this(zone, effect, cost, maxActivationPerTurn, effect.getManaTemplate()); + } + + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, AddManaOfAnyColorEffect effect, Cost cost) { + this(zone, effect, cost, 1); + } + + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, AddManaOfAnyColorEffect effect, Cost cost, int maxActivationPerTurn) { + this(zone, effect, cost, maxActivationPerTurn, + new Mana(0, 0, 0, 0, 0, 0, effect.getAmount(), 0)); + } + + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, ManaEffect effect, Cost cost, int maxActivationPerTurn, Mana mana) { + this(zone, effect, cost, maxActivationPerTurn, Arrays.asList(mana)); + } + + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, ManaEffect effect, Cost cost, int maxActivationPerTurn, List mana) { + super(zone, effect, cost); + this.netMana.addAll(mana); + this.maxActivationsPerTurn = maxActivationPerTurn; + } + + private LimitedTimesPerTurnActivatedManaAbility(final LimitedTimesPerTurnActivatedManaAbility ability) { + super(ability); + } + + @Override + public boolean activate(Game game, boolean noMana) { + if (canActivate(this.controllerId, game).canActivate()) { + return super.activate(game, noMana); + } + return false; + } + + @Override + public String getRule() { + String text = super.getRule() + " Activate "; + text += maxActivationsPerTurn == 1 + ? "only once" + : "no more than " + CardUtil.numberToText(maxActivationsPerTurn) + " times"; + text += " each turn."; + return text; + } + + @Override + public LimitedTimesPerTurnActivatedManaAbility copy() { + return new LimitedTimesPerTurnActivatedManaAbility(this); + } + +}