From 6321e39bcdb54201d462b1c2671eb24ff8bcccca Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 9 Feb 2016 00:06:17 +0100 Subject: [PATCH] [SOI] Added Skulk Ability. --- .../mage/sets/lorwyn/GoldmeadowDodger.java | 6 +- .../CantBeBlockedByCreaturesSourceEffect.java | 13 +--- .../mage/abilities/keyword/SkulkAbility.java | 68 +++++++++++++++++++ 3 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/keyword/SkulkAbility.java diff --git a/Mage.Sets/src/mage/sets/lorwyn/GoldmeadowDodger.java b/Mage.Sets/src/mage/sets/lorwyn/GoldmeadowDodger.java index 802b0fda7ec..0dc9667d7a8 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/GoldmeadowDodger.java +++ b/Mage.Sets/src/mage/sets/lorwyn/GoldmeadowDodger.java @@ -45,10 +45,10 @@ import mage.filter.predicate.mageobject.PowerPredicate; */ public class GoldmeadowDodger extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 4 or greater"); + private static final FilterCreaturePermanent FILTER = new FilterCreaturePermanent("creatures with power 4 or greater"); static { - filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 3)); + FILTER.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 3)); } public GoldmeadowDodger(UUID ownerId) { @@ -60,7 +60,7 @@ public class GoldmeadowDodger extends CardImpl { this.toughness = new MageInt(1); // Goldmeadow Dodger can't be blocked by creatures with power 4 or greater. - this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); + this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(FILTER, Duration.WhileOnBattlefield))); } public GoldmeadowDodger(final GoldmeadowDodger card) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java index 8935b24e43b..5eef7700c9e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java @@ -38,7 +38,6 @@ import mage.game.permanent.Permanent; * * @author LevelX2 */ - public class CantBeBlockedByCreaturesSourceEffect extends RestrictionEffect { private final FilterCreaturePermanent filter; @@ -47,7 +46,7 @@ public class CantBeBlockedByCreaturesSourceEffect extends RestrictionEffect { super(duration); this.filter = filter; staticText = new StringBuilder("{this} can't be blocked ") - .append(filter.getMessage().startsWith("except by") ? "":"by ").append(filter.getMessage()).toString(); + .append(filter.getMessage().startsWith("except by") ? "" : "by ").append(filter.getMessage()).toString(); } public CantBeBlockedByCreaturesSourceEffect(final CantBeBlockedByCreaturesSourceEffect effect) { @@ -57,18 +56,12 @@ public class CantBeBlockedByCreaturesSourceEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getId().equals(source.getSourceId())) { - return true; - } - return false; + return permanent.getId().equals(source.getSourceId()); } @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - if (filter.match(blocker, source.getSourceId(), source.getControllerId(), game)) { - return false; - } - return true; + return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game); } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/SkulkAbility.java b/Mage/src/main/java/mage/abilities/keyword/SkulkAbility.java new file mode 100644 index 00000000000..d23e521637d --- /dev/null +++ b/Mage/src/main/java/mage/abilities/keyword/SkulkAbility.java @@ -0,0 +1,68 @@ +/* + * 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 mage.abilities.Ability; +import mage.abilities.StaticAbility; +import mage.abilities.effects.RestrictionEffect; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class SkulkAbility extends StaticAbility { + + public SkulkAbility() { + super(Zone.BATTLEFIELD, new SkulkEffect(Duration.WhileOnBattlefield)); + } + + public SkulkAbility(final SkulkAbility ability) { + super(ability); + } + + @Override + public Ability copy() { + return new SkulkAbility(this); + } + + @Override + public String getRule() { + return "Skulk (This creature can't be blocked by creatures with greater power.)"; + } + +} + +class SkulkEffect extends RestrictionEffect { + + public SkulkEffect(Duration duration) { + super(duration); + staticText = "Skulk (This creature can't be blocked by creatures with greater power.)"; + } + + public SkulkEffect(final SkulkEffect effect) { + super(effect); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + return !permanent.getControllerId().equals(source.getControllerId()); + } + + @Override + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { + return blocker.getId().equals(source.getSourceId()) + && blocker.getPower().getValue() >= attacker.getPower().getValue(); + } + + @Override + public SkulkEffect copy() { + return new SkulkEffect(this); + } +}