[TDM] Implement Abzan Devotee (#13464)

* [TDM] Implement Abzan Devotee

* small update to constructors
This commit is contained in:
Evan Kranzler 2025-03-23 09:00:46 -04:00 committed by GitHub
parent f30060ae95
commit 9e0bd2d407
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 147 additions and 85 deletions

View file

@ -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);
}
}

View file

@ -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<Mana> 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<Mana> 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;
}
}

View file

@ -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));

View file

@ -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<ManaType> manaTypes = new ArrayList<>();
private final List<Mana> 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<Mana> getNetMana(Game game, Ability source) {
return netMana;
}
public List<Mana> 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);
}
}

View file

@ -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));
}

View file

@ -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<ManaType> types, boolean onlyColors) {
public static Choice getChoiceOfManaTypes(Collection<ManaType> 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 {
* <p>
* 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<ManaType> getTrueManaTypes() {
return EnumSet.of(BLACK, BLUE, GREEN, RED, WHITE, COLORLESS);
}