From 9e0bd2d4070be1c331d16eaa5cdc02e971a30d23 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 23 Mar 2025 09:00:46 -0400 Subject: [PATCH] [TDM] Implement Abzan Devotee (#13464) * [TDM] Implement Abzan Devotee * small update to constructors --- Mage.Sets/src/mage/cards/a/AbzanDevotee.java | 51 ++++++++++++ .../src/mage/cards/m/ManaforgeCinder.java | 81 ++----------------- .../src/mage/sets/TarkirDragonstorm.java | 1 + .../mana/AddManaFromColorChoicesEffect.java | 75 +++++++++++++++++ ...mitedTimesPerTurnActivatedManaAbility.java | 9 +++ .../main/java/mage/constants/ManaType.java | 15 ++-- 6 files changed, 147 insertions(+), 85 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/a/AbzanDevotee.java create mode 100644 Mage/src/main/java/mage/abilities/effects/mana/AddManaFromColorChoicesEffect.java diff --git a/Mage.Sets/src/mage/cards/a/AbzanDevotee.java b/Mage.Sets/src/mage/cards/a/AbzanDevotee.java new file mode 100644 index 00000000000..f6b3e921465 --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AbzanDevotee.java @@ -0,0 +1,51 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; +import mage.abilities.effects.mana.AddManaFromColorChoicesEffect; +import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.ManaType; +import mage.constants.SubType; +import mage.constants.Zone; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AbzanDevotee extends CardImpl { + + public AbzanDevotee(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); + + this.subtype.add(SubType.DOG); + this.subtype.add(SubType.CLERIC); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // {1}: Add {W}, {B}, or {G}. Activate only once each turn. + this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( + new AddManaFromColorChoicesEffect(ManaType.WHITE, ManaType.BLACK, ManaType.GREEN), new GenericManaCost(1) + )); + + // {2}{B}: Return this card from your graveyard to your hand. + this.addAbility(new SimpleActivatedAbility( + Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new ManaCostsImpl<>("{2}{B}") + )); + } + + private AbzanDevotee(final AbzanDevotee card) { + super(card); + } + + @Override + public AbzanDevotee copy() { + return new AbzanDevotee(this); + } +} diff --git a/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java b/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java index 7edcfbd9c12..146db9800e2 100644 --- a/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java +++ b/Mage.Sets/src/mage/cards/m/ManaforgeCinder.java @@ -1,25 +1,15 @@ - package mage.cards.m; import mage.MageInt; -import mage.Mana; -import mage.abilities.Ability; -import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.mana.ManaEffect; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.mana.AddManaFromColorChoicesEffect; import mage.abilities.mana.LimitedTimesPerTurnActivatedManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.choices.Choice; -import mage.choices.ChoiceColor; import mage.constants.CardType; -import mage.constants.ColoredManaSymbol; +import mage.constants.ManaType; 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; /** @@ -36,11 +26,9 @@ public final class ManaforgeCinder extends CardImpl { // {1}: Add {B} or {R}. Activate this ability no more than three times each turn. this.addAbility(new LimitedTimesPerTurnActivatedManaAbility( - Zone.BATTLEFIELD, new ManaforgeCinderManaEffect(), - new ManaCostsImpl<>("{1}"), 3, - ManaforgeCinderManaEffect.netMana + new AddManaFromColorChoicesEffect(ManaType.BLACK, ManaType.RED), + new GenericManaCost(1), 3 )); - } private ManaforgeCinder(final ManaforgeCinder card) { @@ -52,62 +40,3 @@ public final class ManaforgeCinder extends CardImpl { return new ManaforgeCinder(this); } } - -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(); - this.staticText = "Add {B} or {R}"; - } - - private ManaforgeCinderManaEffect(final ManaforgeCinderManaEffect effect) { - super(effect); - } - - @Override - public ManaforgeCinderManaEffect copy() { - return new ManaforgeCinderManaEffect(this); - } - - @Override - 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; - } - switch (choice.getChoice()) { - case "Black": - mana.setBlack(1); - break; - case "Red": - mana.setRed(1); - break; - } - } - return mana; - } -} diff --git a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java index 8ea4ca645cc..a8f1d25869f 100644 --- a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java +++ b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java @@ -20,6 +20,7 @@ public final class TarkirDragonstorm extends ExpansionSet { this.blockName = "Tarkir: Dragonstorm"; // for sorting in GUI this.hasBasicLands = true; + cards.add(new SetCardInfo("Abzan Devotee", 68, Rarity.COMMON, mage.cards.a.AbzanDevotee.class)); cards.add(new SetCardInfo("Aegis Sculptor", 35, Rarity.UNCOMMON, mage.cards.a.AegisSculptor.class)); cards.add(new SetCardInfo("Agent of Kotis", 36, Rarity.COMMON, mage.cards.a.AgentOfKotis.class)); cards.add(new SetCardInfo("Anafenza, Unyielding Lineage", 2, Rarity.RARE, mage.cards.a.AnafenzaUnyieldingLineage.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/mana/AddManaFromColorChoicesEffect.java b/Mage/src/main/java/mage/abilities/effects/mana/AddManaFromColorChoicesEffect.java new file mode 100644 index 00000000000..709bf7f0d6d --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/mana/AddManaFromColorChoicesEffect.java @@ -0,0 +1,75 @@ +package mage.abilities.effects.mana; + +import mage.Mana; +import mage.abilities.Ability; +import mage.choices.Choice; +import mage.constants.ManaType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public class AddManaFromColorChoicesEffect extends ManaEffect { + + private final List manaTypes = new ArrayList<>(); + private final List netMana = new ArrayList<>(); + + public AddManaFromColorChoicesEffect(ManaType... manaTypes) { + super(); + for (ManaType manaType : manaTypes) { + this.manaTypes.add(manaType); + } + this.manaTypes + .stream() + .map(CardUtil::manaTypeToColoredManaSymbol) + .map(Mana::new) + .forEach(netMana::add); + staticText = "add " + CardUtil + .concatWithOr(this.netMana.stream().map(s -> "{" + s + '}').collect(Collectors.toList())); + } + + private AddManaFromColorChoicesEffect(final AddManaFromColorChoicesEffect effect) { + super(effect); + this.manaTypes.addAll(effect.manaTypes); + effect.netMana.stream().map(Mana::copy).forEach(this.netMana::add); + } + + @Override + public AddManaFromColorChoicesEffect copy() { + return new AddManaFromColorChoicesEffect(this); + } + + @Override + public List getNetMana(Game game, Ability source) { + return netMana; + } + + public List getNetMana() { + return netMana; + } + + @Override + public Mana produceMana(Game game, Ability source) { + if (game == null || manaTypes.isEmpty()) { + return null; + } + Choice choice = ManaType.getChoiceOfManaTypes(manaTypes, false); + if (choice.getChoices().size() <= 1) { + choice.setChoice(choice.getChoices().iterator().next()); + } else { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || !player.choose(Outcome.PutManaInPool, choice, game)) { + return null; + } + } + ManaType chosenType = ManaType.findByName(choice.getChoice()); + return chosenType == null ? null : new Mana(chosenType); + } +} diff --git a/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java b/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java index 84f3c753328..f5e79185ea2 100644 --- a/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/LimitedTimesPerTurnActivatedManaAbility.java @@ -4,6 +4,7 @@ package mage.abilities.mana; import mage.MageIdentifier; import mage.Mana; import mage.abilities.costs.Cost; +import mage.abilities.effects.mana.AddManaFromColorChoicesEffect; import mage.abilities.effects.mana.AddManaOfAnyColorEffect; import mage.abilities.effects.mana.BasicManaEffect; import mage.abilities.effects.mana.ManaEffect; @@ -37,6 +38,14 @@ public class LimitedTimesPerTurnActivatedManaAbility extends ActivatedManaAbilit new Mana(0, 0, 0, 0, 0, 0, effect.getAmount(), 0)); } + public LimitedTimesPerTurnActivatedManaAbility(AddManaFromColorChoicesEffect effect, Cost cost) { + this(effect, cost, 1); + } + + public LimitedTimesPerTurnActivatedManaAbility(AddManaFromColorChoicesEffect effect, Cost cost, int maxActivationPerTurn) { + this(Zone.BATTLEFIELD, effect, cost, maxActivationPerTurn, effect.getNetMana()); + } + public LimitedTimesPerTurnActivatedManaAbility(Zone zone, ManaEffect effect, Cost cost, int maxActivationPerTurn, Mana mana) { this(zone, effect, cost, maxActivationPerTurn, Arrays.asList(mana)); } diff --git a/Mage/src/main/java/mage/constants/ManaType.java b/Mage/src/main/java/mage/constants/ManaType.java index c71e389b33e..5ae77674ae1 100644 --- a/Mage/src/main/java/mage/constants/ManaType.java +++ b/Mage/src/main/java/mage/constants/ManaType.java @@ -1,16 +1,12 @@ package mage.constants; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import mage.Mana; import mage.choices.Choice; import mage.choices.ChoiceColor; +import java.util.*; + /** - * * @author North */ public enum ManaType { @@ -34,7 +30,7 @@ public enum ManaType { return text; } - public static Choice getChoiceOfManaTypes(Set types, boolean onlyColors) { + public static Choice getChoiceOfManaTypes(Collection types, boolean onlyColors) { Choice choice = new ChoiceColor(true); choice.getChoices().clear(); choice.setMessage("Pick a mana " + (onlyColors ? "color" : "type")); @@ -124,8 +120,8 @@ public enum ManaType { *

* Used for things like mapping back to a ManaType after the user chose from several of them. * - * @param name The name of the mana to find - * @return The ManaType representing that mana (or null) + * @param name The name of the mana to find + * @return The ManaType representing that mana (or null) */ public static ManaType findByName(String name) { switch (name) { @@ -153,6 +149,7 @@ public enum ManaType { } return manaTypes; } + public static Set getTrueManaTypes() { return EnumSet.of(BLACK, BLUE, GREEN, RED, WHITE, COLORLESS); }