From fac6f583886c9b44f57f06e78e8f1289aa65ea0f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 3 Apr 2019 20:48:02 -0400 Subject: [PATCH] Implemented Sorin, Vengeful Bloodlord --- .../mage/cards/s/SorinVengefulBloodlord.java | 142 ++++++++++++++++++ Mage.Sets/src/mage/sets/WarOfTheSpark.java | 1 + 2 files changed, 143 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SorinVengefulBloodlord.java diff --git a/Mage.Sets/src/mage/cards/s/SorinVengefulBloodlord.java b/Mage.Sets/src/mage/cards/s/SorinVengefulBloodlord.java new file mode 100644 index 0000000000..922afbf6eb --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SorinVengefulBloodlord.java @@ -0,0 +1,142 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.MyTurnCondition; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.PayVariableLoyaltyCost; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.LifelinkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.common.TargetPlayerOrPlaneswalker; +import mage.target.targetadjustment.TargetAdjuster; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SorinVengefulBloodlord extends CardImpl { + + public SorinVengefulBloodlord(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{W}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.SORIN); + this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(4)); + + // As long as it's your turn, creatures and planeswalkers you control have lifelink. + this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect( + new GainAbilityControlledEffect( + LifelinkAbility.getInstance(), Duration.WhileOnBattlefield, + StaticFilters.FILTER_PERMANENT_CREATURE_OR_PLANESWALKER_A + ), MyTurnCondition.instance, "As long as it's your turn, " + + "creatures and planeswalkers you control have lifelink." + ))); + + // +2: Sorin, Vengeful Bloodlord deals 1 damage to target player or planeswalker. + Ability ability = new LoyaltyAbility(new DamageTargetEffect(1), 2); + ability.addTarget(new TargetPlayerOrPlaneswalker()); + this.addAbility(ability); + + // -X: Return target creature card with converted mana cost X from your graveyard to the battlefield. That creature is a vampire in addition to its other types. + ability = new LoyaltyAbility(new ReturnFromGraveyardToBattlefieldTargetEffect().setText( + "Return target creature card with converted mana cost X from your graveyard to the battlefield." + )); + ability.addEffect(new SorinVengefulBloodlordEffect()); + ability.setTargetAdjuster(SorinVengefulBloodlordAdjuster.instance); + this.addAbility(ability); + } + + private SorinVengefulBloodlord(final SorinVengefulBloodlord card) { + super(card); + } + + @Override + public SorinVengefulBloodlord copy() { + return new SorinVengefulBloodlord(this); + } +} + +enum SorinVengefulBloodlordAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + int xValue = 0; + for (Cost cost : ability.getCosts()) { + if (cost instanceof PayVariableLoyaltyCost) { + xValue = ((PayVariableLoyaltyCost) cost).getAmount(); + } + } + FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less"); + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1)); + ability.getTargets().clear(); + ability.addTarget(new TargetCardInYourGraveyard(filter)); + } +} + +class SorinVengefulBloodlordEffect extends ContinuousEffectImpl { + SorinVengefulBloodlordEffect() { + super(Duration.Custom, Outcome.Neutral); + staticText = "That creature is a vampire in addition to its other types."; + } + + private SorinVengefulBloodlordEffect(final SorinVengefulBloodlordEffect effect) { + super(effect); + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.TypeChangingEffects_4; + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Permanent creature; + if (source.getTargets().getFirstTarget() == null) { + creature = game.getPermanent(getTargetPointer().getFirst(game, source)); + } else { + creature = game.getPermanent(source.getTargets().getFirstTarget()); + if (creature == null) { + creature = game.getPermanentEntering(source.getTargets().getFirstTarget()); + } + } + if (creature != null) { + if (sublayer == SubLayer.NA) { + if (!creature.hasSubtype(SubType.VAMPIRE, game)) { + creature.getSubtype(game).add(SubType.VAMPIRE); + } + } + return true; + } else { + this.used = true; + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public SorinVengefulBloodlordEffect copy() { + return new SorinVengefulBloodlordEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/WarOfTheSpark.java b/Mage.Sets/src/mage/sets/WarOfTheSpark.java index bb4243aa80..36a15475fe 100644 --- a/Mage.Sets/src/mage/sets/WarOfTheSpark.java +++ b/Mage.Sets/src/mage/sets/WarOfTheSpark.java @@ -89,6 +89,7 @@ public final class WarOfTheSpark extends ExpansionSet { cards.add(new SetCardInfo("Samut's Sprint", 142, Rarity.COMMON, mage.cards.s.SamutsSprint.class)); cards.add(new SetCardInfo("Samut, Tyrant Smasher", 235, Rarity.UNCOMMON, mage.cards.s.SamutTyrantSmasher.class)); cards.add(new SetCardInfo("Sorin's Thirst", 104, Rarity.COMMON, mage.cards.s.SorinsThirst.class)); + cards.add(new SetCardInfo("Sorin, Vengeful Bloodlord", 217, Rarity.RARE, mage.cards.s.SorinVengefulBloodlord.class)); cards.add(new SetCardInfo("Swamp", 256, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Swamp", 258, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Teferi, Time Raveler", 221, Rarity.RARE, mage.cards.t.TeferiTimeRaveler.class));