[JUD] Implemented Grave Consequences

This commit is contained in:
Evan Kranzler 2022-03-01 19:16:10 -05:00
parent 0cc1b152c4
commit 5e1e69bdfd
2 changed files with 91 additions and 0 deletions

View file

@ -0,0 +1,90 @@
package mage.cards.g;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public final class GraveConsequences extends CardImpl {
public GraveConsequences(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}");
// Each player may exile any number of cards from their graveyard. Then each player loses 1 life for each card in their graveyard.
this.getSpellAbility().addEffect(new GraveConsequencesEffect());
// Draw a card.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1).concatBy("<br>"));
}
private GraveConsequences(final GraveConsequences card) {
super(card);
}
@Override
public GraveConsequences copy() {
return new GraveConsequences(this);
}
}
class GraveConsequencesEffect extends OneShotEffect {
GraveConsequencesEffect() {
super(Outcome.Exile);
staticText = "each player may exile any number of cards from their graveyard. " +
"Then each player loses 1 life for each card in their graveyard";
}
private GraveConsequencesEffect(final GraveConsequencesEffect effect) {
super(effect);
}
@Override
public GraveConsequencesEffect copy() {
return new GraveConsequencesEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
List<Player> players = game
.getState()
.getPlayersInRange(source.getControllerId(), game)
.stream()
.map(game::getPlayer)
.filter(Objects::nonNull)
.collect(Collectors.toList());
for (Player player : players) {
TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
Cards cards = new CardsImpl(target.getTargets());
if (!cards.isEmpty()) {
player.moveCards(cards, Zone.EXILED, source, game);
}
}
for (Player player : players) {
if (!player.getGraveyard().isEmpty()) {
player.loseLife(player.getLife(), game, source, false);
}
}
return true;
}
}

View file

@ -85,6 +85,7 @@ public final class Judgment extends ExpansionSet {
cards.add(new SetCardInfo("Glory", 11, Rarity.RARE, mage.cards.g.Glory.class));
cards.add(new SetCardInfo("Golden Wish", 12, Rarity.RARE, mage.cards.g.GoldenWish.class));
cards.add(new SetCardInfo("Goretusk Firebeast", 91, Rarity.COMMON, mage.cards.g.GoretuskFirebeast.class));
cards.add(new SetCardInfo("Grave Consequences", 67, Rarity.UNCOMMON, mage.cards.g.GraveConsequences.class));
cards.add(new SetCardInfo("Grip of Amnesia", 41, Rarity.COMMON, mage.cards.g.GripOfAmnesia.class));
cards.add(new SetCardInfo("Grizzly Fate", 119, Rarity.UNCOMMON, mage.cards.g.GrizzlyFate.class));
cards.add(new SetCardInfo("Guided Strike", 13, Rarity.COMMON, mage.cards.g.GuidedStrike.class));