mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
[refactoring] CantBlockAbility isn't Singleton anymore
This commit is contained in:
parent
d71c8c0287
commit
7e3944ef66
23 changed files with 57 additions and 71 deletions
|
@ -51,7 +51,7 @@ public class NezumiCutthroat extends CardImpl<NezumiCutthroat> {
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
this.addAbility(FearAbility.getInstance());
|
this.addAbility(FearAbility.getInstance());
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public NezumiCutthroat(final NezumiCutthroat card) {
|
public NezumiCutthroat(final NezumiCutthroat card) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class VillainousOgre extends CardImpl<VillainousOgre> {
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(2);
|
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.
|
// As long as you control a Demon, Villainous Ogre has "{B}: Regenerate Villainous Ogre.
|
||||||
this.addAbility( new ConditionalActivatedAbility(
|
this.addAbility( new ConditionalActivatedAbility(
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ShamblingRemains extends CardImpl<ShamblingRemains> {
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
// Shambling Remains can't block.
|
// Shambling Remains can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
// Unearth {B}{R}
|
// Unearth {B}{R}
|
||||||
this.addAbility(new UnearthAbility(new ManaCostsImpl("{B}{R}")));
|
this.addAbility(new UnearthAbility(new ManaCostsImpl("{B}{R}")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class Gravecrawler extends CardImpl<Gravecrawler> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Gravecrawler can't block.
|
// 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.
|
// You may cast Gravecrawler from your graveyard as long as you control a Zombie.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new GravecrawlerPlayEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.ALL, new GravecrawlerPlayEffect()));
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SightlessGhoul extends CardImpl<SightlessGhoul> {
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
// Sightless Ghoul can't block.
|
// Sightless Ghoul can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
// Undying
|
// Undying
|
||||||
this.addAbility(new UndyingAbility());
|
this.addAbility(new UndyingAbility());
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class UnhallowedCathar extends CardImpl<UnhallowedCathar> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Unhallowed Cathar can't block.
|
// Unhallowed Cathar can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnhallowedCathar(final UnhallowedCathar card) {
|
public UnhallowedCathar(final UnhallowedCathar card) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ScavengingScarab extends CardImpl<ScavengingScarab> {
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScavengingScarab(final ScavengingScarab card) {
|
public ScavengingScarab(final ScavengingScarab card) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class DaggerclawImp extends CardImpl<DaggerclawImp> {
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DaggerclawImp (final DaggerclawImp card) {
|
public DaggerclawImp (final DaggerclawImp card) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class VampireInterloper extends CardImpl<VampireInterloper> {
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
// Vampire Interloper can't block.
|
// Vampire Interloper can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public VampireInterloper(final VampireInterloper card) {
|
public VampireInterloper(final VampireInterloper card) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class NightshadeStinger extends CardImpl<NightshadeStinger> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
// Nightshade Stinger can't block.
|
// Nightshade Stinger can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public NightshadeStinger(final NightshadeStinger card) {
|
public NightshadeStinger(final NightshadeStinger card) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class TormentedSoul extends CardImpl<TormentedSoul> {
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
this.addAbility(new UnblockableAbility());
|
this.addAbility(new UnblockableAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class VeilbornGhoul extends CardImpl<VeilbornGhoul> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Veilborn Ghoul can't block.
|
// 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.
|
// Whenever a Swamp enters the battlefield under your control, you may return Veilborn Ghoul from your graveyard to your hand.
|
||||||
this.addAbility(new VeilbornGhoulTriggeredAbility());
|
this.addAbility(new VeilbornGhoulTriggeredAbility());
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class CarrionFeeder extends CardImpl<CarrionFeeder> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Carrion Feeder can't block.
|
// Carrion Feeder can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
// Sacrifice a creature: Put a +1/+1 counter on Carrion Feeder.
|
// Sacrifice a creature: Put a +1/+1 counter on Carrion Feeder.
|
||||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||||
new AddCountersSourceEffect(CounterType.P1P1.createInstance()),
|
new AddCountersSourceEffect(CounterType.P1P1.createInstance()),
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class AshenmoorGouger extends CardImpl<AshenmoorGouger> {
|
||||||
this.power = new MageInt(4);
|
this.power = new MageInt(4);
|
||||||
this.toughness = new MageInt(4);
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AshenmoorGouger(final AshenmoorGouger card) {
|
public AshenmoorGouger(final AshenmoorGouger card) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class InkfathomInfiltrator extends CardImpl<InkfathomInfiltrator> {
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
this.addAbility(new UnblockableAbility());
|
this.addAbility(new UnblockableAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SpinelessThug extends CardImpl<SpinelessThug> {
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpinelessThug(final SpinelessThug card) {
|
public SpinelessThug(final SpinelessThug card) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class PygmyPyrosaur extends CardImpl<PygmyPyrosaur> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Pygmy Pyrosaur can't block.
|
// Pygmy Pyrosaur can't block.
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
// {R}: Pygmy Pyrosaur gets +1/+0 until end of turn.
|
// {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}")));
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{R}")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class BojukaBrigand extends CardImpl<BojukaBrigand> {
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = 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));
|
this.addAbility(new AllyEntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class Bloodghast extends CardImpl<Bloodghast> {
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
this.addAbility(new LandfallAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(), true));
|
this.addAbility(new LandfallAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(), true));
|
||||||
ContinuousEffect effect = new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield);
|
ContinuousEffect effect = new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield);
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinousEffect(effect,
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinousEffect(effect,
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class HagraCrocodile extends CardImpl<HagraCrocodile> {
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
this.addAbility(CantBlockAbility.getInstance());
|
this.addAbility(new CantBlockAbility());
|
||||||
this.addAbility(new LandfallAbility(new BoostSourceEffect(2, 2, Duration.EndOfTurn), false));
|
this.addAbility(new LandfallAbility(new BoostSourceEffect(2, 2, Duration.EndOfTurn), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,48 @@
|
||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package mage.abilities.common;
|
||||||
|
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.effects.common.CantBlockSourceEffect;
|
||||||
import mage.abilities.MageSingleton;
|
|
||||||
import mage.abilities.effects.RestrictionEffect;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author maurer.it_at_gmail.com
|
* @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();
|
public CantBlockAbility() {
|
||||||
|
super(Zone.BATTLEFIELD, new CantBlockSourceEffect(Duration.WhileOnBattlefield));
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
return fINSTANCE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CantBlockAbility getInstance() {
|
private CantBlockAbility(CantBlockAbility ability) {
|
||||||
return fINSTANCE;
|
super(ability);
|
||||||
}
|
|
||||||
|
|
||||||
private CantBlockAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new CantBlockEffect());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,34 +52,6 @@ public class CantBlockAbility extends SimpleStaticAbility implements MageSinglet
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CantBlockAbility copy() {
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,10 @@ public class CantBlockSourceEffect extends RestrictionEffect<CantBlockSourceEffe
|
||||||
|
|
||||||
public CantBlockSourceEffect(Duration duration) {
|
public CantBlockSourceEffect(Duration duration) {
|
||||||
super(duration);
|
super(duration);
|
||||||
|
this.staticText = "{this} can't block";
|
||||||
|
if (duration.equals(Duration.EndOfTurn)) {
|
||||||
|
this.staticText += " this turn";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CantBlockSourceEffect(final CantBlockSourceEffect effect) {
|
public CantBlockSourceEffect(final CantBlockSourceEffect effect) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ Plainswalk|new|
|
||||||
Rebound|new|
|
Rebound|new|
|
||||||
Swampwalk|new|
|
Swampwalk|new|
|
||||||
Totem armor|new|
|
Totem armor|new|
|
||||||
|
Unblockable|new|
|
||||||
Undying|new|
|
Undying|new|
|
||||||
Deathtouch|instance|
|
Deathtouch|instance|
|
||||||
Defender|instance|
|
Defender|instance|
|
||||||
|
@ -40,6 +41,5 @@ Scavenge|cost|
|
||||||
Shroud|instance|
|
Shroud|instance|
|
||||||
Soulbond|instance|
|
Soulbond|instance|
|
||||||
Trample|instance|
|
Trample|instance|
|
||||||
Unblockable|instance|
|
|
||||||
Vigilance|instance|
|
Vigilance|instance|
|
||||||
Wither|instance|
|
Wither|instance|
|
Loading…
Reference in a new issue