[MAT] Implement Tazri, Stalwart Survivor

This commit is contained in:
theelk801 2023-05-10 09:36:43 -04:00
parent 4c13b42dee
commit 4e7e0b2a8d
4 changed files with 363 additions and 83 deletions

View file

@ -113,38 +113,43 @@ class KatildaDawnhartPrimeManaEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>(); if (game == null) {
if (game != null) { return new ArrayList<>();
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game); Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null) { if (permanent == null) {
return new ArrayList<>();
}
List<Mana> netMana = new ArrayList<>();
ObjectColor color = permanent.getColor(game); ObjectColor color = permanent.getColor(game);
if (color.isWhite()) { if (color.isWhite()) {
netMana.add(new Mana(ColoredManaSymbol.W)); netMana.add(Mana.WhiteMana(1));
} }
if (color.isBlue()) { if (color.isBlue()) {
netMana.add(new Mana(ColoredManaSymbol.U)); netMana.add(Mana.BlueMana(1));
} }
if (color.isBlack()) { if (color.isBlack()) {
netMana.add(new Mana(ColoredManaSymbol.B)); netMana.add(Mana.BlackMana(1));
} }
if (color.isRed()) { if (color.isRed()) {
netMana.add(new Mana(ColoredManaSymbol.R)); netMana.add(Mana.RedMana(1));
} }
if (color.isGreen()) { if (color.isGreen()) {
netMana.add(new Mana(ColoredManaSymbol.G)); netMana.add(Mana.GreenMana(1));
}
}
} }
return netMana; return netMana;
} }
@Override @Override
public Mana produceMana(Game game, Ability source) { public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana(); if (game == null) {
if (game != null) { return new Mana();
}
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game); Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (controller != null && permanent != null) { if (controller == null || permanent == null) {
return new Mana();
}
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setMessage("Pick a mana color"); choice.setMessage("Pick a mana color");
ObjectColor color = permanent.getColor(game); ObjectColor color = permanent.getColor(game);
@ -163,35 +168,30 @@ class KatildaDawnhartPrimeManaEffect extends ManaEffect {
if (color.isGreen()) { if (color.isGreen()) {
choice.getChoices().add("Green"); choice.getChoices().add("Green");
} }
if (!choice.getChoices().isEmpty()) { if (choice.getChoices().isEmpty()) {
return new Mana();
}
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
controller.choose(outcome, choice, game); controller.choose(outcome, choice, game);
} }
if (choice.getChoice() == null) {
if (choice.getChoice() != null) { return new Mana();
}
switch (choice.getChoice()) { switch (choice.getChoice()) {
case "White": case "White":
mana.setWhite(1); return Mana.WhiteMana(1);
break;
case "Blue": case "Blue":
mana.setBlue(1); return Mana.BlueMana(1);
break;
case "Black": case "Black":
mana.setBlack(1); return Mana.BlackMana(1);
break;
case "Red": case "Red":
mana.setRed(1); return Mana.RedMana(1);
break;
case "Green": case "Green":
mana.setGreen(1); return Mana.GreenMana(1);
break; default:
return new Mana();
} }
} }
}
}
}
return mana;
}
} }

View file

