diff --git a/Mage.Sets/src/mage/cards/r/RowanScionOfWar.java b/Mage.Sets/src/mage/cards/r/RowanScionOfWar.java new file mode 100644 index 00000000000..880baa8e242 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RowanScionOfWar.java @@ -0,0 +1,93 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.dynamicvalue.common.ControllerLostLifeCount; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.keyword.MenaceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.util.CardUtil; +import mage.watchers.common.PlayerLostLifeWatcher; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class RowanScionOfWar extends CardImpl { + + public RowanScionOfWar(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{R}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(4); + this.toughness = new MageInt(2); + + // Menace + this.addAbility(new MenaceAbility(false)); + + // {T}: Spells you cast this turn that are black and/or red cost {X} less to cast, where X is the amount of life you lost this turn. Activate only as a sorcery. + this.addAbility( + new ActivateAsSorceryActivatedAbility( + new RowanScionOfWarEffect(), + new TapSourceCost() + ).addHint(ControllerLostLifeCount.getHint()), + new PlayerLostLifeWatcher() + ); + + } + + private RowanScionOfWar(final RowanScionOfWar card) { + super(card); + } + + @Override + public RowanScionOfWar copy() { + return new RowanScionOfWar(this); + } +} + +class RowanScionOfWarEffect extends CostModificationEffectImpl { + + RowanScionOfWarEffect() { + super(Duration.EndOfTurn, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "Spells you cast this turn that are black and/or red cost {X} less to cast, where X is the amount of life you lost this turn."; + } + + private RowanScionOfWarEffect(final RowanScionOfWarEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + CardUtil.reduceCost(abilityToModify, Math.max(0, ControllerLostLifeCount.instance.calculate(game, source, this))); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (!(abilityToModify instanceof SpellAbility)) { + return false; + } + SpellAbility spell = (SpellAbility) abilityToModify; + ObjectColor color = spell.getCharacteristics(game).getColor(game); + + return spell.isControlledBy(source.getControllerId()) + && game.getCard(spell.getSourceId()) != null + && (color.isRed() || color.isBlack()); + } + + @Override + public RowanScionOfWarEffect copy() { + return new RowanScionOfWarEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/WildsOfEldraine.java b/Mage.Sets/src/mage/sets/WildsOfEldraine.java index d33cd73324f..e836b940e22 100644 --- a/Mage.Sets/src/mage/sets/WildsOfEldraine.java +++ b/Mage.Sets/src/mage/sets/WildsOfEldraine.java @@ -76,6 +76,7 @@ public final class WildsOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Restless Spire", 306, Rarity.RARE, mage.cards.r.RestlessSpire.class)); cards.add(new SetCardInfo("Return from the Wilds", 181, Rarity.COMMON, mage.cards.r.ReturnFromTheWilds.class)); cards.add(new SetCardInfo("Rootrider Faun", 182, Rarity.COMMON, mage.cards.r.RootriderFaun.class)); + cards.add(new SetCardInfo("Rowan, Scion of War", 211, Rarity.MYTHIC, mage.cards.r.RowanScionOfWar.class)); cards.add(new SetCardInfo("Rowan's Grim Search", 104, Rarity.COMMON, mage.cards.r.RowansGrimSearch.class)); cards.add(new SetCardInfo("Ruby, Daring Tracker", 212, Rarity.UNCOMMON, mage.cards.r.RubyDaringTracker.class)); cards.add(new SetCardInfo("Scalding Viper", 235, Rarity.RARE, mage.cards.s.ScaldingViper.class)); diff --git a/Mage/src/main/java/mage/abilities/SpellAbility.java b/Mage/src/main/java/mage/abilities/SpellAbility.java index ee00ffa2143..dd557c87e18 100644 --- a/Mage/src/main/java/mage/abilities/SpellAbility.java +++ b/Mage/src/main/java/mage/abilities/SpellAbility.java @@ -286,7 +286,7 @@ public class SpellAbility extends ActivatedAbilityImpl { } /** - * Returns a card object with the spell characteristics like calor, types, + * Returns a card object with the spell characteristics like color, types, * subtypes etc. E.g. if you cast a Bestow card as enchantment, the * characteristics don't include the creature type. * diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerLostLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerLostLifeCount.java new file mode 100644 index 00000000000..d65ba7172be --- /dev/null +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerLostLifeCount.java @@ -0,0 +1,48 @@ +package mage.abilities.dynamicvalue.common; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.game.Game; +import mage.watchers.common.PlayerLostLifeWatcher; + +/** + * Amount of life the controller lost this turn. + * + * @author Susucr + */ +public enum ControllerLostLifeCount implements DynamicValue { + instance; + + private static final Hint hint = new ValueHint("Life lost this turn", instance); + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); + if (watcher != null) { + return watcher.getLifeLost(sourceAbility.getControllerId()); + } + return 0; + } + + @Override + public ControllerLostLifeCount copy() { + return instance; + } + + @Override + public String toString() { + return "X"; + } + + @Override + public String getMessage() { + return "the amount of life you lost this turn"; + } + + public static Hint getHint() { + return hint; + } +}