[SNC] Implemented Fatal Grudge

This commit is contained in:
Daniel Bomar 2022-04-13 10:23:13 -05:00
parent 21c7e26a94
commit b9588a523f
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 114 additions and 0 deletions

View file

@ -0,0 +1,113 @@
package mage.cards.f;
import java.util.HashSet;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
/**
*
* @author weirddan455
*/
public final class FatalGrudge extends CardImpl {
public FatalGrudge(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}{R}");
// As an additional cost to cast this spell, sacrifice a nonland permanent.
this.getSpellAbility().addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND));
// Each opponent chooses a permanent they control that shares a type with the sacrificed permanent and sacrifices it.
this.getSpellAbility().addEffect(new FatalGrudgeEffect());
// Draw a card.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
}
private FatalGrudge(final FatalGrudge card) {
super(card);
}
@Override
public FatalGrudge copy() {
return new FatalGrudge(this);
}
}
class FatalGrudgeEffect extends OneShotEffect {
public FatalGrudgeEffect() {
super(Outcome.Sacrifice);
this.staticText = "each opponent chooses a permanent they control that shares a type with the sacrificed permanent and sacrifices it";
}
private FatalGrudgeEffect(final FatalGrudgeEffect effect) {
super(effect);
}
@Override
public FatalGrudgeEffect copy() {
return new FatalGrudgeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
HashSet<CardType> types = new HashSet<>();
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
for (Permanent sacrificed : ((SacrificeTargetCost) cost).getPermanents()) {
types.addAll(sacrificed.getCardType(game));
}
}
}
FilterControlledPermanent filter = new FilterControlledPermanent("permanent you control that shares a type with the sacrificed permanent");
filter.add(new FatalGrudgePredicate(types));
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
opponent.chooseTarget(Outcome.Sacrifice, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
}
return true;
}
}
class FatalGrudgePredicate implements Predicate<MageObject> {
private final HashSet<CardType> types;
public FatalGrudgePredicate(HashSet<CardType> types) {
this.types = types;
}
@Override
public boolean apply(MageObject input, Game game) {
for (CardType type : input.getCardType(game)) {
if (types.contains(type)) {
return true;
}
}
return false;
}
}

View file

@ -64,6 +64,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet {
cards.add(new SetCardInfo("Evolving Door", 144, Rarity.RARE, mage.cards.e.EvolvingDoor.class));
cards.add(new SetCardInfo("Exotic Pets", 185, Rarity.UNCOMMON, mage.cards.e.ExoticPets.class));
cards.add(new SetCardInfo("Faerie Vandal", 44, Rarity.UNCOMMON, mage.cards.f.FaerieVandal.class));
cards.add(new SetCardInfo("Fatal Grudge", 187, Rarity.UNCOMMON, mage.cards.f.FatalGrudge.class));
cards.add(new SetCardInfo("Fight Rigging", 145, Rarity.RARE, mage.cards.f.FightRigging.class));
cards.add(new SetCardInfo("Fleetfoot Dancer", 188, Rarity.RARE, mage.cards.f.FleetfootDancer.class));
cards.add(new SetCardInfo("Forest", 270, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));