From 4968f0b18c9d7fa42b81e7acbbd8ede6b778efff Mon Sep 17 00:00:00 2001 From: xenohedron Date: Sun, 4 Feb 2024 20:34:20 -0500 Subject: [PATCH] cleanup BecomesColorTargetEffect add option to retain color --- .../src/mage/cards/e/EightAndAHalfTails.java | 12 ++++------- Mage.Sets/src/mage/cards/i/Incite.java | 4 +--- Mage.Sets/src/mage/cards/x/XathridGorgon.java | 18 ++++++++-------- .../continuous/BecomesColorTargetEffect.java | 21 ++++++++++++------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Mage.Sets/src/mage/cards/e/EightAndAHalfTails.java b/Mage.Sets/src/mage/cards/e/EightAndAHalfTails.java index 59266cf81fb..cbcee74440f 100644 --- a/Mage.Sets/src/mage/cards/e/EightAndAHalfTails.java +++ b/Mage.Sets/src/mage/cards/e/EightAndAHalfTails.java @@ -1,4 +1,3 @@ - package mage.cards.e; import java.util.UUID; @@ -17,7 +16,6 @@ import mage.constants.SubType; import mage.constants.Duration; import mage.constants.SuperType; import mage.constants.Zone; -import mage.target.Target; import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetSpellOrPermanent; @@ -38,14 +36,12 @@ public final class EightAndAHalfTails extends CardImpl { // {1}{W}: Target permanent you control gains protection from white until end of turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilityTargetEffect(ProtectionAbility.from(ObjectColor.WHITE), Duration.EndOfTurn), new ManaCostsImpl<>("{1}{W}")); - Target target = new TargetControlledPermanent(); - ability.addTarget(target); + ability.addTarget(new TargetControlledPermanent()); this.addAbility(ability); // {1}: Target spell or permanent becomes white until end of turn. - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new BecomesColorTargetEffect(ObjectColor.WHITE, Duration.EndOfTurn, "Target spell or permanent becomes white until end of turn"), new ManaCostsImpl<>("{1}")); - target = new TargetSpellOrPermanent(); - ability.addTarget(target); + ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorTargetEffect(ObjectColor.WHITE, Duration.EndOfTurn) + .setText("Target spell or permanent becomes white until end of turn"), new ManaCostsImpl<>("{1}")); + ability.addTarget(new TargetSpellOrPermanent()); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/i/Incite.java b/Mage.Sets/src/mage/cards/i/Incite.java index f3da767313c..55a3b041a19 100644 --- a/Mage.Sets/src/mage/cards/i/Incite.java +++ b/Mage.Sets/src/mage/cards/i/Incite.java @@ -1,5 +1,3 @@ - - package mage.cards.i; import java.util.UUID; @@ -24,7 +22,7 @@ public final class Incite extends CardImpl { // Target creature becomes red until end of turn and attacks this turn if able. this.getSpellAbility().addTarget(new TargetCreaturePermanent()); - this.getSpellAbility().addEffect(new BecomesColorTargetEffect(ObjectColor.RED, Duration.EndOfTurn, "Target creature becomes red until end of turn")); + this.getSpellAbility().addEffect(new BecomesColorTargetEffect(ObjectColor.RED, Duration.EndOfTurn)); this.getSpellAbility().addEffect(new AttacksIfAbleTargetEffect(Duration.EndOfTurn).setText("and attacks this turn if able")); } diff --git a/Mage.Sets/src/mage/cards/x/XathridGorgon.java b/Mage.Sets/src/mage/cards/x/XathridGorgon.java index db718fbb4e4..297ab23082f 100644 --- a/Mage.Sets/src/mage/cards/x/XathridGorgon.java +++ b/Mage.Sets/src/mage/cards/x/XathridGorgon.java @@ -6,7 +6,6 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.common.continuous.AddCardTypeTargetEffect; import mage.abilities.effects.common.continuous.BecomesColorTargetEffect; @@ -43,16 +42,17 @@ public final class XathridGorgon extends CardImpl { this.addAbility(DeathtouchAbility.getInstance()); // {2}{B}, {tap}: Put a petrification counter on target creature. It gains defender and becomes a colorless artifact in addition to its other types. Its activated abilities can't be activated. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.PETRIFICATION.createInstance()), new ManaCostsImpl<>("{2}{B}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new AddCountersTargetEffect(CounterType.PETRIFICATION.createInstance()), + new ManaCostsImpl<>("{2}{B}")); ability.addCost(new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); - Effect effect = new GainAbilityTargetEffect(DefenderAbility.getInstance(), Duration.Custom); - effect.setText("It gains defender"); - ability.addEffect(effect); - effect = new AddCardTypeTargetEffect(Duration.Custom, CardType.ARTIFACT); - effect.setText("and becomes a colorless"); - ability.addEffect(effect); - ability.addEffect(new BecomesColorTargetEffect(ObjectColor.COLORLESS, Duration.Custom, " artifact in addition to its other types")); + ability.addEffect(new GainAbilityTargetEffect(DefenderAbility.getInstance(), Duration.Custom) + .setText("It gains defender")); + ability.addEffect(new AddCardTypeTargetEffect(Duration.Custom, CardType.ARTIFACT) + .setText("and becomes a colorless")); + ability.addEffect(new BecomesColorTargetEffect(ObjectColor.COLORLESS, Duration.Custom) + .setText(" artifact in addition to its other types")); ability.addEffect(new XathridGorgonCantActivateEffect()); this.addAbility(ability); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java index 578c6a5e24e..ab4f389b6a8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java @@ -23,29 +23,29 @@ import mage.players.Player; public class BecomesColorTargetEffect extends ContinuousEffectImpl { private ObjectColor setColor; + private final boolean retainColor; /** * Set the color of a spell or permanent - * - * @param duration */ public BecomesColorTargetEffect(Duration duration) { - this(null, duration, null); + this(null, duration); } public BecomesColorTargetEffect(ObjectColor setColor, Duration duration) { - this(setColor, duration, null); + this(setColor, false, duration); } - public BecomesColorTargetEffect(ObjectColor setColor, Duration duration, String text) { + public BecomesColorTargetEffect(ObjectColor setColor, boolean retainColor, Duration duration) { super(duration, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit); this.setColor = setColor; - staticText = text; + this.retainColor = retainColor; } protected BecomesColorTargetEffect(final BecomesColorTargetEffect effect) { super(effect); this.setColor = effect.setColor; + this.retainColor = effect.retainColor; } @Override @@ -82,7 +82,11 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl { if (targetObject != null) { if (targetObject instanceof Spell || targetObject instanceof Permanent) { objectFound = true; - targetObject.getColor(game).setColor(setColor); + if (retainColor) { + targetObject.getColor(game).addColor(setColor); + } else { + targetObject.getColor(game).setColor(setColor); + } } else { objectFound = false; } @@ -114,6 +118,9 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl { } else { sb.append(setColor.getDescription()); } + if (retainColor) { + sb.append(" in addition to its other colors"); + } if (!duration.toString().isEmpty()) { sb.append(' ').append(duration.toString()); }