From 34b671bc838d5aaf3265dc1e3f502682f71753a8 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Wed, 6 Sep 2023 00:19:08 -0400 Subject: [PATCH] cleanup add color/subtype attached effects --- .../src/mage/cards/a/AngelicArmaments.java | 4 ++-- .../src/mage/cards/a/AngelicDestiny.java | 2 +- Mage.Sets/src/mage/cards/c/CallToServe.java | 2 +- Mage.Sets/src/mage/cards/c/CaptainsHook.java | 3 +-- .../src/mage/cards/d/DemonicEmbrace.java | 2 +- .../src/mage/cards/d/DraconicDestiny.java | 2 +- Mage.Sets/src/mage/cards/d/Dub.java | 3 +-- Mage.Sets/src/mage/cards/g/Ghoulflesh.java | 12 +++++----- Mage.Sets/src/mage/cards/i/InnerDemon.java | 2 +- Mage.Sets/src/mage/cards/r/RavenWings.java | 3 +-- .../mage/cards/s/SigiledSwordOfValeron.java | 2 -- .../src/mage/cards/t/TallAsABeanstalk.java | 2 +- Mage.Sets/src/mage/cards/t/TrooperArmor.java | 2 +- .../AddCardColorAttachedEffect.java | 20 +++++------------ .../AddCardSubtypeAttachedEffect.java | 22 +++++-------------- 15 files changed, 30 insertions(+), 53 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AngelicArmaments.java b/Mage.Sets/src/mage/cards/a/AngelicArmaments.java index ee18afa108d..9a081fb7303 100644 --- a/Mage.Sets/src/mage/cards/a/AngelicArmaments.java +++ b/Mage.Sets/src/mage/cards/a/AngelicArmaments.java @@ -31,10 +31,10 @@ public final class AngelicArmaments extends CardImpl { FlyingAbility.getInstance(), AttachmentType.EQUIPMENT ).setText(", has flying")); ability.addEffect(new AddCardColorAttachedEffect( - ObjectColor.WHITE, Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT + ObjectColor.WHITE, AttachmentType.EQUIPMENT ).setText(",")); ability.addEffect(new AddCardSubtypeAttachedEffect( - SubType.ANGEL, Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT + SubType.ANGEL, AttachmentType.EQUIPMENT ).setText("is a white Angel in addition to its other colors and types").concatBy("and")); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/a/AngelicDestiny.java b/Mage.Sets/src/mage/cards/a/AngelicDestiny.java index 6a2948d30e1..5cf5e25c687 100644 --- a/Mage.Sets/src/mage/cards/a/AngelicDestiny.java +++ b/Mage.Sets/src/mage/cards/a/AngelicDestiny.java @@ -45,7 +45,7 @@ public final class AngelicDestiny extends CardImpl { effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA); effect.setText("and first strike"); ability.addEffect(effect); - effect = new AddCardSubtypeAttachedEffect(SubType.ANGEL, Duration.WhileOnBattlefield, AttachmentType.AURA); + effect = new AddCardSubtypeAttachedEffect(SubType.ANGEL, AttachmentType.AURA); effect.setText(", and is an Angel in addition to its other types"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/c/CallToServe.java b/Mage.Sets/src/mage/cards/c/CallToServe.java index 0e4c7db1ec8..f015b5edda4 100644 --- a/Mage.Sets/src/mage/cards/c/CallToServe.java +++ b/Mage.Sets/src/mage/cards/c/CallToServe.java @@ -39,7 +39,7 @@ public final class CallToServe extends CardImpl { Effect effect = new GainAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA); effect.setText(", has flying"); ability.addEffect(effect); - effect = new AddCardSubtypeAttachedEffect(SubType.ANGEL, Duration.WhileOnBattlefield, AttachmentType.AURA); + effect = new AddCardSubtypeAttachedEffect(SubType.ANGEL, AttachmentType.AURA); effect.setText(", and is an Angel in addition to its other types"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/c/CaptainsHook.java b/Mage.Sets/src/mage/cards/c/CaptainsHook.java index 8dc404679e0..16f32447e77 100644 --- a/Mage.Sets/src/mage/cards/c/CaptainsHook.java +++ b/Mage.Sets/src/mage/cards/c/CaptainsHook.java @@ -17,7 +17,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.AttachmentType; import mage.constants.CardType; -import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.Zone; @@ -42,7 +41,7 @@ public final class CaptainsHook extends CardImpl { effect.setText(", has menace"); ability.addEffect(effect); //, and is a Pirate in addition to its other creature types - effect = new AddCardSubtypeAttachedEffect(SubType.PIRATE, Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT); + effect = new AddCardSubtypeAttachedEffect(SubType.PIRATE, AttachmentType.EQUIPMENT); effect.setText(", and is a Pirate in addition to its other creature types"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/d/DemonicEmbrace.java b/Mage.Sets/src/mage/cards/d/DemonicEmbrace.java index db6e8ac1693..df6d90cee1e 100644 --- a/Mage.Sets/src/mage/cards/d/DemonicEmbrace.java +++ b/Mage.Sets/src/mage/cards/d/DemonicEmbrace.java @@ -48,7 +48,7 @@ public final class DemonicEmbrace extends CardImpl { Effect effect = new GainAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA); effect.setText(", has flying"); ability.addEffect(effect); - effect = new AddCardSubtypeAttachedEffect(SubType.DEMON, Duration.WhileOnBattlefield, AttachmentType.AURA); + effect = new AddCardSubtypeAttachedEffect(SubType.DEMON, AttachmentType.AURA); effect.setText(", and is a Demon in addition to its other types"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/d/DraconicDestiny.java b/Mage.Sets/src/mage/cards/d/DraconicDestiny.java index 3e4779880b1..e377cbf651b 100644 --- a/Mage.Sets/src/mage/cards/d/DraconicDestiny.java +++ b/Mage.Sets/src/mage/cards/d/DraconicDestiny.java @@ -45,7 +45,7 @@ public final class DraconicDestiny extends CardImpl { ability.addEffect(new GainAbilityAttachedEffect(new SimpleActivatedAbility( new BoostSourceEffect(1, 0, Duration.EndOfTurn), new GenericManaCost(1) ), AttachmentType.AURA).setText(", and \"{1}: This creature gets +1/+0 until end of turn.\"")); - ability.addEffect(new AddCardSubtypeAttachedEffect(SubType.DRAGON, Duration.WhileOnBattlefield, AttachmentType.AURA) + ability.addEffect(new AddCardSubtypeAttachedEffect(SubType.DRAGON, AttachmentType.AURA) .setText("It's a Dragon in addition to its other types")); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/d/Dub.java b/Mage.Sets/src/mage/cards/d/Dub.java index e2d96e88159..01b19d5522c 100644 --- a/Mage.Sets/src/mage/cards/d/Dub.java +++ b/Mage.Sets/src/mage/cards/d/Dub.java @@ -15,7 +15,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.AttachmentType; import mage.constants.CardType; -import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.Zone; @@ -45,7 +44,7 @@ public final class Dub extends CardImpl { effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA); effect.setText(", has first strike"); ability.addEffect(effect); - effect = new AddCardSubtypeAttachedEffect(SubType.KNIGHT, Duration.WhileOnBattlefield, AttachmentType.AURA); + effect = new AddCardSubtypeAttachedEffect(SubType.KNIGHT, AttachmentType.AURA); effect.setText(", and is a Knight in addition to its other types"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/g/Ghoulflesh.java b/Mage.Sets/src/mage/cards/g/Ghoulflesh.java index ded0c933bd5..ce022098a8a 100644 --- a/Mage.Sets/src/mage/cards/g/Ghoulflesh.java +++ b/Mage.Sets/src/mage/cards/g/Ghoulflesh.java @@ -1,8 +1,8 @@ - package mage.cards.g; import java.util.UUID; import mage.ObjectColor; +import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.continuous.AddCardColorAttachedEffect; @@ -24,7 +24,6 @@ public final class Ghoulflesh extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{B}"); this.subtype.add(SubType.AURA); - // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); @@ -32,9 +31,12 @@ public final class Ghoulflesh extends CardImpl { this.addAbility(new EnchantAbility(auraTarget)); // Enchanted creature gets -1/-1 and is a black Zombie in addition to its other colors and types. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(-1, -1, Duration.WhileOnBattlefield))); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AddCardSubtypeAttachedEffect(SubType.ZOMBIE, Duration.WhileOnBattlefield, AttachmentType.AURA))); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AddCardColorAttachedEffect(ObjectColor.BLACK, Duration.WhileOnBattlefield, AttachmentType.AURA))); + Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(-1, -1, Duration.WhileOnBattlefield)); + ability.addEffect(new AddCardColorAttachedEffect(ObjectColor.BLACK, AttachmentType.AURA) + .setText(" and is a black")); + ability.addEffect(new AddCardSubtypeAttachedEffect(SubType.ZOMBIE, AttachmentType.AURA) + .setText(" Zombie in addition to its other colors and types")); + this.addAbility(ability); } private Ghoulflesh(final Ghoulflesh card) { diff --git a/Mage.Sets/src/mage/cards/i/InnerDemon.java b/Mage.Sets/src/mage/cards/i/InnerDemon.java index 723869af361..6c1a98a9ce9 100644 --- a/Mage.Sets/src/mage/cards/i/InnerDemon.java +++ b/Mage.Sets/src/mage/cards/i/InnerDemon.java @@ -55,7 +55,7 @@ public final class InnerDemon extends CardImpl { Effect effect = new GainAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA); effect.setText(", has flying"); ability.addEffect(effect); - effect = new AddCardSubtypeAttachedEffect(SubType.DEMON, Duration.WhileOnBattlefield, AttachmentType.AURA); + effect = new AddCardSubtypeAttachedEffect(SubType.DEMON, AttachmentType.AURA); effect.setText(", and is a Demon in addition to its other types"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/r/RavenWings.java b/Mage.Sets/src/mage/cards/r/RavenWings.java index 396f0b039c9..7c021006673 100644 --- a/Mage.Sets/src/mage/cards/r/RavenWings.java +++ b/Mage.Sets/src/mage/cards/r/RavenWings.java @@ -11,7 +11,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.AttachmentType; import mage.constants.CardType; -import mage.constants.Duration; import mage.constants.SubType; import java.util.UUID; @@ -32,7 +31,7 @@ public final class RavenWings extends CardImpl { FlyingAbility.getInstance(), AttachmentType.AURA ).setText(", has flying")); ability.addEffect(new AddCardSubtypeAttachedEffect( - SubType.BIRD, Duration.WhileOnBattlefield, AttachmentType.AURA + SubType.BIRD, AttachmentType.AURA ).setText(", and is a Bird in addition to its other types")); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/s/SigiledSwordOfValeron.java b/Mage.Sets/src/mage/cards/s/SigiledSwordOfValeron.java index 1da5cf4fdf4..f0c746feea8 100644 --- a/Mage.Sets/src/mage/cards/s/SigiledSwordOfValeron.java +++ b/Mage.Sets/src/mage/cards/s/SigiledSwordOfValeron.java @@ -16,7 +16,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.AttachmentType; import mage.constants.CardType; -import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.permanent.token.KnightToken; @@ -44,7 +43,6 @@ public final class SigiledSwordOfValeron extends CardImpl { ).setText(", has vigilance")); ability.addEffect(new AddCardSubtypeAttachedEffect( SubType.KNIGHT, - Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT ).setText(", and is a Knight in addition to its other types")); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/t/TallAsABeanstalk.java b/Mage.Sets/src/mage/cards/t/TallAsABeanstalk.java index 0f6031b2abf..4bc5298bfac 100644 --- a/Mage.Sets/src/mage/cards/t/TallAsABeanstalk.java +++ b/Mage.Sets/src/mage/cards/t/TallAsABeanstalk.java @@ -41,7 +41,7 @@ public final class TallAsABeanstalk extends CardImpl { ReachAbility.getInstance(), AttachmentType.AURA ).setText(", has reach")); ability.addEffect(new AddCardSubtypeAttachedEffect( - SubType.GIANT, Duration.WhileOnBattlefield, AttachmentType.AURA + SubType.GIANT, AttachmentType.AURA ).setText(", and is a Giant in addition to its other types")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/t/TrooperArmor.java b/Mage.Sets/src/mage/cards/t/TrooperArmor.java index c7173750b4b..a30cd993355 100644 --- a/Mage.Sets/src/mage/cards/t/TrooperArmor.java +++ b/Mage.Sets/src/mage/cards/t/TrooperArmor.java @@ -26,7 +26,7 @@ public final class TrooperArmor extends CardImpl { // Equiped creature gets +1/+1 and is a Trooper in addition to its other types. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 1))); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AddCardSubtypeAttachedEffect(SubType.TROOPER, Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AddCardSubtypeAttachedEffect(SubType.TROOPER, AttachmentType.EQUIPMENT))); // Whenever a Trooper enters the battlefield under your control, you may attach {this} to it. this.addAbility(new EntersBattlefieldControlledTriggeredAbility( diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardColorAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardColorAttachedEffect.java index 07cff2680a5..90bf119753b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardColorAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardColorAttachedEffect.java @@ -1,5 +1,3 @@ - - package mage.abilities.effects.common.continuous; import mage.ObjectColor; @@ -14,20 +12,18 @@ import mage.game.permanent.Permanent; */ public class AddCardColorAttachedEffect extends ContinuousEffectImpl { - private ObjectColor addedColor; - private AttachmentType attachmentType; + private final ObjectColor addedColor; - public AddCardColorAttachedEffect(ObjectColor addedColor, Duration duration, AttachmentType attachmentType) { - super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); + public AddCardColorAttachedEffect(ObjectColor addedColor, AttachmentType attachmentType) { + super(Duration.WhileOnBattlefield, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit); this.addedColor = addedColor; - this.attachmentType = attachmentType; - setText(); + staticText = attachmentType.verb() + " creature is " + addedColor.getDescription() + + " in addition to its other colors"; } protected AddCardColorAttachedEffect(final AddCardColorAttachedEffect effect) { super(effect); this.addedColor = effect.addedColor; - this.attachmentType = effect.attachmentType; } @Override @@ -56,10 +52,4 @@ public class AddCardColorAttachedEffect extends ContinuousEffectImpl { return new AddCardColorAttachedEffect(this); } - private void setText() { - StringBuilder sb = new StringBuilder(); - sb.append(attachmentType.verb()); - sb.append(" creature is a ").append(addedColor.getDescription()).append(" in addition to its colors"); - staticText = sb.toString(); - } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAttachedEffect.java index 3b6114beb3f..d1b489acc28 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAttachedEffect.java @@ -1,5 +1,3 @@ - - package mage.abilities.effects.common.continuous; import mage.abilities.Ability; @@ -7,25 +5,24 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.util.CardUtil; /** * @author nantuko */ public class AddCardSubtypeAttachedEffect extends ContinuousEffectImpl { - private SubType addedSubtype; - private AttachmentType attachmentType; + private final SubType addedSubtype; - public AddCardSubtypeAttachedEffect(SubType addedSubtype, Duration duration, AttachmentType attachmentType) { - super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); + public AddCardSubtypeAttachedEffect(SubType addedSubtype, AttachmentType attachmentType) { + super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); this.addedSubtype = addedSubtype; - this.attachmentType = attachmentType; - setText(); + staticText = attachmentType.verb() + + " creature becomes " + CardUtil.addArticle(addedSubtype.getDescription()) + " in addition to its other types"; } protected AddCardSubtypeAttachedEffect(final AddCardSubtypeAttachedEffect effect) { super(effect); this.addedSubtype = effect.addedSubtype; - this.attachmentType = effect.attachmentType; } @Override @@ -44,11 +41,4 @@ public class AddCardSubtypeAttachedEffect extends ContinuousEffectImpl { return new AddCardSubtypeAttachedEffect(this); } - private void setText() { - StringBuilder sb = new StringBuilder(); - - sb.append(attachmentType.verb()); - sb.append(" creature becomes ").append(addedSubtype).append(" in addition to its other types"); //TODO add attacked card type detection - staticText = sb.toString(); - } }