From 9531a79eb228fded554f808fea731c9650189870 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 3 Nov 2020 08:22:47 -0500 Subject: [PATCH] [CMR] Implemented Commander's Plate --- .../src/mage/cards/c/CommandersPlate.java | 150 ++++++++++++++++++ Mage.Sets/src/mage/sets/CommanderLegends.java | 1 + Utils/mtg-cards-data.txt | 2 +- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/c/CommandersPlate.java diff --git a/Mage.Sets/src/mage/cards/c/CommandersPlate.java b/Mage.Sets/src/mage/cards/c/CommandersPlate.java new file mode 100644 index 0000000000..de2ede5519 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CommandersPlate.java @@ -0,0 +1,150 @@ +package mage.cards.c; + +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.keyword.EquipAbility; +import mage.abilities.keyword.ProtectionAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterMana; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.CommanderPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.targetpointer.FixedTarget; + +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CommandersPlate extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledCreaturePermanent("commander"); + + static { + filter.add(CommanderPredicate.instance); + } + + public CommandersPlate(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + + this.subtype.add(SubType.EQUIPMENT); + + // Equipped creature gets +3/+3 and has protection from each color that's not in your commander's color identity. + Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(3, 3)); + ability.addEffect(new CommandersPlateEffect()); + this.addAbility(ability); + + // Equip commander {3} + this.addAbility(new EquipAbility( + Outcome.AddAbility, new GenericManaCost(3), new TargetPermanent(filter) + )); + + // Equip {5} + this.addAbility(new EquipAbility(5)); + } + + private CommandersPlate(final CommandersPlate card) { + super(card); + } + + @Override + public CommandersPlate copy() { + return new CommandersPlate(this); + } +} + +class CommandersPlateEffect extends ContinuousEffectImpl { + + CommandersPlateEffect() { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + this.staticText = "has protection from each color that's not in your commander's color identity"; + this.generateGainAbilityDependencies(ProtectionAbility.from(new ObjectColor("WUBRG")), null); + this.concatBy("and"); + } + + private CommandersPlateEffect(final CommandersPlateEffect effect) { + super(effect); + } + + @Override + public CommandersPlateEffect copy() { + return new CommandersPlateEffect(this); + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); + if (!affectedObjectsSet) { + return; + } + Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (equipment == null || equipment.getAttachedTo() == null) { + return; + } + this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game)); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Permanent permanent = null; + if (affectedObjectsSet) { + permanent = game.getPermanent(targetPointer.getFirst(game, source)); + if (permanent == null) { + discard(); + return true; + } + } else { + Permanent equipment = game.getPermanent(source.getSourceId()); + if (equipment != null && equipment.getAttachedTo() != null) { + permanent = game.getPermanentOrLKIBattlefield(equipment.getAttachedTo()); + } + } + Set commanders = game.getCommandersIds(player); + if (commanders.isEmpty()) { + return false; + } + ObjectColor color = new ObjectColor("WUBRG"); + for (UUID commanderId : commanders) { + Card card = game.getCard(commanderId); + if (card == null) { + continue; + } + FilterMana identity = card.getColorIdentity(); + if (identity.isWhite()) { + color.setWhite(false); + } + if (identity.isBlue()) { + color.setBlue(false); + } + if (identity.isBlack()) { + color.setBlack(false); + } + if (identity.isRed()) { + color.setRed(false); + } + if (identity.isGreen()) { + color.setGreen(false); + } + } + if (permanent != null) { + permanent.addAbility(ProtectionAbility.from(color), source.getSourceId(), game); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 3599981aad..36ad7a66c5 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -64,6 +64,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Colfenor, the Last Yew", 274, Rarity.RARE, mage.cards.c.ColfenorTheLastYew.class)); cards.add(new SetCardInfo("Command Beacon", 349, Rarity.RARE, mage.cards.c.CommandBeacon.class)); cards.add(new SetCardInfo("Command Tower", 350, Rarity.COMMON, mage.cards.c.CommandTower.class)); + cards.add(new SetCardInfo("Commander's Plate", 692, Rarity.MYTHIC, mage.cards.c.CommandersPlate.class)); cards.add(new SetCardInfo("Commander's Sphere", 306, Rarity.COMMON, mage.cards.c.CommandersSphere.class)); cards.add(new SetCardInfo("Confiscate", 62, Rarity.UNCOMMON, mage.cards.c.Confiscate.class)); cards.add(new SetCardInfo("Court Street Denizen", 17, Rarity.COMMON, mage.cards.c.CourtStreetDenizen.class)); diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index b210fa1bb2..63bc93c567 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -39525,5 +39525,5 @@ Ramos, Dragon Engine|Commander Legends|545|M|{6}|Legendary Artifact Creature - D Ich-Tekik, Salvage Splicer|Commander Legends|580|U|{4}{G}|Legendary Creature - Human Artificer|1|1|When Ich-Tekik, Salvage Splicer enters the battlefield, create a 3/3 colorless Golem artifact creature token.$Whenever an artifact is put into a graveyard from the battlefield, put a +1/+1 counter on Ich-Tekik and a +1/+1 counter on each Golem you control.$Partner| Armored Skyhunter|Commander Legends|617|R|{3}{W}|Creature - Cat Knight|3|3|Flying$Whenever Armored Skyhunter attacks, look at the top six cards of your library. You may put an Aura or Equipment card from among them onto the battlefield. If an Equipment is put onto the battlefield this way, you may attach it to a creature you control. Put the rest of those cards on the bottom of your library in a random order.| Reshape the Earth|Commander Legends|683|M|{6}{G}{G}{G}|Sorcery|||Search your library for up to ten land cards, put them onto the battlefield tapped, then shuffle your library.| -Commander's Plate|Commander Legends|692|C|{1}|Artifact - Equipment|||Equipped creature gets +3/+3 and has protection from each color that's not in your commander's color identity.$Equip commaner {3}$Equip {5}| +Commander's Plate|Commander Legends|692|M|{1}|Artifact - Equipment|||Equipped creature gets +3/+3 and has protection from each color that's not in your commander's color identity.$Equip commaner {3}$Equip {5}| Mana Confluence|Commander Legends|721|M||Land|||{T}, Pay 1 life: Add one mana of any color.|