[refactoring] CantBlockAbility isn't Singleton anymore

This commit is contained in:
North 2012-09-07 10:50:07 +03:00
parent d71c8c0287
commit 7e3944ef66
23 changed files with 57 additions and 71 deletions

View file

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

View file

@ -64,7 +64,7 @@ public class VillainousOgre extends CardImpl<VillainousOgre> {
this.power = new MageInt(3);
this.toughness = new MageInt(2);
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// As long as you control a Demon, Villainous Ogre has "{B}: Regenerate Villainous Ogre.
this.addAbility( new ConditionalActivatedAbility(

View file

@ -54,7 +54,7 @@ public class ShamblingRemains extends CardImpl<ShamblingRemains> {
this.toughness = new MageInt(3);
// Shambling Remains can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// Unearth {B}{R}
this.addAbility(new UnearthAbility(new ManaCostsImpl("{B}{R}")));
}

View file

@ -60,7 +60,7 @@ public class Gravecrawler extends CardImpl<Gravecrawler> {
this.toughness = new MageInt(1);
// Gravecrawler can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// You may cast Gravecrawler from your graveyard as long as you control a Zombie.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new GravecrawlerPlayEffect()));

View file

@ -52,7 +52,7 @@ public class SightlessGhoul extends CardImpl<SightlessGhoul> {
this.toughness = new MageInt(2);
// Sightless Ghoul can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// Undying
this.addAbility(new UndyingAbility());
}

View file

@ -54,7 +54,7 @@ public class UnhallowedCathar extends CardImpl<UnhallowedCathar> {
this.toughness = new MageInt(1);
// Unhallowed Cathar can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
}
public UnhallowedCathar(final UnhallowedCathar card) {

View file

@ -48,7 +48,7 @@ public class ScavengingScarab extends CardImpl<ScavengingScarab> {
this.color.setBlack(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
}
public ScavengingScarab(final ScavengingScarab card) {

View file

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

View file

@ -54,7 +54,7 @@ public class VampireInterloper extends CardImpl<VampireInterloper> {
this.addAbility(FlyingAbility.getInstance());
// Vampire Interloper can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
}
public VampireInterloper(final VampireInterloper card) {

View file

@ -52,7 +52,7 @@ public class NightshadeStinger extends CardImpl<NightshadeStinger> {
this.toughness = new MageInt(1);
this.addAbility(FlyingAbility.getInstance());
// Nightshade Stinger can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
}
public NightshadeStinger(final NightshadeStinger card) {

View file

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

View file

@ -57,7 +57,7 @@ public class VeilbornGhoul extends CardImpl<VeilbornGhoul> {
this.toughness = new MageInt(1);
// Veilborn Ghoul can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// Whenever a Swamp enters the battlefield under your control, you may return Veilborn Ghoul from your graveyard to your hand.
this.addAbility(new VeilbornGhoulTriggeredAbility());

View file

@ -56,7 +56,7 @@ public class CarrionFeeder extends CardImpl<CarrionFeeder> {
this.toughness = new MageInt(1);
// Carrion Feeder can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// Sacrifice a creature: Put a +1/+1 counter on Carrion Feeder.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new AddCountersSourceEffect(CounterType.P1P1.createInstance()),

View file

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

View file

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

View file

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

View file

@ -55,7 +55,7 @@ public class PygmyPyrosaur extends CardImpl<PygmyPyrosaur> {
this.toughness = new MageInt(1);
// Pygmy Pyrosaur can't block.
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
// {R}: Pygmy Pyrosaur gets +1/+0 until end of turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{R}")));
}

View file

@ -54,7 +54,7 @@ public class BojukaBrigand extends CardImpl<BojukaBrigand> {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
this.addAbility(new AllyEntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), true));
}

View file

@ -60,7 +60,7 @@ public class Bloodghast extends CardImpl<Bloodghast> {
this.power = new MageInt(2);
this.toughness = new MageInt(1);
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
this.addAbility(new LandfallAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(), true));
ContinuousEffect effect = new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinousEffect(effect,

View file

@ -52,7 +52,7 @@ public class HagraCrocodile extends CardImpl<HagraCrocodile> {
this.power = new MageInt(3);
this.toughness = new MageInt(1);
this.addAbility(CantBlockAbility.getInstance());
this.addAbility(new CantBlockAbility());
this.addAbility(new LandfallAbility(new BoostSourceEffect(2, 2, Duration.EndOfTurn), false));
}

View file

@ -1,38 +1,48 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* 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.common;
import mage.Constants.Duration;
import mage.Constants.Zone;
import mage.abilities.Ability;
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.CantBlockSourceEffect;
/**
*
* @author maurer.it_at_gmail.com
*/
public class CantBlockAbility extends SimpleStaticAbility implements MageSingleton {
public class CantBlockAbility extends SimpleStaticAbility {
private static final CantBlockAbility fINSTANCE = new CantBlockAbility();
private Object readResolve() throws ObjectStreamException {
return fINSTANCE;
public CantBlockAbility() {
super(Zone.BATTLEFIELD, new CantBlockSourceEffect(Duration.WhileOnBattlefield));
}
public static CantBlockAbility getInstance() {
return fINSTANCE;
}
private CantBlockAbility() {
super(Zone.BATTLEFIELD, new CantBlockEffect());
private CantBlockAbility(CantBlockAbility ability) {
super(ability);
}
@Override
@ -42,34 +52,6 @@ public class CantBlockAbility extends SimpleStaticAbility implements MageSinglet
@Override
public CantBlockAbility copy() {
return fINSTANCE;
return new CantBlockAbility(this);
}
}
class CantBlockEffect extends RestrictionEffect<CantBlockEffect> implements MageSingleton {
public CantBlockEffect() {
super(Duration.EndOfGame);
}
public CantBlockEffect(final CantBlockEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getAbilities().containsKey(CantBlockAbility.getInstance().getId()) || source.getId().equals(CantBlockAbility.getInstance().getId());
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return !blocker.getAbilities().containsKey(CantBlockAbility.getInstance().getId());
}
@Override
public CantBlockEffect copy() {
return new CantBlockEffect(this);
}
}

View file

@ -42,6 +42,10 @@ public class CantBlockSourceEffect extends RestrictionEffect<CantBlockSourceEffe
public CantBlockSourceEffect(Duration duration) {
super(duration);
this.staticText = "{this} can't block";
if (duration.equals(Duration.EndOfTurn)) {
this.staticText += " this turn";
}
}
public CantBlockSourceEffect(final CantBlockSourceEffect effect) {

View file

@ -21,6 +21,7 @@ Plainswalk|new|
Rebound|new|
Swampwalk|new|
Totem armor|new|
Unblockable|new|
Undying|new|
Deathtouch|instance|
Defender|instance|
@ -40,6 +41,5 @@ Scavenge|cost|
Shroud|instance|
Soulbond|instance|
Trample|instance|
Unblockable|instance|
Vigilance|instance|
Wither|instance|