From 9f922c6a2a6afdc370fc7bdff2eeddea9a060b6d Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Fri, 7 Oct 2011 12:24:44 -0400 Subject: [PATCH] made Hexproof a singleton --- .../src/mage/sets/eventide/SlipperyBogle.java | 2 +- .../mage/sets/innistrad/AngelicOverseer.java | 2 +- .../sets/innistrad/GeistOfSaintTraft.java | 2 +- .../mage/sets/innistrad/InvisibleStalker.java | 2 +- .../src/mage/sets/innistrad/Lumberknot.java | 2 +- .../src/mage/sets/innistrad/MaskOfAvacyn.java | 2 +- .../src/mage/sets/innistrad/RangersGuile.java | 2 +- .../src/mage/sets/magic2011/SacredWolf.java | 8 +------ .../mage/sets/magic2012/AvenFleetwing.java | 2 +- .../mage/sets/magic2012/DungroveElder.java | 2 +- .../mage/sets/magic2012/GladecoverScout.java | 2 +- .../mage/sets/magic2012/LordOfTheUnreal.java | 2 +- .../mage/sets/magic2012/SwiftfootBoots.java | 2 +- .../src/mage/sets/mirrodin/LeoninAbunas.java | 2 +- .../mage/sets/mirrodin/PlatedSlagwurm.java | 2 +- .../src/mage/sets/mirrodin/TrollAscetic.java | 2 +- .../mirrodinbesieged/ThrunTheLastTroll.java | 2 +- .../mage/sets/shadowmoor/DroveOfElves.java | 2 +- .../mage/sets/zendikar/VinesOfVastwood.java | 2 +- .../abilities/keyword/HexproofAbility.java | 24 ++++++++++--------- 20 files changed, 32 insertions(+), 36 deletions(-) diff --git a/Mage.Sets/src/mage/sets/eventide/SlipperyBogle.java b/Mage.Sets/src/mage/sets/eventide/SlipperyBogle.java index 4097a27915..2d4de1b7db 100644 --- a/Mage.Sets/src/mage/sets/eventide/SlipperyBogle.java +++ b/Mage.Sets/src/mage/sets/eventide/SlipperyBogle.java @@ -50,7 +50,7 @@ public class SlipperyBogle extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); } public SlipperyBogle(final SlipperyBogle card) { diff --git a/Mage.Sets/src/mage/sets/innistrad/AngelicOverseer.java b/Mage.Sets/src/mage/sets/innistrad/AngelicOverseer.java index 5fa6ac5146..fd3d1dbbd8 100644 --- a/Mage.Sets/src/mage/sets/innistrad/AngelicOverseer.java +++ b/Mage.Sets/src/mage/sets/innistrad/AngelicOverseer.java @@ -68,7 +68,7 @@ public class AngelicOverseer extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // As long as you control a Human, Angelic Overseer has hexproof and is indestructible. - Ability ability = new ConditionalStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilitySourceEffect(new HexproofAbility()), new ControlsPermanentCondition(filter), rule); + Ability ability = new ConditionalStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilitySourceEffect(HexproofAbility.getInstance()), new ControlsPermanentCondition(filter), rule); ability.addEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance())); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/innistrad/GeistOfSaintTraft.java b/Mage.Sets/src/mage/sets/innistrad/GeistOfSaintTraft.java index d26940e7dc..0972035ff0 100644 --- a/Mage.Sets/src/mage/sets/innistrad/GeistOfSaintTraft.java +++ b/Mage.Sets/src/mage/sets/innistrad/GeistOfSaintTraft.java @@ -64,7 +64,7 @@ public class GeistOfSaintTraft extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); // Whenever Geist of Saint Traft attacks, put a 4/4 white Angel creature token with flying onto the battlefield tapped and attacking. Exile that token at end of combat. this.addAbility(new AttacksTriggeredAbility(new GeistOfSaintTraftEffect(), false)); } diff --git a/Mage.Sets/src/mage/sets/innistrad/InvisibleStalker.java b/Mage.Sets/src/mage/sets/innistrad/InvisibleStalker.java index b2d37cd905..689e081979 100644 --- a/Mage.Sets/src/mage/sets/innistrad/InvisibleStalker.java +++ b/Mage.Sets/src/mage/sets/innistrad/InvisibleStalker.java @@ -51,7 +51,7 @@ public class InvisibleStalker extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); // Invisible Stalker is unblockable. this.addAbility(UnblockableAbility.getInstance()); } diff --git a/Mage.Sets/src/mage/sets/innistrad/Lumberknot.java b/Mage.Sets/src/mage/sets/innistrad/Lumberknot.java index 3b046106c5..91c0f30fdf 100644 --- a/Mage.Sets/src/mage/sets/innistrad/Lumberknot.java +++ b/Mage.Sets/src/mage/sets/innistrad/Lumberknot.java @@ -52,7 +52,7 @@ public class Lumberknot extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); // Whenever a creature dies, put a +1/+1 counter on Lumberknot. this.addAbility(new CreatureDiesTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false)); } diff --git a/Mage.Sets/src/mage/sets/innistrad/MaskOfAvacyn.java b/Mage.Sets/src/mage/sets/innistrad/MaskOfAvacyn.java index 3b1597240e..f5d59f50ef 100644 --- a/Mage.Sets/src/mage/sets/innistrad/MaskOfAvacyn.java +++ b/Mage.Sets/src/mage/sets/innistrad/MaskOfAvacyn.java @@ -54,7 +54,7 @@ public class MaskOfAvacyn extends CardImpl { this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(3))); // Equipped creature gets +1/+2 and has hexproof. - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new HexproofAbility(), Constants.AttachmentType.EQUIPMENT))); + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(HexproofAbility.getInstance(), Constants.AttachmentType.EQUIPMENT))); this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostEquippedEffect(1, 2))); } diff --git a/Mage.Sets/src/mage/sets/innistrad/RangersGuile.java b/Mage.Sets/src/mage/sets/innistrad/RangersGuile.java index 6564bb9bc0..972af38610 100644 --- a/Mage.Sets/src/mage/sets/innistrad/RangersGuile.java +++ b/Mage.Sets/src/mage/sets/innistrad/RangersGuile.java @@ -52,7 +52,7 @@ public class RangersGuile extends CardImpl { // Target creature you control gets +1/+1 and gains hexproof until end of turn. this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addEffect(new BoostTargetEffect(1, 1, Duration.EndOfTurn)); - this.getSpellAbility().addEffect(new GainAbilityTargetEffect(new HexproofAbility(), Duration.EndOfTurn)); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(HexproofAbility.getInstance(), Duration.EndOfTurn)); } public RangersGuile(final RangersGuile card) { diff --git a/Mage.Sets/src/mage/sets/magic2011/SacredWolf.java b/Mage.Sets/src/mage/sets/magic2011/SacredWolf.java index 544b704293..fa23baa414 100644 --- a/Mage.Sets/src/mage/sets/magic2011/SacredWolf.java +++ b/Mage.Sets/src/mage/sets/magic2011/SacredWolf.java @@ -30,16 +30,10 @@ package mage.sets.magic2011; import java.util.UUID; import mage.Constants.CardType; -import mage.Constants.Duration; import mage.Constants.Rarity; -import mage.Constants.TargetController; -import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.common.CantTargetSourceEffect; import mage.abilities.keyword.HexproofAbility; import mage.cards.CardImpl; -import mage.filter.FilterStackObject; /** * @@ -53,7 +47,7 @@ public class SacredWolf extends CardImpl { this.color.setGreen(true); this.power = new MageInt(3); this.toughness = new MageInt(1); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); } public SacredWolf(final SacredWolf card) { diff --git a/Mage.Sets/src/mage/sets/magic2012/AvenFleetwing.java b/Mage.Sets/src/mage/sets/magic2012/AvenFleetwing.java index 3e46c93e54..10a267b7c8 100644 --- a/Mage.Sets/src/mage/sets/magic2012/AvenFleetwing.java +++ b/Mage.Sets/src/mage/sets/magic2012/AvenFleetwing.java @@ -51,7 +51,7 @@ public class AvenFleetwing extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); this.addAbility(FlyingAbility.getInstance()); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); } public AvenFleetwing(final AvenFleetwing card) { diff --git a/Mage.Sets/src/mage/sets/magic2012/DungroveElder.java b/Mage.Sets/src/mage/sets/magic2012/DungroveElder.java index 743155bb58..2120535a61 100644 --- a/Mage.Sets/src/mage/sets/magic2012/DungroveElder.java +++ b/Mage.Sets/src/mage/sets/magic2012/DungroveElder.java @@ -63,7 +63,7 @@ public class DungroveElder extends CardImpl { this.power = new MageInt(0); this.toughness = new MageInt(0); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(filterLands), Duration.EndOfGame))); } diff --git a/Mage.Sets/src/mage/sets/magic2012/GladecoverScout.java b/Mage.Sets/src/mage/sets/magic2012/GladecoverScout.java index 595488f6f1..bd20bde10c 100644 --- a/Mage.Sets/src/mage/sets/magic2012/GladecoverScout.java +++ b/Mage.Sets/src/mage/sets/magic2012/GladecoverScout.java @@ -49,7 +49,7 @@ public class GladecoverScout extends CardImpl { this.color.setGreen(true); this.power = new MageInt(1); this.toughness = new MageInt(1); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); } public GladecoverScout(final GladecoverScout card) { diff --git a/Mage.Sets/src/mage/sets/magic2012/LordOfTheUnreal.java b/Mage.Sets/src/mage/sets/magic2012/LordOfTheUnreal.java index 75f9782578..d1ec5d001c 100644 --- a/Mage.Sets/src/mage/sets/magic2012/LordOfTheUnreal.java +++ b/Mage.Sets/src/mage/sets/magic2012/LordOfTheUnreal.java @@ -64,7 +64,7 @@ public class LordOfTheUnreal extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); Ability ability = new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Constants.Duration.WhileOnBattlefield, filter, false)); - ability.addEffect(new GainAbilityControlledEffect(new HexproofAbility(), Constants.Duration.WhileOnBattlefield, filter, false)); + ability.addEffect(new GainAbilityControlledEffect(HexproofAbility.getInstance(), Constants.Duration.WhileOnBattlefield, filter, false)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/magic2012/SwiftfootBoots.java b/Mage.Sets/src/mage/sets/magic2012/SwiftfootBoots.java index afd1a6048c..f8432e2138 100644 --- a/Mage.Sets/src/mage/sets/magic2012/SwiftfootBoots.java +++ b/Mage.Sets/src/mage/sets/magic2012/SwiftfootBoots.java @@ -52,7 +52,7 @@ public class SwiftfootBoots extends CardImpl { super(ownerId, 219, "Swiftfoot Boots", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "M12"; this.subtype.add("Equipment"); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new HexproofAbility(), Constants.AttachmentType.EQUIPMENT))); + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(HexproofAbility.getInstance(), Constants.AttachmentType.EQUIPMENT))); this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(HasteAbility.getInstance(), Constants.AttachmentType.EQUIPMENT))); this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(1))); diff --git a/Mage.Sets/src/mage/sets/mirrodin/LeoninAbunas.java b/Mage.Sets/src/mage/sets/mirrodin/LeoninAbunas.java index 6bb775a45b..bc39581a56 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/LeoninAbunas.java +++ b/Mage.Sets/src/mage/sets/mirrodin/LeoninAbunas.java @@ -58,7 +58,7 @@ public class LeoninAbunas extends CardImpl { this.color.setWhite(true); this.power = new MageInt(2); this.toughness = new MageInt(5); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityControlledEffect(new HexproofAbility(), Constants.Duration.WhileOnBattlefield, filter, false))); + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityControlledEffect(HexproofAbility.getInstance(), Constants.Duration.WhileOnBattlefield, filter, false))); } public LeoninAbunas(final LeoninAbunas card) { diff --git a/Mage.Sets/src/mage/sets/mirrodin/PlatedSlagwurm.java b/Mage.Sets/src/mage/sets/mirrodin/PlatedSlagwurm.java index 73229bd139..38d6929af9 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/PlatedSlagwurm.java +++ b/Mage.Sets/src/mage/sets/mirrodin/PlatedSlagwurm.java @@ -49,7 +49,7 @@ public class PlatedSlagwurm extends CardImpl { this.power = new MageInt(8); this.toughness = new MageInt(8); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); } public PlatedSlagwurm(final PlatedSlagwurm card) { diff --git a/Mage.Sets/src/mage/sets/mirrodin/TrollAscetic.java b/Mage.Sets/src/mage/sets/mirrodin/TrollAscetic.java index 2dc6cfe48e..ce854b6259 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/TrollAscetic.java +++ b/Mage.Sets/src/mage/sets/mirrodin/TrollAscetic.java @@ -56,7 +56,7 @@ public class TrollAscetic extends CardImpl { this.color.setGreen(true); this.power = new MageInt(3); this.toughness = new MageInt(2); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{1}{G}"))); } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/ThrunTheLastTroll.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/ThrunTheLastTroll.java index 949422ba50..7b6301987f 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/ThrunTheLastTroll.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/ThrunTheLastTroll.java @@ -59,7 +59,7 @@ public class ThrunTheLastTroll extends CardImpl { this.toughness = new MageInt(4); this.addAbility(new SimpleStaticAbility(Zone.ALL, new CantCounterSourceEffect())); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{1}{G}"))); } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/DroveOfElves.java b/Mage.Sets/src/mage/sets/shadowmoor/DroveOfElves.java index 7472368603..c750720eb4 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/DroveOfElves.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/DroveOfElves.java @@ -62,7 +62,7 @@ public class DroveOfElves extends CardImpl { this.power = new MageInt(0); this.toughness = new MageInt(0); - this.addAbility(new HexproofAbility()); + this.addAbility(HexproofAbility.getInstance()); // Drove of Elves's power and toughness are each equal to the number of green permanents you control. this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(filter), Duration.WhileOnBattlefield))); } diff --git a/Mage.Sets/src/mage/sets/zendikar/VinesOfVastwood.java b/Mage.Sets/src/mage/sets/zendikar/VinesOfVastwood.java index ad7bd81692..dd6ce6e81b 100644 --- a/Mage.Sets/src/mage/sets/zendikar/VinesOfVastwood.java +++ b/Mage.Sets/src/mage/sets/zendikar/VinesOfVastwood.java @@ -55,7 +55,7 @@ public class VinesOfVastwood extends CardImpl { this.color.setGreen(true); TargetCreaturePermanent target = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(target); - this.getSpellAbility().addEffect(new GainAbilityTargetEffect(new HexproofAbility(), Duration.EndOfTurn)); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(HexproofAbility.getInstance(), Duration.EndOfTurn)); this.getSpellAbility().addOptionalCost(new KickerManaCost("{G}")); this.getSpellAbility().addEffect(new ConditionalContinousEffect(new BoostTargetEffect(4, 4, Duration.EndOfTurn), diff --git a/Mage/src/mage/abilities/keyword/HexproofAbility.java b/Mage/src/mage/abilities/keyword/HexproofAbility.java index 216d4fee28..0427610dda 100644 --- a/Mage/src/mage/abilities/keyword/HexproofAbility.java +++ b/Mage/src/mage/abilities/keyword/HexproofAbility.java @@ -1,5 +1,6 @@ package mage.abilities.keyword; +import java.io.ObjectStreamException; import mage.Constants; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.CantTargetSourceEffect; @@ -7,28 +8,29 @@ import mage.filter.FilterStackObject; /** * Hexproof - * (This creature can't be the target of spells or abilities your opponents control.) + * (This creature or player can't be the target of spells or abilities your opponents control.) * * @author loki */ public class HexproofAbility extends SimpleStaticAbility { - private static final FilterStackObject filter = new FilterStackObject("spells or abilities your opponents control"); - static { - filter.setTargetController(Constants.TargetController.OPPONENT); + private static final HexproofAbility fINSTANCE = new HexproofAbility(); + + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; } - public HexproofAbility() { - super(Constants.Zone.BATTLEFIELD, new CantTargetSourceEffect(filter, Constants.Duration.WhileOnBattlefield)); - } + public static HexproofAbility getInstance() { + return fINSTANCE; + } - public HexproofAbility(final HexproofAbility ability) { - super(ability); + private HexproofAbility() { + super(Constants.Zone.BATTLEFIELD, new CantTargetSourceEffect(new FilterStackObject("spells or abilities your opponents control"), Constants.Duration.WhileOnBattlefield)); } @Override - public SimpleStaticAbility copy() { - return new HexproofAbility(this); + public HexproofAbility copy() { + return fINSTANCE; } @Override