mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
Implemented Decoy Gambit
This commit is contained in:
parent
4b940fb2fe
commit
7b68d855a4
2 changed files with 114 additions and 0 deletions
113
Mage.Sets/src/mage/cards/d/DecoyGambit.java
Normal file
113
Mage.Sets/src/mage/cards/d/DecoyGambit.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
package mage.cards.d;
|
||||
|
||||
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.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class DecoyGambit extends CardImpl {
|
||||
|
||||
public DecoyGambit(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
|
||||
|
||||
// For each opponent, choose up to one target creature that player controls, then return that creature to its owner's hand unless its controller has you draw a card.
|
||||
this.getSpellAbility().addEffect(new DecoyGambitEffect());
|
||||
this.getSpellAbility().setTargetAdjuster(DecoyGambitAdjuster.instance);
|
||||
}
|
||||
|
||||
private DecoyGambit(final DecoyGambit card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoyGambit copy() {
|
||||
return new DecoyGambit(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum DecoyGambitAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
ability.getTargets().clear();
|
||||
game.getOpponents(ability.getControllerId())
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.forEachOrdered(player -> {
|
||||
FilterPermanent filter = new FilterCreaturePermanent(
|
||||
"creature controlled by " + player.getName()
|
||||
);
|
||||
filter.add(new ControllerIdPredicate(player.getId()));
|
||||
ability.addTarget(new TargetPermanent(0, 1, filter, false));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class DecoyGambitEffect extends OneShotEffect {
|
||||
|
||||
DecoyGambitEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "For each opponent, choose up to one target creature that player controls, " +
|
||||
"then return that creature to its owner's hand unless its controller has you draw a card.";
|
||||
}
|
||||
|
||||
private DecoyGambitEffect(final DecoyGambitEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoyGambitEffect copy() {
|
||||
return new DecoyGambitEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
List<Permanent> permanents = source
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
for (Permanent permanent : permanents) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
if (player.chooseUse(outcome, "Have " + controller.getName() + " draw a card? If you don't, " +
|
||||
permanent.getName() + " will be returned to its owner's hand.", source, game)
|
||||
&& controller.drawCards(1, source.getSourceId(), game) > 0) {
|
||||
player.moveCards(permanent, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -101,6 +101,7 @@ public final class Commander2020Edition extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Deadly Tempest", 131, Rarity.RARE, mage.cards.d.DeadlyTempest.class));
|
||||
cards.add(new SetCardInfo("Dearly Departed", 84, Rarity.RARE, mage.cards.d.DearlyDeparted.class));
|
||||
cards.add(new SetCardInfo("Deathsprout", 208, Rarity.UNCOMMON, mage.cards.d.Deathsprout.class));
|
||||
cards.add(new SetCardInfo("Decoy Gambit", 32, Rarity.RARE, mage.cards.d.DecoyGambit.class));
|
||||
cards.add(new SetCardInfo("Decree of Justice", 85, Rarity.RARE, mage.cards.d.DecreeOfJustice.class));
|
||||
cards.add(new SetCardInfo("Deflecting Swat", 50, Rarity.RARE, mage.cards.d.DeflectingSwat.class));
|
||||
cards.add(new SetCardInfo("Descend upon the Sinful", 86, Rarity.MYTHIC, mage.cards.d.DescendUponTheSinful.class));
|
||||
|
|
Loading…
Reference in a new issue