@ -1,7 +1,5 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID;
import mage.ConditionalMana; import mage.ConditionalMana;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
@ -15,19 +13,19 @@ import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.abilities.mana.conditional.ManaCondition; import mage.abilities.mana.conditional.ManaCondition;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.AbilityType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.game.Game; import mage.game.Game;
import java.util.UUID;
/** /**
*
* @author hanasu * @author hanasu
*/ */
public final class SoldeviMachinist extends CardImpl { public final class SoldeviMachinist extends CardImpl {
public SoldeviMachinist(UUID ownerId, CardSetInfo setInfo) { public SoldeviMachinist(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD); this.subtype.add(SubType.WIZARD);
this.subtype.add(SubType.ARTIFICER); this.subtype.add(SubType.ARTIFICER);
@ -74,14 +72,16 @@ class ArtifactAbilityManaCondition extends ManaCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (source != null && source.getAbilityType() == AbilityType.ACTIVATED) { switch (source.getAbilityType()) {
MageObject object = game.getObject(source); case ACTIVATED:
if (object != null && object.isArtifact(game)) { case MANA:
return true; break;
} default:
}
return false; return false;
} }
MageObject object = game.getObject(source);
return object != null && object.isArtifact(game);
}
@Override @Override
public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) { public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) {

View file

@ -0,0 +1,279 @@
package mage.cards.t;
import mage.*;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.conditional.ManaCondition;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class TazriStalwartSurvivor extends CardImpl {
public TazriStalwartSurvivor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Each creature you control has "{T}: Add one mana of any of this creature's colors. Spend this mana only to activate an ability of a creature. Activate only if this creature has another activated ability."
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
new TazriStalwartSurvivorManaAbility(), Duration.WhileOnBattlefield,
StaticFilters.FILTER_PERMANENT_CREATURE
).setText("each creature you control has \"{T}: Add one mana of any of this creature's colors. " +
"Spend this mana only to activate an ability of a creature. Activate only if " +
"this creature has another activated ability.\"")));
// {W}{U}{B}{R}{G}, {T}: Mill five cards. Put all creature cards with activated abilities that aren't mana abilities from among the milled cards into your hand.
Ability ability = new SimpleActivatedAbility(
new TazriStalwartSurvivorMillEffect(), new ManaCostsImpl<>("{W}{U}{B}{R}{G}")
);
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
private TazriStalwartSurvivor(final TazriStalwartSurvivor card) {
super(card);
}
@Override
public TazriStalwartSurvivor copy() {
return new TazriStalwartSurvivor(this);
}
}
class TazriStalwartSurvivorManaAbility extends ActivatedManaAbilityImpl {
private enum TazriStalwartSurvivorCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
return permanent != null
&& permanent
.getAbilities(game)
.stream()
.filter(ability -> ability.getAbilityType() == AbilityType.ACTIVATED
|| ability.getAbilityType() == AbilityType.MANA)
.map(Ability::getOriginalId)
.anyMatch(abilityId -> !source.getOriginalId().equals(abilityId));
}
}
TazriStalwartSurvivorManaAbility() {
super(Zone.BATTLEFIELD, new TazriStalwartSurvivorManaEffect(), new TapSourceCost());
this.condition = TazriStalwartSurvivorCondition.instance;
}
private TazriStalwartSurvivorManaAbility(final TazriStalwartSurvivorManaAbility ability) {
super(ability);
}
@Override
public TazriStalwartSurvivorManaAbility copy() {
return new TazriStalwartSurvivorManaAbility(this);
}
@Override
public String getRule() {
return "{T}: Add one mana of any of this creature's colors. " +
"Spend this mana only to activate an ability of a creature. " +
"Activate only if this creature has another activated ability.";
}
}
class TazriStalwartSurvivorManaEffect extends ManaEffect {
private static final class TazriStalwartSurvivorConditionalMana extends ConditionalMana {
public TazriStalwartSurvivorConditionalMana(Mana mana) {
super(mana);
staticText = "Spend this mana only to activate abilities of creatures";
addCondition(new TazriStalwartSurvivorManaCondition());
}
}
private static final class TazriStalwartSurvivorManaCondition extends ManaCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
switch (source.getAbilityType()) {
case ACTIVATED:
case MANA:
break;
default:
return false;
}
MageObject object = game.getObject(source);
return object != null && object.isCreature(game);
}
@Override
public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) {
return apply(game, source);
}
}
public TazriStalwartSurvivorManaEffect() {
super();
staticText = "Add one mana of any of this creature's colors. " +
"Spend this mana only to activate an ability of a creature";
}
private TazriStalwartSurvivorManaEffect(final TazriStalwartSurvivorManaEffect effect) {
super(effect);
}
@Override
public TazriStalwartSurvivorManaEffect copy() {
return new TazriStalwartSurvivorManaEffect(this);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
if (game == null) {
return new ArrayList<>();
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null) {
return new ArrayList<>();
}
List<Mana> netMana = new ArrayList<>();
ObjectColor color = permanent.getColor(game);
if (color.isWhite()) {
netMana.add(new TazriStalwartSurvivorConditionalMana(Mana.WhiteMana(1)));
}
if (color.isBlue()) {
netMana.add(new TazriStalwartSurvivorConditionalMana(Mana.BlueMana(1)));
}
if (color.isBlack()) {
netMana.add(new TazriStalwartSurvivorConditionalMana(Mana.BlackMana(1)));
}
if (color.isRed()) {
netMana.add(new TazriStalwartSurvivorConditionalMana(Mana.RedMana(1)));
}
if (color.isGreen()) {
netMana.add(new TazriStalwartSurvivorConditionalMana(Mana.GreenMana(1)));
}
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
if (game == null) {
return new Mana();
}
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (controller == null || permanent == null) {
return new Mana();
}
Choice choice = new ChoiceImpl();
choice.setMessage("Pick a mana color");
ObjectColor color = permanent.getColor(game);
if (color.isWhite()) {
choice.getChoices().add("White");
}
if (color.isBlue()) {
choice.getChoices().add("Blue");
}
if (color.isBlack()) {
choice.getChoices().add("Black");
}
if (color.isRed()) {
choice.getChoices().add("Red");
}
if (color.isGreen()) {
choice.getChoices().add("Green");
}
if (choice.getChoices().isEmpty()) {
return new Mana();
}
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
controller.choose(outcome, choice, game);
}
if (choice.getChoice() == null) {
return new Mana();
}
switch (choice.getChoice()) {
case "White":
return new TazriStalwartSurvivorConditionalMana(Mana.WhiteMana(1));
case "Blue":
return new TazriStalwartSurvivorConditionalMana(Mana.BlueMana(1));
case "Black":
return new TazriStalwartSurvivorConditionalMana(Mana.BlackMana(1));
case "Red":
return new TazriStalwartSurvivorConditionalMana(Mana.RedMana(1));
case "Green":
return new TazriStalwartSurvivorConditionalMana(Mana.GreenMana(1));
default:
return new Mana();
}
}
}
class TazriStalwartSurvivorMillEffect extends OneShotEffect {
TazriStalwartSurvivorMillEffect() {
super(Outcome.Benefit);
staticText = "mill five cards. Put all creature cards with activated abilities " +
"that aren't mana abilities from among the milled cards into your hand";
}
private TazriStalwartSurvivorMillEffect(final TazriStalwartSurvivorMillEffect effect) {
super(effect);
}
@Override
public TazriStalwartSurvivorMillEffect copy() {
return new TazriStalwartSurvivorMillEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = player.millCards(5, source, game);
cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
cards.removeIf(uuid -> game
.getCard(uuid)
.getAbilities(game)
.stream()
.map(Ability::getAbilityType)
.noneMatch(AbilityType.ACTIVATED::equals));
player.moveCards(cards, Zone.HAND, source, game);
return true;
}
}

