forked from External/mage
[OTJ] Implement Binding Negotiation
This commit is contained in:
parent
51d972e63f
commit
29f7fa0342
2 changed files with 107 additions and 0 deletions
106
Mage.Sets/src/mage/cards/b/BindingNegotiation.java
Normal file
106
Mage.Sets/src/mage/cards/b/BindingNegotiation.java
Normal file
|
|
@ -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<Card> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue