Add Flanking ability

This commit is contained in:
Plopman 2012-09-20 13:59:54 +02:00
parent 3d4467e071
commit bfe6261acc
2 changed files with 113 additions and 45 deletions

View file

@ -0,0 +1,67 @@
package mage.abilities.keyword;
import mage.Constants;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author Plopman
*/
public class FlankingAbility extends TriggeredAbilityImpl<FlankingAbility> {
public FlankingAbility() {
super(Constants.Zone.BATTLEFIELD, new BoostTargetEffect(-1, -1, Constants.Duration.EndOfTurn), false);
}
public FlankingAbility(final FlankingAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED && event.getTargetId().equals(this.getSourceId())) {
Permanent permanent = game.getPermanent(event.getSourceId());
if(permanent != null)
{
boolean hasFlankingAbility = false;
for(Ability ability : permanent.getAbilities()){
if(ability instanceof FlankingAbility){
hasFlankingAbility = true;
}
}
if(!hasFlankingAbility){
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getSourceId()));
}
return true;
}
}
}
return false;
}
@Override
public String getRule() {
return "Flanking";
}
@Override
public FlankingAbility copy() {
return new FlankingAbility(this);
}
}

View file

@ -11,6 +11,7 @@ Unearth|cost|
Battle cry|new| Battle cry|new|
Cascade|new| Cascade|new|
Exalted|new| Exalted|new|
Flanking|new|
Forestwalk|new| Forestwalk|new|
Indestructible|new| Indestructible|new|
Islandwalk|new| Islandwalk|new|