From 29f7fa0342ef9fc6355ab6c4580b3fa1fb41e3d7 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:32:39 +0200 Subject: [PATCH] [OTJ] Implement Binding Negotiation --- .../src/mage/cards/b/BindingNegotiation.java | 106 ++++++++++++++++++ .../mage/sets/OutlawsOfThunderJunction.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BindingNegotiation.java diff --git a/Mage.Sets/src/mage/cards/b/BindingNegotiation.java b/Mage.Sets/src/mage/cards/b/BindingNegotiation.java new file mode 100644 index 00000000000..6f5ac383246 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BindingNegotiation.java @@ -0,0 +1,106 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterNonlandCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.card.FaceDownPredicate; +import mage.filter.predicate.card.OwnerIdPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; +import mage.target.common.TargetOpponent; + +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author Susucr + */ +public final class BindingNegotiation extends CardImpl { + + public BindingNegotiation(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}"); + + // Target opponent reveals their hand. You may choose a nonland card from it. If you do, they discard it. Otherwise, you may put a face-up exiled card they own into their graveyard. + this.getSpellAbility().addEffect(new BindingNegotiationEffect()); + this.getSpellAbility().addTarget(new TargetOpponent()); + } + + private BindingNegotiation(final BindingNegotiation card) { + super(card); + } + + @Override + public BindingNegotiation copy() { + return new BindingNegotiation(this); + } +} + +class BindingNegotiationEffect extends OneShotEffect { + + BindingNegotiationEffect() { + super(Outcome.Discard); + staticText = "Target opponent reveals their hand. You may choose a nonland card from it. " + + "If you do, they discard it. Otherwise, you may put a face-up exiled card they own into their graveyard"; + } + + private BindingNegotiationEffect(final BindingNegotiationEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + Player controller = game.getPlayer(source.getControllerId()); + if (player == null || controller == null) { + return false; + } + // Target opponent reveals their hand + Cards revealedCards = new CardsImpl(); + revealedCards.addAll(player.getHand()); + player.revealCards(source, revealedCards, game); + + // You may choose a nonland card from it. + TargetCard target = new TargetCard(0, 1, Zone.HAND, new FilterNonlandCard()); + controller.choose(outcome, revealedCards, target, source, game); + + UUID chosenId = target.getFirstTarget(); + if (chosenId != null) { + // If you do, they discard it. + Card card = revealedCards.get(target.getFirstTarget(), game); + player.discard(card, false, source, game); + } else { + // Otherwise, you may put a face-up exiled card they own into their graveyard. + FilterCard filter = new FilterCard("face-up exiled card owned by " + player.getName()); + filter.add(Predicates.not(FaceDownPredicate.instance)); + filter.add(new OwnerIdPredicate(player.getId())); + TargetCard targetExiled = new TargetCardInExile(0, 1, filter, null); + controller.choose(outcome, targetExiled, source, game); + Set chosenExiledCard = targetExiled + .getTargets() + .stream() + .map(game::getCard) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + if (!chosenExiledCard.isEmpty()) { + player.moveCards(chosenExiledCard, Zone.GRAVEYARD, source, game); + } + } + return true; + } + + @Override + public BindingNegotiationEffect copy() { + return new BindingNegotiationEffect(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java index 605eb406d30..48d059f8d0b 100644 --- a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java +++ b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java @@ -39,6 +39,7 @@ public final class OutlawsOfThunderJunction extends ExpansionSet { cards.add(new SetCardInfo("Baron Bertram Graywater", 195, Rarity.UNCOMMON, mage.cards.b.BaronBertramGraywater.class)); cards.add(new SetCardInfo("Beastbond Outcaster", 154, Rarity.UNCOMMON, mage.cards.b.BeastbondOutcaster.class)); cards.add(new SetCardInfo("Betrayal at the Vault", 155, Rarity.UNCOMMON, mage.cards.b.BetrayalAtTheVault.class)); + cards.add(new SetCardInfo("Binding Negotiation", 78, Rarity.UNCOMMON, mage.cards.b.BindingNegotiation.class)); cards.add(new SetCardInfo("Blacksnag Buzzard", 79, Rarity.COMMON, mage.cards.b.BlacksnagBuzzard.class)); cards.add(new SetCardInfo("Blood Hustler", 80, Rarity.UNCOMMON, mage.cards.b.BloodHustler.class)); cards.add(new SetCardInfo("Blooming Marsh", 266, Rarity.RARE, mage.cards.b.BloomingMarsh.class));