[TDM] Implement Mardu Siegebreaker

This commit is contained in:
theelk801 2025-04-08 09:16:50 -04:00
parent 235e5200d0
commit 2e6e3cd4e7
3 changed files with 138 additions and 1 deletions

View file

@ -0,0 +1,136 @@
package mage.cards.m;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.GameState;
import mage.game.permanent.token.Token;
import mage.target.TargetCard;
import mage.target.TargetPermanent;
import mage.target.common.TargetCardInExile;
import mage.target.targetpointer.FixedTargets;
import mage.util.CardUtil;
import mage.util.functions.CopyTokenFunction;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class MarduSiegebreaker extends CardImpl {
public MarduSiegebreaker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{W}{B}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Deathtouch
this.addAbility(DeathtouchAbility.getInstance());
// Haste
this.addAbility(HasteAbility.getInstance());
// When this creature enters, exile up to one other target creature you control until this creature leaves the battlefield.
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileUntilSourceLeavesEffect());
ability.addTarget(new TargetPermanent(0, 1, StaticFilters.FILTER_OTHER_CONTROLLED_CREATURE));
this.addAbility(ability);
// Whenever this creature attacks, for each opponent, create a tapped token that's a copy of the exiled card attacking that opponent. At the beginning of your end step, sacrifice those tokens.
this.addAbility(new AttacksTriggeredAbility(new MarduSiegebreakerEffect()));
}
private MarduSiegebreaker(final MarduSiegebreaker card) {
super(card);
}
@Override
public MarduSiegebreaker copy() {
return new MarduSiegebreaker(this);
}
}
class MarduSiegebreakerEffect extends OneShotEffect {
MarduSiegebreakerEffect() {
super(Outcome.Benefit);
staticText = "for each opponent, create a tapped token that's a copy of the exiled card " +
"attacking that opponent. At the beginning of your end step, sacrifice those tokens";
}
private MarduSiegebreakerEffect(final MarduSiegebreakerEffect effect) {
super(effect);
}
@Override
public MarduSiegebreakerEffect copy() {
return new MarduSiegebreakerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Cards cards = Optional
.ofNullable(game)
.map(Game::getState)
.map(GameState::getExile)
.map(exile -> exile.getExileZone(CardUtil.getExileZoneId(game, source)))
.orElse(null);
if (cards == null) {
return false;
}
Card card;
switch (cards.size()) {
case 0:
return false;
case 1:
card = cards.getRandom(game);
break;
default:
card = Optional.ofNullable(game.getPlayer(source.getControllerId())).map(player -> {
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD);
target.withNotTarget(true);
target.withChooseHint("to copy");
player.choose(Outcome.Neutral, cards, target, source, game);
return game.getCard(target.getFirstTarget());
}).orElse(null);
}
if (card == null) {
return false;
}
Set<MageObjectReference> addedTokens = new HashSet<>();
Token token = CopyTokenFunction.createTokenCopy(card, game);
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true, opponentId);
token.getLastAddedTokenIds()
.stream()
.map(uuid -> new MageObjectReference(uuid, game))
.forEach(addedTokens::add);
}
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new SacrificeTargetEffect().setTargetPointer(new FixedTargets(addedTokens))
), source);
return true;
}
}

View file

@ -143,6 +143,7 @@ public final class TarkirDragonstorm extends ExpansionSet {
cards.add(new SetCardInfo("Mammoth Bellow", 205, Rarity.UNCOMMON, mage.cards.m.MammothBellow.class));
cards.add(new SetCardInfo("Mardu Devotee", 16, Rarity.COMMON, mage.cards.m.MarduDevotee.class));
cards.add(new SetCardInfo("Mardu Monument", 245, Rarity.UNCOMMON, mage.cards.m.MarduMonument.class));
cards.add(new SetCardInfo("Mardu Siegebreaker", 206, Rarity.RARE, mage.cards.m.MarduSiegebreaker.class));
cards.add(new SetCardInfo("Marshal of the Lost", 207, Rarity.UNCOMMON, mage.cards.m.MarshalOfTheLost.class));
cards.add(new SetCardInfo("Meticulous Artisan", 112, Rarity.COMMON, mage.cards.m.MeticulousArtisan.class));
cards.add(new SetCardInfo("Molten Exhale", 113, Rarity.COMMON, mage.cards.m.MoltenExhale.class));

View file

@ -50,7 +50,7 @@ public class FixedTargets extends TargetPointerImpl {
.collect(Collectors.toList()), game);
}
public FixedTargets(List<MageObjectReference> morList) {
public FixedTargets(Collection<MageObjectReference> morList) {
super();
targets.addAll(morList);
this.setInitialized(); // no need dynamic init