made Hexproof a singleton

This commit is contained in:
BetaSteward 2011-10-07 12:24:44 -04:00
parent a629d9ea12
commit 9f922c6a2a
20 changed files with 32 additions and 36 deletions

View file

@ -50,7 +50,7 @@ public class SlipperyBogle extends CardImpl<SlipperyBogle> {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
this.addAbility(new HexproofAbility());
this.addAbility(HexproofAbility.getInstance());
}
public SlipperyBogle(final SlipperyBogle card) {

View file

@ -68,7 +68,7 @@ public class AngelicOverseer extends CardImpl<AngelicOverseer> {
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);
}

View file

@ -64,7 +64,7 @@ public class GeistOfSaintTraft extends CardImpl<GeistOfSaintTraft> {
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));
}

View file

@ -51,7 +51,7 @@ public class InvisibleStalker extends CardImpl<InvisibleStalker> {
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());
}

View file

@ -52,7 +52,7 @@ public class Lumberknot extends CardImpl<Lumberknot> {
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));
}

View file

@ -54,7 +54,7 @@ public class MaskOfAvacyn extends CardImpl<MaskOfAvacyn> {
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)));
}

View file

@ -52,7 +52,7 @@ public class RangersGuile extends CardImpl<RangersGuile> {
// 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) {

View file

@ -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<SacredWolf> {
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) {

View file

@ -51,7 +51,7 @@ public class AvenFleetwing extends CardImpl<AvenFleetwing> {
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) {

View file

@ -63,7 +63,7 @@ public class DungroveElder extends CardImpl<DungroveElder> {
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)));
}

View file

@ -49,7 +49,7 @@ public class GladecoverScout extends CardImpl<GladecoverScout> {
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) {

View file

@ -64,7 +64,7 @@ public class LordOfTheUnreal extends CardImpl<LordOfTheUnreal> {
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);
}

View file

@ -52,7 +52,7 @@ public class SwiftfootBoots extends CardImpl<SwiftfootBoots> {
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)));

View file

@ -58,7 +58,7 @@ public class LeoninAbunas extends CardImpl<LeoninAbunas> {
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) {

View file

@ -49,7 +49,7 @@ public class PlatedSlagwurm extends CardImpl<PlatedSlagwurm> {
this.power = new MageInt(8);
this.toughness = new MageInt(8);
this.addAbility(new HexproofAbility());
this.addAbility(HexproofAbility.getInstance());
}
public PlatedSlagwurm(final PlatedSlagwurm card) {

View file

@ -56,7 +56,7 @@ public class TrollAscetic extends CardImpl<TrollAscetic> {
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}")));
}

View file

@ -59,7 +59,7 @@ public class ThrunTheLastTroll extends CardImpl<ThrunTheLastTroll> {
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}")));
}

View file

@ -62,7 +62,7 @@ public class DroveOfElves extends CardImpl<DroveOfElves> {
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)));
}

View file

@ -55,7 +55,7 @@ public class VinesOfVastwood extends CardImpl<VinesOfVastwood> {
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),

View file

@ -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