From 867fa64156ff47736bf7fcd904b6a25a8d417b46 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Wed, 2 Nov 2022 20:22:49 -0500 Subject: [PATCH] [BRO] Implemented Gix's Command --- Mage.Sets/src/mage/cards/g/GixsCommand.java | 106 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + .../GreatestPowerControlledPredicate.java | 10 +- 3 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/g/GixsCommand.java diff --git a/Mage.Sets/src/mage/cards/g/GixsCommand.java b/Mage.Sets/src/mage/cards/g/GixsCommand.java new file mode 100644 index 00000000000..74fbb1b8191 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GixsCommand.java @@ -0,0 +1,106 @@ +package mage.cards.g; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyAllEffect; +import mage.abilities.effects.common.SacrificeOpponentsEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.keyword.LifelinkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.PowerPredicate; +import mage.filter.predicate.permanent.GreatestPowerControlledPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author weirddan455 + */ +public final class GixsCommand extends CardImpl { + + private static final FilterCreaturePermanent filter + = new FilterCreaturePermanent("each creature with power 2 or less"); + + private static final FilterCreaturePermanent filter2 + = new FilterCreaturePermanent("creature with the highest power among creatures they control"); + + static { + filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, 3)); + filter2.add(GreatestPowerControlledPredicate.instance); + } + + public GixsCommand(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); + + // Choose two -- + this.getSpellAbility().getModes().setMinModes(2); + this.getSpellAbility().getModes().setMaxModes(2); + + // * Put two +1/+1 counter on up to one creature. It gains lifelink until end of turn. + this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(2))); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(LifelinkAbility.getInstance()) + .setText("It gains lifelink until end of turn")); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1)); + + // * Destroy each creature with power 2 or less. + this.getSpellAbility().addMode(new Mode(new DestroyAllEffect(filter).setText("Destroy each creature with power 2 or less"))); + + // * Return up to two creature cards from your graveyard to your hand. + this.getSpellAbility().addMode(new Mode(new GixsCommandReturnEffect())); + + // * Each opponent sacrifices a creature with the highest power among creatures they control. + this.getSpellAbility().addMode(new Mode(new SacrificeOpponentsEffect(filter2))); + } + + private GixsCommand(final GixsCommand card) { + super(card); + } + + @Override + public GixsCommand copy() { + return new GixsCommand(this); + } +} + +class GixsCommandReturnEffect extends OneShotEffect { + + public GixsCommandReturnEffect() { + super(Outcome.ReturnToHand); + this.staticText = "Return up to two creature cards from your graveyard to your hand"; + } + + private GixsCommandReturnEffect(final GixsCommandReturnEffect effect) { + super(effect); + } + + @Override + public GixsCommandReturnEffect copy() { + return new GixsCommandReturnEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 2, StaticFilters.FILTER_CARD_CREATURES_YOUR_GRAVEYARD, true); + controller.chooseTarget(outcome, target, source, game); + return controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 296191b0c30..934819f6e60 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -64,6 +64,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Gaea's Courser", 181, Rarity.UNCOMMON, mage.cards.g.GaeasCourser.class)); cards.add(new SetCardInfo("Giant Growth", 183, Rarity.COMMON, mage.cards.g.GiantGrowth.class)); cards.add(new SetCardInfo("Gix's Caress", 96, Rarity.COMMON, mage.cards.g.GixsCaress.class)); + cards.add(new SetCardInfo("Gix's Command", 97, Rarity.RARE, mage.cards.g.GixsCommand.class)); cards.add(new SetCardInfo("Gixian Puppeteer", 99, Rarity.RARE, mage.cards.g.GixianPuppeteer.class)); cards.add(new SetCardInfo("Gnawing Vermin", 101, Rarity.UNCOMMON, mage.cards.g.GnawingVermin.class)); cards.add(new SetCardInfo("Go for the Throat", 102, Rarity.UNCOMMON, mage.cards.g.GoForTheThroat.class)); diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/GreatestPowerControlledPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/GreatestPowerControlledPredicate.java index e2a83ef107c..afa26ddbd37 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/GreatestPowerControlledPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/GreatestPowerControlledPredicate.java @@ -14,12 +14,10 @@ public enum GreatestPowerControlledPredicate implements ObjectSourcePlayerPredic @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent creatureWithGreatestPower = input.getObject(); - for (Permanent p : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, input.getObject().getControllerId(), game)) { - if (p.getPower().getValue() >= creatureWithGreatestPower.getPower().getValue()) { - creatureWithGreatestPower = p; - } + int greatestPower = Integer.MIN_VALUE; + for (Permanent p : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, input.getPlayerId(), input.getSource(), game)) { + greatestPower = Math.max(greatestPower, p.getPower().getValue()); } - return (creatureWithGreatestPower == input.getObject()); + return input.getObject().getPower().getValue() == greatestPower; } }