From b8feae7f3abc1779aa3c496967faba66cd6fb2b4 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 8 Nov 2020 17:45:33 -0500 Subject: [PATCH] [CMR] Implemented Liesa, Shroud of Dusk --- .../src/mage/game/OathbreakerFreeForAll.java | 2 +- .../src/mage/cards/l/LiesaShroudOfDusk.java | 74 +++++++++++++++++++ Mage.Sets/src/mage/sets/CommanderLegends.java | 1 + .../cost/CommanderCostModification.java | 25 +++---- Mage/src/main/java/mage/cards/Card.java | 11 +++ .../java/mage/game/GameCommanderImpl.java | 2 +- .../java/mage/game/GameTinyLeadersImpl.java | 2 +- 7 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/l/LiesaShroudOfDusk.java diff --git a/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java b/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java index 9c517d0361..65ac49e5b8 100644 --- a/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java +++ b/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java @@ -60,7 +60,7 @@ public class OathbreakerFreeForAll extends GameCommanderImpl { // basic commmander restrict (oathbreaker may ask to move, signature force to move) commanderAbility.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, isSignatureSpell, getCommanderTypeName(commander))); - commanderAbility.addEffect(new CommanderCostModification(commander.getId())); + commanderAbility.addEffect(new CommanderCostModification(commander)); // signature spell restrict (spell can be casted on player's commander on battlefield) if (isSignatureSpell) { diff --git a/Mage.Sets/src/mage/cards/l/LiesaShroudOfDusk.java b/Mage.Sets/src/mage/cards/l/LiesaShroudOfDusk.java new file mode 100644 index 0000000000..b5074668a5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LiesaShroudOfDusk.java @@ -0,0 +1,74 @@ +package mage.cards.l; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.SpellCastAllTriggeredAbility; +import mage.abilities.costs.common.PayLifeCost; +import mage.abilities.effects.common.InfoEffect; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.LifelinkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SetTargetPointer; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.watchers.common.CommanderPlaysCountWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class LiesaShroudOfDusk extends CardImpl { + + public LiesaShroudOfDusk(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ANGEL); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Rather than pay {2} for each previous time you've cast this spell from the command zone this game, pay 2 life that many times. + this.addAbility(new SimpleStaticAbility(new InfoEffect( + "Rather than pay {2} for each previous time you've cast this spell " + + "from the command zone this game, pay 2 life that many times." + ))); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Lifelink + this.addAbility(LifelinkAbility.getInstance()); + + // Whenever a player casts a spell, they lose 2 life. + this.addAbility(new SpellCastAllTriggeredAbility( + new LoseLifeTargetEffect(2).setText("they lose 2 life"), + StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.PLAYER + )); + } + + private LiesaShroudOfDusk(final LiesaShroudOfDusk card) { + super(card); + } + + @Override + public LiesaShroudOfDusk copy() { + return new LiesaShroudOfDusk(this); + } + + @Override + public boolean commanderCost(Game game, Ability source, Ability abilityToModify) { + CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class); + int castCount = watcher.getPlaysCount(getId()); + if (castCount > 0) { + abilityToModify.addCost(new PayLifeCost(2 * castCount)); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 88ccc5114c..95a0dc53f2 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -269,6 +269,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Kydele, Chosen of Kruphix", 524, Rarity.MYTHIC, mage.cards.k.KydeleChosenOfKruphix.class)); cards.add(new SetCardInfo("Laboratory Drudge", 78, Rarity.RARE, mage.cards.l.LaboratoryDrudge.class)); cards.add(new SetCardInfo("Lathiel, the Bounteous Dawn", 285, Rarity.RARE, mage.cards.l.LathielTheBounteousDawn.class)); + cards.add(new SetCardInfo("Liesa, Shroud of Dusk", 286, Rarity.RARE, mage.cards.l.LiesaShroudOfDusk.class)); cards.add(new SetCardInfo("Lifecrafter's Gift", 240, Rarity.COMMON, mage.cards.l.LifecraftersGift.class)); cards.add(new SetCardInfo("Lightning-Rig Crew", 190, Rarity.UNCOMMON, mage.cards.l.LightningRigCrew.class)); cards.add(new SetCardInfo("Livio, Oathsworn Sentinel", 31, Rarity.RARE, mage.cards.l.LivioOathswornSentinel.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/CommanderCostModification.java b/Mage/src/main/java/mage/abilities/effects/common/cost/CommanderCostModification.java index 7e6f87daf2..046e513ab7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/CommanderCostModification.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/CommanderCostModification.java @@ -3,14 +3,11 @@ package mage.abilities.effects.common.cost; import mage.abilities.Ability; import mage.abilities.common.CastCommanderAbility; import mage.abilities.common.PlayLandAsCommanderAbility; +import mage.cards.Card; import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; import mage.game.Game; -import mage.util.ManaUtil; -import mage.watchers.common.CommanderPlaysCountWatcher; - -import java.util.UUID; /** * @author Plopman @@ -25,32 +22,28 @@ import java.util.UUID; public class CommanderCostModification extends CostModificationEffectImpl { - private final UUID commanderId; + private final Card commander; - public CommanderCostModification(UUID commanderId) { + public CommanderCostModification(Card commander) { super(Duration.Custom, Outcome.Neutral, CostModificationType.INCREASE_COST); - this.commanderId = commanderId; + this.commander = commander; } public CommanderCostModification(final CommanderCostModification effect) { super(effect); - this.commanderId = effect.commanderId; + this.commander = effect.commander; } @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { - CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class); - int castCount = watcher.getPlaysCount(commanderId); - if (castCount > 0) { - abilityToModify.getManaCostsToPay().add(ManaUtil.createManaCost(2 * castCount, false)); - } - return true; + return commander.commanderCost(game, source, abilityToModify); } @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - return commanderId.equals(abilityToModify.getSourceId()) - && (abilityToModify instanceof CastCommanderAbility || abilityToModify instanceof PlayLandAsCommanderAbility); + return commander.getId().equals(abilityToModify.getSourceId()) + && (abilityToModify instanceof CastCommanderAbility + || abilityToModify instanceof PlayLandAsCommanderAbility); } @Override diff --git a/Mage/src/main/java/mage/cards/Card.java b/Mage/src/main/java/mage/cards/Card.java index e49bf7072f..48d10c385e 100644 --- a/Mage/src/main/java/mage/cards/Card.java +++ b/Mage/src/main/java/mage/cards/Card.java @@ -13,6 +13,8 @@ import mage.filter.FilterMana; import mage.game.Game; import mage.game.GameState; import mage.game.permanent.Permanent; +import mage.util.ManaUtil; +import mage.watchers.common.CommanderPlaysCountWatcher; import java.util.List; import java.util.UUID; @@ -180,4 +182,13 @@ public interface Card extends MageObject { default boolean isOwnedBy(UUID controllerId) { return getOwnerId().equals(controllerId); } + + default boolean commanderCost(Game game, Ability source, Ability abilityToModify) { + CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class); + int castCount = watcher.getPlaysCount(getId()); + if (castCount > 0) { + abilityToModify.getManaCostsToPay().add(ManaUtil.createManaCost(2 * castCount, false)); + } + return true; + } } diff --git a/Mage/src/main/java/mage/game/GameCommanderImpl.java b/Mage/src/main/java/mage/game/GameCommanderImpl.java index ade44a7727..c8263fbb12 100644 --- a/Mage/src/main/java/mage/game/GameCommanderImpl.java +++ b/Mage/src/main/java/mage/game/GameCommanderImpl.java @@ -103,7 +103,7 @@ public abstract class GameCommanderImpl extends GameImpl { public void initCommanderEffects(Card commander, Player player, Ability commanderAbility) { // all commander effects must be independent from sourceId or controllerId commanderAbility.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander")); - commanderAbility.addEffect(new CommanderCostModification(commander.getId())); + commanderAbility.addEffect(new CommanderCostModification(commander)); } //20130711 diff --git a/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java b/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java index 97bccb6b1a..467fdf3d23 100644 --- a/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java +++ b/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java @@ -59,7 +59,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl { commander.moveToZone(Zone.COMMAND, null, this, true); Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects")); ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander")); - ability.addEffect(new CommanderCostModification(commander.getId())); + ability.addEffect(new CommanderCostModification(commander)); // Commander rule #4 was removed Jan. 18, 2016 // ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander))); CommanderInfoWatcher watcher = new CommanderInfoWatcher("Commander", commander.getId(), false);