From 6b200e00e710630dc94ec82725142b1e60b00ef5 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 27 May 2019 20:29:58 -0400 Subject: [PATCH] Implemented Valiant Changeling --- .../src/mage/cards/v/ValiantChangeling.java | 101 ++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons.java | 1 + 2 files changed, 102 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/ValiantChangeling.java diff --git a/Mage.Sets/src/mage/cards/v/ValiantChangeling.java b/Mage.Sets/src/mage/cards/v/ValiantChangeling.java new file mode 100644 index 0000000000..6a4d65c150 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/ValiantChangeling.java @@ -0,0 +1,101 @@ +package mage.cards.v; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.keyword.ChangelingAbility; +import mage.abilities.keyword.DoubleStrikeAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ValiantChangeling extends CardImpl { + + public ValiantChangeling(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}"); + + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // This spell costs {1} less to cast for each creature type among creatures you control. This effect can't reduce the amount of mana this spell costs by more than {5}. + this.addAbility(new SimpleStaticAbility(Zone.ALL, new ValiantChangelingCostReductionEffect())); + + // Changeling + this.addAbility(ChangelingAbility.getInstance()); + + // Double strike + this.addAbility(DoubleStrikeAbility.getInstance()); + } + + private ValiantChangeling(final ValiantChangeling card) { + super(card); + } + + @Override + public ValiantChangeling copy() { + return new ValiantChangeling(this); + } +} + +class ValiantChangelingCostReductionEffect extends CostModificationEffectImpl { + + ValiantChangelingCostReductionEffect() { + super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "This spell costs {1} less to cast for each creature type among creatures you control. " + + "This effect can't reduce the amount of mana this spell costs by more than {5}."; + } + + private ValiantChangelingCostReductionEffect(ValiantChangelingCostReductionEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + Set subTypes = new HashSet(); + int reductionAmount = 0; + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game + )) { + if (permanent.getAbilities().contains(ChangelingAbility.getInstance()) + || permanent.isAllCreatureTypes()) { + reductionAmount = 5; + break; + } + subTypes.addAll(permanent.getSubtype(game)); + reductionAmount = subTypes.size(); + if (reductionAmount > 4) { + break; + } + } + CardUtil.reduceCost(abilityToModify, Math.max(reductionAmount, 5)); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if ((abilityToModify instanceof SpellAbility) + && abilityToModify.getSourceId().equals(source.getSourceId())) { + return game.getCard(abilityToModify.getSourceId()) != null; + } + return false; + } + + @Override + public ValiantChangelingCostReductionEffect copy() { + return new ValiantChangelingCostReductionEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons.java b/Mage.Sets/src/mage/sets/ModernHorizons.java index 84cb937ecb..cf46108ba4 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons.java @@ -146,6 +146,7 @@ public final class ModernHorizons extends ExpansionSet { cards.add(new SetCardInfo("Umezawa's Charm", 111, Rarity.COMMON, mage.cards.u.UmezawasCharm.class)); cards.add(new SetCardInfo("Undead Augur", 112, Rarity.UNCOMMON, mage.cards.u.UndeadAugur.class)); cards.add(new SetCardInfo("Urza, Lord High Artificer", 75, Rarity.MYTHIC, mage.cards.u.UrzaLordHighArtificer.class)); + cards.add(new SetCardInfo("Valiant Changeling", 34, Rarity.UNCOMMON, mage.cards.v.ValiantChangeling.class)); cards.add(new SetCardInfo("Venomous Changeling", 114, Rarity.COMMON, mage.cards.v.VenomousChangeling.class)); cards.add(new SetCardInfo("Wall of One Thousand Cuts", 36, Rarity.COMMON, mage.cards.w.WallOfOneThousandCuts.class)); cards.add(new SetCardInfo("Waterlogged Grove", 249, Rarity.RARE, mage.cards.w.WaterloggedGrove.class));