View file

@ -59,6 +59,7 @@ public final class MarchOfTheMachineTheAftermath extends ExpansionSet {
cards.add(new SetCardInfo("Sarkhan, Soul Aflame", 46, Rarity.MYTHIC, mage.cards.s.SarkhanSoulAflame.class)); cards.add(new SetCardInfo("Sarkhan, Soul Aflame", 46, Rarity.MYTHIC, mage.cards.s.SarkhanSoulAflame.class));
cards.add(new SetCardInfo("Sigarda, Font of Blessings", 47, Rarity.RARE, mage.cards.s.SigardaFontOfBlessings.class)); cards.add(new SetCardInfo("Sigarda, Font of Blessings", 47, Rarity.RARE, mage.cards.s.SigardaFontOfBlessings.class));
cards.add(new SetCardInfo("Spark Rupture", 5, Rarity.RARE, mage.cards.s.SparkRupture.class)); cards.add(new SetCardInfo("Spark Rupture", 5, Rarity.RARE, mage.cards.s.SparkRupture.class));
cards.add(new SetCardInfo("Tazri, Stalwart Survivor", 6, Rarity.RARE, mage.cards.t.TazriStalwartSurvivor.class));
cards.add(new SetCardInfo("The Kenriths' Royal Funeral", 34, Rarity.RARE, mage.cards.t.TheKenrithsRoyalFuneral.class)); cards.add(new SetCardInfo("The Kenriths' Royal Funeral", 34, Rarity.RARE, mage.cards.t.TheKenrithsRoyalFuneral.class));
cards.add(new SetCardInfo("Tolarian Contempt", 8, Rarity.UNCOMMON, mage.cards.t.TolarianContempt.class)); cards.add(new SetCardInfo("Tolarian Contempt", 8, Rarity.UNCOMMON, mage.cards.t.TolarianContempt.class));
cards.add(new SetCardInfo("Training Grounds", 9, Rarity.RARE, mage.cards.t.TrainingGrounds.class)); cards.add(new SetCardInfo("Training Grounds", 9, Rarity.RARE, mage.cards.t.TrainingGrounds.class));