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