[DMU] Implemented Braids, Arisen Nightmare

This commit is contained in:
Daniel Bomar 2022-08-19 14:33:11 -05:00
parent 462552d0ef
commit 63bbbcfc81
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 149 additions and 0 deletions

View file

@ -0,0 +1,148 @@
package mage.cards.b;
import java.util.HashSet;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
/**
*
* @author weirddan455
*/
public final class BraidsArisenNightmare extends CardImpl {
public BraidsArisenNightmare(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.NIGHTMARE);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// At the beginning of your end step, you may sacrifice an artifact, creature, enchantment, land, or planeswalker.
// If you do, each opponent may sacrifice a permanent that shares a card type with it.
// For each opponent who doesn't, that player loses 2 life and you draw a card.
this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new BraidsArisenNightmareEffect(), true));
}
private BraidsArisenNightmare(final BraidsArisenNightmare card) {
super(card);
}
@Override
public BraidsArisenNightmare copy() {
return new BraidsArisenNightmare(this);
}
}
class BraidsArisenNightmareEffect extends OneShotEffect {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("an artifact, creature, enchantment, land, or planeswalker");
static {
filter.add(Predicates.or(
CardType.ARTIFACT.getPredicate(),
CardType.CREATURE.getPredicate(),
CardType.ENCHANTMENT.getPredicate(),
CardType.LAND.getPredicate(),
CardType.PLANESWALKER.getPredicate()
));
}
public BraidsArisenNightmareEffect() {
super(Outcome.Sacrifice);
this.staticText = "you may sacrifice an artifact, creature, enchantment, land, or planeswalker. " +
"If you do, each opponent may sacrifice a permanent that shares a card type with it. " +
"For each opponent who doesn't, that player loses 2 life and you draw a card";
}
private BraidsArisenNightmareEffect(final BraidsArisenNightmareEffect effect) {
super(effect);
}
@Override
public BraidsArisenNightmareEffect copy() {
return new BraidsArisenNightmareEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
if (!target.canChoose(controller.getId(), source, game)) {
return false;
}
controller.chooseTarget(Outcome.Sacrifice, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
FilterControlledPermanent opponentFilter = new FilterControlledPermanent("a permanent that shares a card type with " + permanent.getName());
opponentFilter.add(new BraidsArisenNightmarePredicate(new HashSet<>(permanent.getCardType(game))));
if (!permanent.sacrifice(source, game)) {
return false;
}
for (UUID opponentId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent == null) {
continue;
}
if (!braidsSacrifice(opponent, opponentFilter, game, source)) {
opponent.loseLife(2, game, source, false);
controller.drawCards(1, source, game);
}
}
return true;
}
private boolean braidsSacrifice(Player opponent, FilterControlledPermanent opponentFilter, Game game, Ability source) {
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, opponentFilter, true);
if (!target.canChoose(opponent.getId(), source, game)) {
return false;
}
if (!opponent.chooseUse(Outcome.Sacrifice, "Sacrifice " + opponentFilter.getMessage() + '?', source, game)) {
return false;
}
opponent.chooseTarget(Outcome.Sacrifice, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
return permanent != null && permanent.sacrifice(source, game);
}
}
class BraidsArisenNightmarePredicate implements Predicate<MageObject> {
private final HashSet<CardType> cardTypes;
public BraidsArisenNightmarePredicate(HashSet<CardType> cardTypes) {
this.cardTypes = cardTypes;
}
@Override
public boolean apply(MageObject input, Game game) {
for (CardType type : input.getCardType(game)) {
if (cardTypes.contains(type)) {
return true;
}
}
return false;
}
}

View file

@ -29,6 +29,7 @@ public final class DominariaUnited extends ExpansionSet {
cards.add(new SetCardInfo("Adarkar Wastes", 243, Rarity.RARE, mage.cards.a.AdarkarWastes.class));
cards.add(new SetCardInfo("Benalish Sleeper", 8, Rarity.COMMON, mage.cards.b.BenalishSleeper.class));
cards.add(new SetCardInfo("Braids, Arisen Nightmare", 84, Rarity.RARE, mage.cards.b.BraidsArisenNightmare.class));
cards.add(new SetCardInfo("Caves of Koilos", 244, Rarity.RARE, mage.cards.c.CavesOfKoilos.class));
cards.add(new SetCardInfo("Charismatic Vanguard", 10, Rarity.COMMON, mage.cards.c.CharismaticVanguard.class));
cards.add(new SetCardInfo("Evolved Sleeper", 93, Rarity.RARE, mage.cards.e.EvolvedSleeper.class));