From 23a843455257e7caa0a337ec720c14d851852e2a Mon Sep 17 00:00:00 2001 From: xenohedron Date: Fri, 6 Sep 2024 21:02:59 -0400 Subject: [PATCH] fix Twitching Doll counter type small refactor to CountersSourceCount for counters of any type --- Mage.Sets/src/mage/cards/g/GavelOfTheRighteous.java | 5 +---- Mage.Sets/src/mage/cards/h/HancockGhoulishMayor.java | 4 +--- Mage.Sets/src/mage/cards/i/IndominusRexAlpha.java | 5 +---- Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java | 2 +- Mage.Sets/src/mage/cards/t/TwitchingDoll.java | 7 ++----- .../abilities/dynamicvalue/common/CountersSourceCount.java | 4 +--- Mage/src/main/java/mage/counters/CounterType.java | 6 +----- 7 files changed, 8 insertions(+), 25 deletions(-) diff --git a/Mage.Sets/src/mage/cards/g/GavelOfTheRighteous.java b/Mage.Sets/src/mage/cards/g/GavelOfTheRighteous.java index dfd77502e98..e5645cf94fa 100644 --- a/Mage.Sets/src/mage/cards/g/GavelOfTheRighteous.java +++ b/Mage.Sets/src/mage/cards/g/GavelOfTheRighteous.java @@ -8,7 +8,6 @@ import mage.abilities.costs.OrCost; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.decorator.ConditionalContinuousEffect; -import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.common.continuous.BoostEquippedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; @@ -33,8 +32,6 @@ import java.util.stream.IntStream; */ public final class GavelOfTheRighteous extends CardImpl { - private static final DynamicValue xValue = new CountersSourceCount(); - public GavelOfTheRighteous(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); @@ -46,7 +43,7 @@ public final class GavelOfTheRighteous extends CardImpl { )); // Equipped creature gets +1/+1 for each counter on Gavel of the Righteous. - this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(xValue, xValue))); + this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(CountersSourceCount.ANY, CountersSourceCount.ANY))); // As long as Gavel of the Righteous has four or more counters on it, equipped creature has double strike. this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect( diff --git a/Mage.Sets/src/mage/cards/h/HancockGhoulishMayor.java b/Mage.Sets/src/mage/cards/h/HancockGhoulishMayor.java index 7d3e17630ff..02b14d699b6 100644 --- a/Mage.Sets/src/mage/cards/h/HancockGhoulishMayor.java +++ b/Mage.Sets/src/mage/cards/h/HancockGhoulishMayor.java @@ -2,7 +2,6 @@ package mage.cards.h; import mage.MageInt; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.common.continuous.BoostControlledEffect; import mage.abilities.keyword.UndyingAbility; @@ -22,7 +21,6 @@ import java.util.UUID; */ public final class HancockGhoulishMayor extends CardImpl { - private static final DynamicValue xValue = new CountersSourceCount(); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); static { @@ -44,7 +42,7 @@ public final class HancockGhoulishMayor extends CardImpl { // Each other creature you control that's a Zombie or Mutant gets +X/+X, where X is the number of counters on Hancock, Ghoulish Mayor. this.addAbility(new SimpleStaticAbility(new BoostControlledEffect( - xValue, xValue, Duration.WhileOnBattlefield, filter, true + CountersSourceCount.ANY, CountersSourceCount.ANY, Duration.WhileOnBattlefield, filter, true ).setText("each other creature you control that's a Zombie or Mutant " + "gets +X/+X, where X is the number of counters on {this}"))); diff --git a/Mage.Sets/src/mage/cards/i/IndominusRexAlpha.java b/Mage.Sets/src/mage/cards/i/IndominusRexAlpha.java index d8b2cbf5da6..a27e3114b0a 100644 --- a/Mage.Sets/src/mage/cards/i/IndominusRexAlpha.java +++ b/Mage.Sets/src/mage/cards/i/IndominusRexAlpha.java @@ -6,7 +6,6 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; @@ -30,8 +29,6 @@ import mage.target.common.TargetDiscard; */ public final class IndominusRexAlpha extends CardImpl { - private static final DynamicValue xValue = new CountersSourceCount(); - public IndominusRexAlpha(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U/B}{U/B}{G}{G}"); @@ -47,7 +44,7 @@ public final class IndominusRexAlpha extends CardImpl { this.addAbility(new AsEntersBattlefieldAbility(new IndominusRexAlphaCountersEffect())); // When Indominus Rex enters the battlefield, draw a card for each counter on it. - this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(xValue) + this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(CountersSourceCount.ANY) .setText("draw a card for each counter on it"))); } diff --git a/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java b/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java index 917419d0ad6..7dff16ac6f9 100644 --- a/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java +++ b/Mage.Sets/src/mage/cards/o/OmarthisGhostfireInitiate.java @@ -58,7 +58,7 @@ public final class OmarthisGhostfireInitiate extends CardImpl { // When Omarthis dies, manifest a number of cards from the top of your library equal to the number of counters on it. this.addAbility(new DiesSourceTriggeredAbility( - new ManifestEffect(new CountersSourceCount()) + new ManifestEffect(CountersSourceCount.ANY) .setText("manifest a number of cards from the top of your library equal to the number of counters on it."), false )); diff --git a/Mage.Sets/src/mage/cards/t/TwitchingDoll.java b/Mage.Sets/src/mage/cards/t/TwitchingDoll.java index 26f72276014..f4d665289bf 100644 --- a/Mage.Sets/src/mage/cards/t/TwitchingDoll.java +++ b/Mage.Sets/src/mage/cards/t/TwitchingDoll.java @@ -5,7 +5,6 @@ import mage.abilities.Ability; import mage.abilities.common.ActivateAsSorceryActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; @@ -24,8 +23,6 @@ import java.util.UUID; */ public final class TwitchingDoll extends CardImpl { - private static final DynamicValue xValue = new CountersSourceCount(); - public TwitchingDoll(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}{G}"); @@ -36,12 +33,12 @@ public final class TwitchingDoll extends CardImpl { // {T}: Add one mana of any color. Put a nest counter on Twitching Doll. Ability ability = new AnyColorManaAbility(); - ability.addEffect(new AddCountersSourceEffect(CounterType.OMEN.createInstance())); + ability.addEffect(new AddCountersSourceEffect(CounterType.NEST.createInstance())); this.addAbility(ability); // {T}, Sacrifice Twitching Doll: Create a 2/2 green Spider creature token with reach for each counter on Twitching Doll. Activate only as a sorcery. ability = new ActivateAsSorceryActivatedAbility( - new CreateTokenEffect(new Spider22Token(), xValue), new TapSourceCost() + new CreateTokenEffect(new Spider22Token(), CountersSourceCount.ANY), new TapSourceCost() ); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java index 69c0e358f29..574ee108e69 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java @@ -15,9 +15,7 @@ public class CountersSourceCount implements DynamicValue { /** * Number of counters of any type on the source permanent */ - public CountersSourceCount() { - this((CounterType) null); - } + public static final CountersSourceCount ANY = new CountersSourceCount((CounterType) null); /** * Number of counters of the specified type on the source permanent diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index 29511e65425..7b9e33d19cc 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -150,6 +150,7 @@ public enum CounterType { MUSIC("music"), MUSTER("muster"), NECRODERMIS("necrodermis"), + NEST("nest"), NET("net"), NIGHT("night"), OIL("oil"), @@ -260,8 +261,6 @@ public enum CounterType { /** * Get counter string name. - * - * @return */ public String getName() { return this.name; @@ -273,8 +272,6 @@ public enum CounterType { /** * Create instance of counter type with amount equal to 1. - * - * @return */ public Counter createInstance() { return createInstance(1); @@ -285,7 +282,6 @@ public enum CounterType { * given type. * * @param amount amount of counters of the given type. - * @return */ public Counter createInstance(int amount) { switch (this) {