[SWS] Fixed Exogorth's block ability.

This commit is contained in:
LevelX2 2016-10-19 23:24:02 +02:00
parent 99fa296e37
commit 54d5599e06
3 changed files with 49 additions and 40 deletions

View file

@ -29,19 +29,12 @@ package mage.cards.e;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.keyword.CanBlockSpaceflightAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.keyword.FlashAbility; import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.SpaceflightAbility;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; 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 class Exogorth extends CardImpl {
public Exogorth(UUID ownerId, CardSetInfo setInfo) { 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.subtype.add("Slug");
this.power = new MageInt(7); this.power = new MageInt(7);
this.toughness = new MageInt(7); this.toughness = new MageInt(7);
@ -61,8 +54,8 @@ public class Exogorth extends CardImpl {
// Trample // Trample
this.addAbility(TrampleAbility.getInstance()); this.addAbility(TrampleAbility.getInstance());
// Exogorth can block only creatures with spaceflight. // Exogorth can block creatures with spaceflight.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockOnlySpaceflightEffect())); this.addAbility(CanBlockSpaceflightAbility.getInstance());
} }
public Exogorth(final Exogorth card) { public Exogorth(final Exogorth card) {
@ -74,31 +67,3 @@ public class Exogorth extends CardImpl {
return new Exogorth(this); 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);
}
}

View file

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

View file

@ -90,7 +90,8 @@ class SpaceFlightEffect extends RestrictionEffect implements MageSingleton {
@Override @Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { 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 @Override