Added UnblockableSourceEffect; Unblockable isn't Singleton anymore

This commit is contained in:
North 2012-09-07 00:38:24 +03:00
parent c0e4e7a431
commit 7e5b677647
26 changed files with 178 additions and 151 deletions

View file

@ -32,7 +32,7 @@ public class MagicAbility {
put(ShroudAbility.getInstance().getRule(), 60);
put(new SwampwalkAbility().getRule(), 10);
put(TrampleAbility.getInstance().getRule(), 30);
put(UnblockableAbility.getInstance().getRule(), 100);
put(new UnblockableAbility().getRule(), 100);
put(VigilanceAbility.getInstance().getRule(), 20);
put(WitherAbility.getInstance().getRule(), 30);
}};

View file

@ -28,17 +28,16 @@
package mage.sets.alarareborn;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.CyclingAbility;
import mage.abilities.keyword.UnblockableAbility;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -78,8 +77,8 @@ public class GlassdustHulk extends CardImpl<GlassdustHulk> {
class GlassdustHulkTriggeredAbility extends TriggeredAbilityImpl<GlassdustHulkTriggeredAbility> {
GlassdustHulkTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new BoostSourceEffect(1, 1, Constants.Duration.EndOfTurn));
this.addEffect(new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Constants.Duration.EndOfTurn));
super(Zone.BATTLEFIELD, new BoostSourceEffect(1, 1, Duration.EndOfTurn));
this.addEffect(new UnblockableSourceEffect(Duration.EndOfTurn));
}
GlassdustHulkTriggeredAbility(final GlassdustHulkTriggeredAbility ability) {
@ -95,7 +94,7 @@ class GlassdustHulkTriggeredAbility extends TriggeredAbilityImpl<GlassdustHulkTr
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && !event.getTargetId().equals(this.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getToZone() == Constants.Zone.BATTLEFIELD) {
if (zEvent.getToZone() == Zone.BATTLEFIELD) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getCardType().contains(CardType.ARTIFACT)
&& permanent.getControllerId().equals(this.controllerId)) {

View file

@ -50,7 +50,7 @@ public class LatchSeeker extends CardImpl<LatchSeeker> {
this.toughness = new MageInt(1);
// Latch Seeker is unblockable.
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
public LatchSeeker(final LatchSeeker card) {

View file

@ -37,9 +37,8 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.cards.CardImpl;
/**
@ -56,9 +55,13 @@ public class VectisAgents extends CardImpl<VectisAgents> {
this.subtype.add("Human");
this.subtype.add("Rogue");
this.power = new MageInt(4);
this.toughness = new MageInt(3);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(-2, -0, Duration.EndOfTurn), new ManaCostsImpl("{U}{B}"));
ability.addEffect(new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Duration.EndOfTurn));
this.toughness = new MageInt(3);
// {U}{B}: Vectis Agents gets -2/-0 until end of turn and is unblockable this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new BoostSourceEffect(-2, -0, Duration.EndOfTurn),
new ManaCostsImpl("{U}{B}"));
ability.addEffect(new UnblockableSourceEffect(Duration.EndOfTurn));
this.addAbility(ability);
}

View file

@ -30,16 +30,16 @@ package mage.sets.darksteel;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.BlocksTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
@ -54,8 +54,13 @@ public class Spincrusher extends CardImpl<Spincrusher> {
this.subtype.add("Construct");
this.power = new MageInt(0);
this.toughness = new MageInt(2);
// Whenever Spincrusher blocks, put a +1/+1 counter on it.
this.addAbility(new BlocksTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false));
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Constants.Duration.EndOfTurn), new RemoveCountersSourceCost(CounterType.P1P1.createInstance(1))));
// Remove a +1/+1 counter from Spincrusher: Spincrusher is unblockable this turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new UnblockableSourceEffect(Duration.EndOfTurn),
new RemoveCountersSourceCost(CounterType.P1P1.createInstance(1))));
}
public Spincrusher(final Spincrusher card) {

View file

@ -53,7 +53,7 @@ public class InvisibleStalker extends CardImpl<InvisibleStalker> {
this.addAbility(HexproofAbility.getInstance());
// Invisible Stalker is unblockable.
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
public InvisibleStalker(final InvisibleStalker card) {

View file

@ -48,7 +48,7 @@ public class PhantomWarrior extends CardImpl<PhantomWarrior> {
this.color.setBlue(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
public PhantomWarrior(final PhantomWarrior card) {

View file

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

View file

@ -28,19 +28,18 @@
package mage.sets.magic2013;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.ControlsPermanentCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -70,10 +69,12 @@ public class HarborBandit extends CardImpl<HarborBandit> {
// Harbor Bandit gets +1/+1 as long as you control an Island.
ConditionalContinousEffect effect = new ConditionalContinousEffect(new BoostSourceEffect(1, 1, Duration.WhileOnBattlefield), new ControlsPermanentCondition(filter), rule);
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// {1}{U}: Harbor Bandit is unblockable this turn.
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{1}{U}")));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new UnblockableSourceEffect(Duration.EndOfTurn),
new ManaCostsImpl("{1}{U}")));
}
public HarborBandit(final HarborBandit card) {

View file

@ -28,21 +28,21 @@
package mage.sets.mirrodin;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
@ -52,7 +52,6 @@ import mage.game.Game;
*/
public class NeurokSpy extends CardImpl<NeurokSpy> {
private static final String text = "Neurok Spy is unblockable as long as defending player controls an artifact";
private static final FilterPermanent filter = new FilterPermanent();
static {
@ -81,9 +80,10 @@ public class NeurokSpy extends CardImpl<NeurokSpy> {
this.toughness = new MageInt(2);
//Neurok Spy is unblockable as long as defending player controls an artifact.
ContinuousEffect gainAbility = new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Constants.Duration.WhileOnBattlefield);
Effect effect = new ConditionalContinousEffect(gainAbility, new DefendingPlayerControlsArtifact(), text);
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
Effect effect = new ConditionalContinousEffect(new UnblockableSourceEffect(),
new DefendingPlayerControlsArtifact(),
"Neurok Spy is unblockable as long as defending player controls an artifact");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public NeurokSpy(final NeurokSpy card) {

View file

@ -52,7 +52,7 @@ public class BlightedAgent extends CardImpl<BlightedAgent> {
this.toughness = new MageInt(1);
this.addAbility(InfectAbility.getInstance());
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
public BlightedAgent(final BlightedAgent card) {

View file

@ -36,8 +36,7 @@ import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.PhyrexianManaCost;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.cards.CardImpl;
/**
@ -54,8 +53,9 @@ public class TrespassingSouleater extends CardImpl<TrespassingSouleater> {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// {UP}: Trespassing Souleater is unblockable this turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Duration.EndOfTurn),
new UnblockableSourceEffect(Duration.EndOfTurn),
new PhyrexianManaCost(ColoredManaSymbol.U)));
}

View file

@ -52,7 +52,7 @@ public class DimirInfiltrator extends CardImpl<DimirInfiltrator> {
this.toughness = new MageInt(3);
// Dimir Infiltrator is unblockable.
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
// Transmute {1}{U}{B}
this.addAbility(new TransmuteAbility("{1}{U}{B}"));
}

View file

@ -56,7 +56,7 @@ public class HuntedPhantasm extends CardImpl<HuntedPhantasm> {
this.toughness = new MageInt(6);
// Hunted Phantasm is unblockable.
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
// When Hunted Phantasm enters the battlefield, put five 1/1 red Goblin creature tokens onto the battlefield under target opponent's control.
Ability ability = new EntersBattlefieldTriggeredAbility(new CreateTokenTargetEffect(new GoblinToken(), 5), false);
Target target = new TargetOpponent();

View file

@ -61,10 +61,10 @@ public class HadaSpyPatrol extends LevelerCard<HadaSpyPatrol> {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{U}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
abilities1.add(UnblockableAbility.getInstance());
abilities1.add(new UnblockableAbility());
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
abilities2.add(UnblockableAbility.getInstance());
abilities2.add(new UnblockableAbility());
abilities2.add(ShroudAbility.getInstance());
LevelerCardBuilder.construct(this,

View file

@ -55,7 +55,7 @@ public class NeurokInvisimancer extends CardImpl<NeurokInvisimancer> {
this.toughness = new MageInt(1);
// Neurok Invisimancer is unblockable.
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
// When Neurok Invisimancer enters the battlefield, target creature is unblockable this turn.
Ability ability = new EntersBattlefieldTriggeredAbility(new UnblockableTargetEffect());
ability.addTarget(new TargetCreaturePermanent());

View file

@ -32,7 +32,9 @@ import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -40,8 +42,7 @@ import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -53,8 +54,6 @@ import mage.game.Game;
*/
public class ScrapdiverSerpent extends CardImpl<ScrapdiverSerpent> {
private static final String rule = "Scrapdiver Serpent is unblockable as long as defending player controls an artifact";
private static final FilterPermanent filter = new FilterPermanent();
static {
@ -79,9 +78,12 @@ public class ScrapdiverSerpent extends CardImpl<ScrapdiverSerpent> {
this.color.setBlue(true);
this.power = new MageInt(5);
this.toughness = new MageInt(5);
ContinuousEffect gainAbility = new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Constants.Duration.WhileOnBattlefield);
Effect effect = new ConditionalContinousEffect(gainAbility, new DefendingPlayerControlsArtifact(), rule);
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
// Scrapdiver Serpent is unblockable as long as defending player controls an artifact
Effect effect = new ConditionalContinousEffect(new UnblockableSourceEffect(Duration.WhileOnBattlefield),
new DefendingPlayerControlsArtifact(),
"{this} is unblockable as long as defending player controls an artifact");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public ScrapdiverSerpent (final ScrapdiverSerpent card) {

View file

@ -53,7 +53,7 @@ public class InkfathomInfiltrator extends CardImpl<InkfathomInfiltrator> {
this.toughness = new MageInt(1);
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
public InkfathomInfiltrator(final InkfathomInfiltrator card) {

View file

@ -50,7 +50,7 @@ public class JhessianInfiltrator extends CardImpl<JhessianInfiltrator> {
this.color.setBlue(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
public JhessianInfiltrator (final JhessianInfiltrator card) {

View file

@ -36,10 +36,8 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -51,7 +49,6 @@ import mage.game.Game;
*/
public class BubblingBeebles extends CardImpl<BubblingBeebles> {
private static final String rule = "{this} is unblockable as long as defending player controls an enchantment";
private static final FilterPermanent filter = new FilterPermanent();
static {
@ -79,8 +76,9 @@ public class BubblingBeebles extends CardImpl<BubblingBeebles> {
this.toughness = new MageInt(3);
// Bubbling Beebles is unblockable as long as defending player controls an enchantment.
ContinuousEffect gainAbility = new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Constants.Duration.WhileOnBattlefield);
Effect effect = new ConditionalContinousEffect(gainAbility, new DefendingPlayerControlsEnchantment(), rule);
Effect effect = new ConditionalContinousEffect(new UnblockableSourceEffect(Constants.Duration.WhileOnBattlefield),
new DefendingPlayerControlsEnchantment(),
"{this} is unblockable as long as defending player controls an enchantment");
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
}

View file

@ -32,15 +32,14 @@ import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.UnblockableAbility;
import mage.abilities.effects.common.UnblockableSourceEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -52,7 +51,6 @@ import mage.game.Game;
*/
public class BouncingBeebles extends CardImpl<BouncingBeebles> {
private static final String rule = "Bouncing Beebles is unblockable as long as defending player controls an artifact";
private static final FilterPermanent filter = new FilterPermanent();
static {
@ -80,9 +78,10 @@ public class BouncingBeebles extends CardImpl<BouncingBeebles> {
this.toughness = new MageInt(2);
//Bouncing Beebles is unblockable as long as defending player controls an artifact.
ContinuousEffect gainAbility = new GainAbilitySourceEffect(UnblockableAbility.getInstance(), Constants.Duration.WhileOnBattlefield);
Effect effect = new ConditionalContinousEffect(gainAbility, new DefendingPlayerControlsArtifact(), rule);
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
Effect effect = new ConditionalContinousEffect(new UnblockableSourceEffect(),
new DefendingPlayerControlsArtifact(),
"Neurok Spy is unblockable as long as defending player controls an artifact");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public BouncingBeebles(final BouncingBeebles card) {

View file

@ -79,6 +79,6 @@ class CreepingTarPitToken extends Token {
color.setBlack(true);
power = new MageInt(3);
toughness = new MageInt(2);
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
}
}

View file

@ -59,7 +59,7 @@ public class AetherFigment extends CardImpl<AetherFigment> {
this.toughness = new MageInt(1);
// AEther Figment is unblockable.
this.addAbility(UnblockableAbility.getInstance());
this.addAbility(new UnblockableAbility());
// Kicker {3}
this.getSpellAbility().addOptionalCost(new KickerManaCost("{3}"));

View file

@ -0,0 +1,71 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.Constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class UnblockableSourceEffect extends RestrictionEffect<UnblockableSourceEffect> {
public UnblockableSourceEffect() {
this(Duration.WhileOnBattlefield);
}
public UnblockableSourceEffect(Duration duration) {
super(duration);
this.staticText = "{this} is unblockable";
if (Duration.EndOfTurn.equals(this.duration)) {
this.staticText += " this turn";
}
}
public UnblockableSourceEffect(UnblockableSourceEffect effect) {
super(effect);
}
@Override
public UnblockableSourceEffect copy() {
return new UnblockableSourceEffect(this);
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getId().equals(source.getSourceId());
}
}

View file

@ -1,100 +1,50 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import mage.Constants.Duration;
import mage.abilities.Ability;
import mage.abilities.EvasionAbility;
import mage.abilities.MageSingleton;
import mage.abilities.effects.RestrictionEffect;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.ObjectStreamException;
import mage.abilities.effects.common.UnblockableSourceEffect;
/**
* @author BetaSteward_at_googlemail.com
*/
public class UnblockableAbility extends EvasionAbility<UnblockableAbility> implements MageSingleton {
public class UnblockableAbility extends EvasionAbility<UnblockableAbility> {
private static final UnblockableAbility fINSTANCE = new UnblockableAbility();
private Object readResolve() throws ObjectStreamException {
return fINSTANCE;
public UnblockableAbility() {
this.addEffect(new UnblockableSourceEffect());
}
public static UnblockableAbility getInstance() {
return fINSTANCE;
}
private UnblockableAbility() {
this.addEffect(new UnblockableEffect());
}
@Override
public String getRule() {
return "Unblockable";
private UnblockableAbility(UnblockableAbility ability) {
super(ability);
}
@Override
public UnblockableAbility copy() {
return fINSTANCE;
return new UnblockableAbility(this);
}
}
class UnblockableEffect extends RestrictionEffect<UnblockableEffect> implements MageSingleton {
public UnblockableEffect() {
super(Duration.EndOfGame);
}
public UnblockableEffect(final UnblockableEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getAbilities().containsKey(UnblockableAbility.getInstance().getId())) {
return true;
}
return false;
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}
@Override
public UnblockableEffect copy() {
return new UnblockableEffect(this);
}
}

View file

@ -107,7 +107,6 @@ public class TraceUtil {
log.error(uuid);
log.error(uuid+"Flying ability id: " + FlyingAbility.getInstance().getId());
log.error(uuid+"Reach ability id: " + ReachAbility.getInstance().getId());
log.error(uuid+"Unblockable ability id: " + UnblockableAbility.getInstance().getId());
log.error(uuid);
log.error(uuid+"Restriction effects:");