forked from External/mage
Can't Block Ability finally working properly.
Added Not condition to be used for inverting other conditions... not sure how handy this will be but it helped with Vampire Lacerator.
This commit is contained in:
parent
e8df43353a
commit
2f063775a4
2 changed files with 38 additions and 11 deletions
|
|
@ -10,14 +10,12 @@ 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
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class CantBlockAbility extends SimpleStaticAbility {
|
||||
|
||||
|
|
@ -59,18 +57,12 @@ class CantBlockEffect extends RestrictionEffect<CantBlockEffect> {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getAbilities().containsKey(CantBlockAbility.getInstance().getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent.getAbilities().containsKey(CantBlockAbility.getInstance().getId()) || source.getId().equals(CantBlockAbility.getInstance().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlock(Permanent blocker, Game game) {
|
||||
if (blocker.getAbilities().containsKey(CantBlockAbility.getInstance().getId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !blocker.getAbilities().containsKey(CantBlockAbility.getInstance().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
35
Mage/src/mage/abilities/condition/common/Not.java
Normal file
35
Mage/src/mage/abilities/condition/common/Not.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* A simple {@link Condition} to invert a decorated conditions
|
||||
* {@link Condition#apply(mage.game.Game, mage.abilities.Ability) apply(mage.game.Game, mage.abilities.Ability)}
|
||||
* method invocation.
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class Not implements Condition {
|
||||
|
||||
private Condition condition;
|
||||
|
||||
public Not ( Condition condition ) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
/*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !condition.apply(game, source);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue