From 54d5599e067871345e3e26fd697def66997f0d2a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 19 Oct 2016 23:24:02 +0200 Subject: [PATCH] [SWS] Fixed Exogorth's block ability. --- Mage.Sets/src/mage/cards/e/Exogorth.java | 43 ++----------------- .../keyword/CanBlockSpaceflightAbility.java | 43 +++++++++++++++++++ .../abilities/keyword/SpaceflightAbility.java | 3 +- 3 files changed, 49 insertions(+), 40 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/keyword/CanBlockSpaceflightAbility.java diff --git a/Mage.Sets/src/mage/cards/e/Exogorth.java b/Mage.Sets/src/mage/cards/e/Exogorth.java index 165f16787b..dcbe49f4ee 100644 --- a/Mage.Sets/src/mage/cards/e/Exogorth.java +++ b/Mage.Sets/src/mage/cards/e/Exogorth.java @@ -29,19 +29,12 @@ package mage.cards.e; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.RestrictionEffect; +import mage.abilities.keyword.CanBlockSpaceflightAbility; import mage.abilities.keyword.FlashAbility; -import mage.abilities.keyword.SpaceflightAbility; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -50,7 +43,7 @@ import mage.game.permanent.Permanent; public class Exogorth extends CardImpl { public Exogorth(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{G}"); this.subtype.add("Slug"); this.power = new MageInt(7); this.toughness = new MageInt(7); @@ -61,8 +54,8 @@ public class Exogorth extends CardImpl { // Trample this.addAbility(TrampleAbility.getInstance()); - // Exogorth can block only creatures with spaceflight. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockOnlySpaceflightEffect())); + // Exogorth can block creatures with spaceflight. + this.addAbility(CanBlockSpaceflightAbility.getInstance()); } public Exogorth(final Exogorth card) { @@ -74,31 +67,3 @@ public class Exogorth extends CardImpl { return new Exogorth(this); } } - -class CanBlockOnlySpaceflightEffect extends RestrictionEffect { - - public CanBlockOnlySpaceflightEffect() { - super(Duration.EndOfTurn); - this.staticText = "{this} can block only creatures with spaceflight"; - } - - public CanBlockOnlySpaceflightEffect(final CanBlockOnlySpaceflightEffect effect) { - super(effect); - } - - @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - return permanent.getId().equals(source.getSourceId()); - } - - @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { - return attacker.getAbilities().contains(SpaceflightAbility.getInstance()); - } - - @Override - public CanBlockOnlySpaceflightEffect copy() { - return new CanBlockOnlySpaceflightEffect(this); - } - -} diff --git a/Mage/src/main/java/mage/abilities/keyword/CanBlockSpaceflightAbility.java b/Mage/src/main/java/mage/abilities/keyword/CanBlockSpaceflightAbility.java new file mode 100644 index 0000000000..b65edc6129 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/keyword/CanBlockSpaceflightAbility.java @@ -0,0 +1,43 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.abilities.keyword; + +import java.io.ObjectStreamException; +import mage.abilities.MageSingleton; +import mage.abilities.StaticAbility; +import mage.constants.Zone; + +/** + * + * @author LevelX2 + */ +public class CanBlockSpaceflightAbility extends StaticAbility implements MageSingleton { + + private static final CanBlockSpaceflightAbility fINSTANCE = new CanBlockSpaceflightAbility(); + + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } + + public static CanBlockSpaceflightAbility getInstance() { + return fINSTANCE; + } + + private CanBlockSpaceflightAbility() { + super(Zone.ALL, null); + } + + @Override + public String getRule() { + return "{this} can block creatures with spaceflight."; + } + + @Override + public CanBlockSpaceflightAbility copy() { + return fINSTANCE; + } + +} diff --git a/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java b/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java index c0e080ad1a..f4a84542c0 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java @@ -90,7 +90,8 @@ class SpaceFlightEffect extends RestrictionEffect implements MageSingleton { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - return blocker.getAbilities().containsKey(SpaceflightAbility.getInstance().getId()); + return blocker.getAbilities().containsKey(SpaceflightAbility.getInstance().getId()) + || blocker.getAbilities().containsKey(CanBlockSpaceflightAbility.getInstance().getId()); } @Override