From 6a3b768ca6c0ff95113342deb2f4bbed9640385c Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 2 Nov 2021 19:27:30 -0400 Subject: [PATCH] [VOW] Implemented Ancient Lumberknot --- .../src/mage/cards/a/AncientLumberknot.java | 57 +++++++++++++++++++ .../src/mage/cards/d/DoranTheSiegeTower.java | 11 +--- .../src/mage/sets/InnistradCrimsonVow.java | 1 + .../CombatDamageByToughnessEffect.java | 30 ++++++---- 4 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/a/AncientLumberknot.java diff --git a/Mage.Sets/src/mage/cards/a/AncientLumberknot.java b/Mage.Sets/src/mage/cards/a/AncientLumberknot.java new file mode 100644 index 00000000000..cd944672aac --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AncientLumberknot.java @@ -0,0 +1,57 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.ruleModifying.CombatDamageByToughnessEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AncientLumberknot extends CardImpl { + + private static final FilterCreaturePermanent filter + = new FilterCreaturePermanent("creature you control with toughness greater than its power"); + + static { + filter.add(AncientLumberknotPredicate.instance); + } + + public AncientLumberknot(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}"); + + this.subtype.add(SubType.TREEFOLK); + this.power = new MageInt(1); + this.toughness = new MageInt(4); + + // Each creature you control with toughness greater than its power assigns combat damage equal to its toughness rather than its power. + this.addAbility(new SimpleStaticAbility(new CombatDamageByToughnessEffect(filter, true))); + } + + private AncientLumberknot(final AncientLumberknot card) { + super(card); + } + + @Override + public AncientLumberknot copy() { + return new AncientLumberknot(this); + } +} + +enum AncientLumberknotPredicate implements Predicate { + instance; + + @Override + public boolean apply(Permanent input, Game game) { + return input.getToughness().getValue() > input.getPower().getValue(); + } +} diff --git a/Mage.Sets/src/mage/cards/d/DoranTheSiegeTower.java b/Mage.Sets/src/mage/cards/d/DoranTheSiegeTower.java index 984b2342ec1..24918b36682 100644 --- a/Mage.Sets/src/mage/cards/d/DoranTheSiegeTower.java +++ b/Mage.Sets/src/mage/cards/d/DoranTheSiegeTower.java @@ -1,4 +1,3 @@ - package mage.cards.d; import mage.MageInt; @@ -9,7 +8,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.SuperType; -import mage.constants.Zone; import mage.filter.StaticFilters; import java.util.UUID; @@ -37,12 +35,9 @@ public final class DoranTheSiegeTower extends CardImpl { this.toughness = new MageInt(5); // Each creature assigns combat damage equal to its toughness rather than its power. - this.addAbility(new SimpleStaticAbility( - Zone.BATTLEFIELD, - new CombatDamageByToughnessEffect( - StaticFilters.FILTER_PERMANENT_CREATURE, false - ) - )); + this.addAbility(new SimpleStaticAbility(new CombatDamageByToughnessEffect( + StaticFilters.FILTER_PERMANENT_CREATURE, false + ))); } private DoranTheSiegeTower(final DoranTheSiegeTower card) { diff --git a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java index ef5fe0b83b2..27c0cd35c82 100644 --- a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java +++ b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java @@ -33,6 +33,7 @@ public final class InnistradCrimsonVow extends ExpansionSet { cards.add(new SetCardInfo("Abrade", 139, Rarity.COMMON, mage.cards.a.Abrade.class)); cards.add(new SetCardInfo("Ancestor's Embrace", 22, Rarity.COMMON, mage.cards.a.AncestorsEmbrace.class)); + cards.add(new SetCardInfo("Ancient Lumberknot", 230, Rarity.UNCOMMON, mage.cards.a.AncientLumberknot.class)); cards.add(new SetCardInfo("Angelic Quartermaster", 2, Rarity.UNCOMMON, mage.cards.a.AngelicQuartermaster.class)); cards.add(new SetCardInfo("Anje, Maid of Dishonor", 231, Rarity.RARE, mage.cards.a.AnjeMaidOfDishonor.class)); cards.add(new SetCardInfo("Apprentice Sharpshooter", 185, Rarity.COMMON, mage.cards.a.ApprenticeSharpshooter.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CombatDamageByToughnessEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CombatDamageByToughnessEffect.java index a72ec5c1e6f..55f3369ef1f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CombatDamageByToughnessEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CombatDamageByToughnessEffect.java @@ -2,6 +2,7 @@ package mage.abilities.effects.common.ruleModifying; import mage.abilities.Ability; +import mage.abilities.Mode; import mage.abilities.effects.ContinuousEffectImpl; import mage.constants.Duration; import mage.constants.Layer; @@ -20,11 +21,9 @@ public class CombatDamageByToughnessEffect extends ContinuousEffectImpl { private final boolean onlyControlled; public CombatDamageByToughnessEffect(FilterCreaturePermanent filter, boolean onlyControlled) { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + super(Duration.WhileOnBattlefield, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment); this.filter = filter; this.onlyControlled = onlyControlled; - staticText = "Each " + filter.getMessage() + (onlyControlled ? " you control" : "") + - " assigns combat damage equal to its toughness rather than its power"; } private CombatDamageByToughnessEffect(final CombatDamageByToughnessEffect effect) { @@ -39,11 +38,14 @@ public class CombatDamageByToughnessEffect extends ContinuousEffectImpl { } @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + public boolean apply(Game game, Ability source) { // Change the rule - FilterCreaturePermanent filterPermanent = filter.copy(); + FilterCreaturePermanent filterPermanent; if (onlyControlled) { + filterPermanent = filter.copy(); filterPermanent.add(new ControllerIdPredicate(source.getControllerId())); + } else { + filterPermanent = filter; } game.getCombat().setUseToughnessForDamage(true); game.getCombat().addUseToughnessForDamageFilter(filterPermanent); @@ -51,12 +53,16 @@ public class CombatDamageByToughnessEffect extends ContinuousEffectImpl { } @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.RulesEffects; + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + StringBuilder sb = new StringBuilder("Each "); + sb.append(filter.getMessage()); + if (onlyControlled && !filter.getMessage().contains("you control")) { + sb.append(" you control"); + } + sb.append(" assigns combat damage equal to its toughness rather than its power"); + return sb.toString(); } }