From 20a577fc5a9dc9894effea6918ac5f6dc9cdb6d2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 9 Apr 2022 10:08:23 -0400 Subject: [PATCH] [SNC] Implemented Incriminate --- Mage.Sets/src/mage/cards/b/BarrinsSpite.java | 5 +- Mage.Sets/src/mage/cards/c/Cannibalize.java | 5 +- Mage.Sets/src/mage/cards/i/Incriminate.java | 101 ++++++++++++++++++ Mage.Sets/src/mage/cards/s/SorrowsPath.java | 2 +- .../src/mage/sets/StreetsOfNewCapenna.java | 1 + ...TargetCreaturePermanentSameController.java | 14 ++- 6 files changed, 114 insertions(+), 14 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/i/Incriminate.java diff --git a/Mage.Sets/src/mage/cards/b/BarrinsSpite.java b/Mage.Sets/src/mage/cards/b/BarrinsSpite.java index a9be4bde62..f90e68333c 100644 --- a/Mage.Sets/src/mage/cards/b/BarrinsSpite.java +++ b/Mage.Sets/src/mage/cards/b/BarrinsSpite.java @@ -7,7 +7,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; -import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -30,9 +29,7 @@ public final class BarrinsSpite extends CardImpl { // Choose two target creatures controlled by the same player. Their controller chooses and sacrifices one of them. Return the other to its owner's hand. this.getSpellAbility().addEffect(new BarrinsSpiteEffect()); - this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController( - 2, 2, StaticFilters.FILTER_PERMANENT_CREATURE, false - )); + this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController(2)); } private BarrinsSpite(final BarrinsSpite card) { diff --git a/Mage.Sets/src/mage/cards/c/Cannibalize.java b/Mage.Sets/src/mage/cards/c/Cannibalize.java index 32a4d8eac1..4d6fc737ba 100644 --- a/Mage.Sets/src/mage/cards/c/Cannibalize.java +++ b/Mage.Sets/src/mage/cards/c/Cannibalize.java @@ -8,7 +8,6 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; import mage.counters.CounterType; -import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -29,9 +28,7 @@ public final class Cannibalize extends CardImpl { // Choose two target creatures controlled by the same player. Exile one of the creatures and put two +1/+1 counters on the other. this.getSpellAbility().addEffect(new CannibalizeEffect()); - this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController( - 2, 2, StaticFilters.FILTER_PERMANENT_CREATURE, false - )); + this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController(2)); } private Cannibalize(final Cannibalize card) { diff --git a/Mage.Sets/src/mage/cards/i/Incriminate.java b/Mage.Sets/src/mage/cards/i/Incriminate.java new file mode 100644 index 0000000000..c0a0a783b4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/Incriminate.java @@ -0,0 +1,101 @@ +package mage.cards.i; + +import mage.MageItem; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanentSameController; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class Incriminate extends CardImpl { + + public Incriminate(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}"); + + // Choose two target creatures controlled by the same player. That player sacrifices one of them. + this.getSpellAbility().addEffect(new IncriminateEffect()); + this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController(2)); + } + + private Incriminate(final Incriminate card) { + super(card); + } + + @Override + public Incriminate copy() { + return new Incriminate(this); + } +} + +class IncriminateEffect extends OneShotEffect { + + IncriminateEffect() { + super(Outcome.Benefit); + staticText = "choose two target creatures controlled by the same player. That player sacrifices one of them"; + } + + private IncriminateEffect(final IncriminateEffect effect) { + super(effect); + } + + @Override + public IncriminateEffect copy() { + return new IncriminateEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + List permanents = this + .getTargetPointer() + .getTargets(game, source) + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + Permanent permanent; + switch (permanents.size()) { + case 0: + return false; + case 1: + permanent = permanents.get(0); + break; + case 2: + Player player = game.getPlayer(permanents.get(0).getControllerId()); + if (player == null) { + return false; + } + FilterPermanent filter = new FilterPermanent("creature to sacrifice"); + filter.add(Predicates.or( + permanents + .stream() + .map(MageItem::getId) + .map(ControllerIdPredicate::new) + .collect(Collectors.toList()) + )); + TargetPermanent target = new TargetPermanent(filter); + target.setNotTarget(true); + player.choose(Outcome.Sacrifice, target, source, game); + permanent = game.getPermanent(target.getFirstTarget()); + default: + throw new UnsupportedOperationException("This shouldn't have happened"); + } + return permanent != null && permanent.sacrifice(source, game); + } +} diff --git a/Mage.Sets/src/mage/cards/s/SorrowsPath.java b/Mage.Sets/src/mage/cards/s/SorrowsPath.java index 29d8fc9ba7..7f6deeaffb 100644 --- a/Mage.Sets/src/mage/cards/s/SorrowsPath.java +++ b/Mage.Sets/src/mage/cards/s/SorrowsPath.java @@ -44,7 +44,7 @@ public final class SorrowsPath extends CardImpl { // {T}: Choose two target blocking creatures an opponent controls. If each of those creatures could block all creatures that the other is blocking, remove both of them from combat. Each one then blocks all creatures the other was blocking. Ability ability = new SimpleActivatedAbility(new SorrowsPathSwitchBlockersEffect(), new TapSourceCost()); - ability.addTarget(new TargetCreaturePermanentSameController(2, 2, filter, false)); + ability.addTarget(new TargetCreaturePermanentSameController(2, filter)); this.addAbility(ability); // Whenever Sorrow's Path becomes tapped, it deals 2 damage to you and each creature you control. diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index e3dfc9fa17..a115075ee6 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -45,6 +45,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Gala Greeters", 148, Rarity.RARE, mage.cards.g.GalaGreeters.class)); cards.add(new SetCardInfo("Getaway Car", 237, Rarity.RARE, mage.cards.g.GetawayCar.class)); cards.add(new SetCardInfo("Halo Fountain", 15, Rarity.MYTHIC, mage.cards.h.HaloFountain.class)); + cards.add(new SetCardInfo("Incriminate", 84, Rarity.COMMON, mage.cards.i.Incriminate.class)); cards.add(new SetCardInfo("Island", 264, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Jetmir's Garden", 250, Rarity.RARE, mage.cards.j.JetmirsGarden.class)); cards.add(new SetCardInfo("Jetmir, Nexus of Revels", 193, Rarity.MYTHIC, mage.cards.j.JetmirNexusOfRevels.class)); diff --git a/Mage/src/main/java/mage/target/common/TargetCreaturePermanentSameController.java b/Mage/src/main/java/mage/target/common/TargetCreaturePermanentSameController.java index 0bc13bb396..fcdb188028 100644 --- a/Mage/src/main/java/mage/target/common/TargetCreaturePermanentSameController.java +++ b/Mage/src/main/java/mage/target/common/TargetCreaturePermanentSameController.java @@ -1,20 +1,24 @@ - package mage.target.common; -import java.util.UUID; import mage.abilities.Ability; +import mage.filter.StaticFilters; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public class TargetCreaturePermanentSameController extends TargetCreaturePermanent { - public TargetCreaturePermanentSameController(int minNumTargets, int maxNumTargets, FilterCreaturePermanent filter, boolean notTarget) { - super(minNumTargets, maxNumTargets, filter, notTarget); + public TargetCreaturePermanentSameController(int numTargets) { + this(numTargets, StaticFilters.FILTER_PERMANENT_CREATURE); + } + + public TargetCreaturePermanentSameController(int numTargets, FilterCreaturePermanent filter) { + super(numTargets, numTargets, filter, false); } public TargetCreaturePermanentSameController(final TargetCreaturePermanentSameController target) {