forked from External/mage
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"
This commit is contained in:
parent
d01ab3b2ef
commit
0548ff7467
3 changed files with 130 additions and 1 deletions
81
Mage/src/mage/abilities/common/CantBlockAbility.java
Normal file
81
Mage/src/mage/abilities/common/CantBlockAbility.java
Normal file
|
|
@ -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<CantBlockEffect> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
48
Mage/src/mage/abilities/condition/common/TenOrLessLife.java
Normal file
48
Mage/src/mage/abilities/condition/common/TenOrLessLife.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue