Implemented Valiant Changeling

This commit is contained in:
Evan Kranzler 2019-05-27 20:29:58 -04:00
parent 31f9d698d7
commit 6b200e00e7
2 changed files with 102 additions and 0 deletions

View file

@ -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<SubType> 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);
}
}

View file

@ -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));