From 0548ff746712e11853847010991db3151e5de1e1 Mon Sep 17 00:00:00 2001 From: "maurer.it" Date: Tue, 28 Dec 2010 23:40:48 -0500 Subject: [PATCH] Added TenOrLessLife condition which can be used for Zendikar Block vampires and should be usable with cards such as Convalescence, Lurking Jackals, Opal Avenger, etc, magiccards.info search: o:"10 or Less Life" Modified javadoc author on Controls condition. Added CantBlockAbility. Used with Bloodghast and can be used with cards such as Aesthir Glider, Ashenmoor Gouger, Auntie's Snitch, Bog Hoodlums, Bojuka Brigand, etc. magiccards.info search: o:"Can't Block" --- .../abilities/common/CantBlockAbility.java | 81 +++++++++++++++++++ .../abilities/condition/common/Controls.java | 2 +- .../condition/common/TenOrLessLife.java | 48 +++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 Mage/src/mage/abilities/common/CantBlockAbility.java create mode 100644 Mage/src/mage/abilities/condition/common/TenOrLessLife.java diff --git a/Mage/src/mage/abilities/common/CantBlockAbility.java b/Mage/src/mage/abilities/common/CantBlockAbility.java new file mode 100644 index 00000000000..69ef81433fa --- /dev/null +++ b/Mage/src/mage/abilities/common/CantBlockAbility.java @@ -0,0 +1,81 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package mage.abilities.common; + +import java.io.ObjectStreamException; +import mage.Constants.Duration; +import mage.Constants.Zone; +import mage.abilities.Ability; +import mage.abilities.effects.RestrictionEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.ReachAbility; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author matthew.maurer + */ +public class CantBlockAbility extends SimpleStaticAbility { + + private static final CantBlockAbility fINSTANCE = new CantBlockAbility(); + + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } + + public static CantBlockAbility getInstance() { + return fINSTANCE; + } + + private CantBlockAbility() { + super(Zone.BATTLEFIELD, new CantBlockEffect()); + } + + @Override + public String getRule() { + return "Flying"; + } + + @Override + public CantBlockAbility copy() { + return fINSTANCE; + } + +} + +class CantBlockEffect extends RestrictionEffect { + + public CantBlockEffect() { + super(Duration.WhileOnBattlefield); + } + + public CantBlockEffect(final CantBlockEffect effect) { + super(effect); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + if (permanent.getAbilities().containsKey(CantBlockAbility.getInstance().getId())) { + return true; + } + return false; + } + + @Override + public boolean canBlock(Permanent blocker, Game game) { + if (blocker.getAbilities().containsKey(CantBlockAbility.getInstance().getId())) { + return false; + } + return true; + } + + @Override + public CantBlockEffect copy() { + return new CantBlockEffect(this); + } + +} diff --git a/Mage/src/mage/abilities/condition/common/Controls.java b/Mage/src/mage/abilities/condition/common/Controls.java index b6c81b13927..933c9acdb10 100644 --- a/Mage/src/mage/abilities/condition/common/Controls.java +++ b/Mage/src/mage/abilities/condition/common/Controls.java @@ -40,7 +40,7 @@ import mage.game.Game; * @see #Controls(mage.filter.Filter) * @see #Controls(mage.filter.Filter, mage.abilities.condition.Condition) * - * @author matthew.maurer + * @author maurer.it_at_gmail.com */ public class Controls implements Condition { diff --git a/Mage/src/mage/abilities/condition/common/TenOrLessLife.java b/Mage/src/mage/abilities/condition/common/TenOrLessLife.java new file mode 100644 index 00000000000..dbd9fe41676 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/TenOrLessLife.java @@ -0,0 +1,48 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package mage.abilities.condition.common; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; + +/** + * + * @author maurer.it_at_gmail.com + */ +public class TenOrLessLife implements Condition { + + public static enum CheckType { AN_OPPONENT, CONTROLLER, TARGET_OPPONENT }; + + private CheckType type; + + public TenOrLessLife ( CheckType type ) { + this.type = type; + } + + @Override + public boolean apply(Game game, Ability source) { + boolean conditionApplies = false; + + switch ( this.type ) { + case AN_OPPONENT: + for ( UUID opponentUUID : game.getOpponents(source.getControllerId()) ) { + conditionApplies |= game.getPlayer(opponentUUID).getLife() <= 10; + } + break; + case CONTROLLER: + conditionApplies |= game.getPlayer(source.getControllerId()).getLife() <= 10; + break; + case TARGET_OPPONENT: + //TODO: Implement this. + break; + } + + return conditionApplies; + } + +}