From 5b84462eff7aaa125e5f12ae561697d441698ea9 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Fri, 7 Aug 2020 14:05:44 -0500 Subject: [PATCH] - Added Chameleon Spirit --- .../src/mage/cards/c/ChameleonSpirit.java | 93 +++++++++++++++++++ Mage.Sets/src/mage/sets/MercadianMasques.java | 1 + 2 files changed, 94 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ChameleonSpirit.java diff --git a/Mage.Sets/src/mage/cards/c/ChameleonSpirit.java b/Mage.Sets/src/mage/cards/c/ChameleonSpirit.java new file mode 100644 index 0000000000..87c0285413 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ChameleonSpirit.java @@ -0,0 +1,93 @@ +package mage.cards.c; + +import static java.awt.SystemColor.control; +import java.util.UUID; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.ChooseColorEffect; +import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author jeffwadsworth + */ +public final class ChameleonSpirit extends CardImpl { + + public ChameleonSpirit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}"); + + this.subtype.add(SubType.ILLUSION); + this.subtype.add(SubType.SPIRIT); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // As Chameleon Spirit enters the battlefield, choose a color. + this.addAbility(new EntersBattlefieldAbility(new ChooseColorEffect(Outcome.Neutral))); + + // Chameleon Spirit's power and toughness are each equal to the number + // of permanents of the chosen color your opponents control. + this.addAbility(new SimpleStaticAbility( + new SetPowerToughnessSourceEffect( + PermanentsOfTheChosenColorOpponentsControlCount.instance, + Duration.EndOfGame))); + } + + private ChameleonSpirit(final ChameleonSpirit card) { + super(card); + } + + @Override + public ChameleonSpirit copy() { + return new ChameleonSpirit(this); + } +} + +enum PermanentsOfTheChosenColorOpponentsControlCount implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + int number = 0; + FilterPermanent filter = new FilterPermanent(); + filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(sourceAbility.getSourceId() + "_color"))); + for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) { + if (permanent != null + && game.getOpponents(sourceAbility.getControllerId()).contains(permanent.getControllerId()) + && filter.match(permanent, game)) { + number++; + } + } + return number; + } + + @Override + public PermanentsOfTheChosenColorOpponentsControlCount copy() { + return PermanentsOfTheChosenColorOpponentsControlCount.instance; + } + + @Override + public String toString() { + return "X"; + } + + @Override + public String getMessage() { + return "permanents of the chosen color your opponents control"; + } + +} diff --git a/Mage.Sets/src/mage/sets/MercadianMasques.java b/Mage.Sets/src/mage/sets/MercadianMasques.java index bdd6a8f209..58c6c737f6 100644 --- a/Mage.Sets/src/mage/sets/MercadianMasques.java +++ b/Mage.Sets/src/mage/sets/MercadianMasques.java @@ -67,6 +67,7 @@ public final class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("Cave Sense", 179, Rarity.COMMON, mage.cards.c.CaveSense.class)); cards.add(new SetCardInfo("Ceremonial Guard", 182, Rarity.COMMON, mage.cards.c.CeremonialGuard.class)); cards.add(new SetCardInfo("Chambered Nautilus", 64, Rarity.UNCOMMON, mage.cards.c.ChamberedNautilus.class)); + cards.add(new SetCardInfo("Chameleon Spirit", 65, Rarity.UNCOMMON, mage.cards.c.ChameleonSpirit.class)); cards.add(new SetCardInfo("Charisma", 66, Rarity.RARE, mage.cards.c.Charisma.class)); cards.add(new SetCardInfo("Charm Peddler", 6, Rarity.COMMON, mage.cards.c.CharmPeddler.class)); cards.add(new SetCardInfo("Charmed Griffin", 7, Rarity.UNCOMMON, mage.cards.c.CharmedGriffin.class));