forked from External/mage
* Fixed that equipments with restrictions (e.g. Gate Smasher) were not unequipped if the equipped permanent did no longer fulfill the restrictions(fixes #2212).
This commit is contained in:
parent
720a4457fd
commit
ab2399cbe7
17 changed files with 234 additions and 59 deletions
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.InfoEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AttachableToRestrictedAbility extends SimpleStaticAbility {
|
||||
|
||||
public AttachableToRestrictedAbility(Target target) {
|
||||
super(Zone.BATTLEFIELD, new InfoEffect("{this} can be attached only to a " + target.getTargetName()));
|
||||
addTarget(target);
|
||||
}
|
||||
|
||||
private AttachableToRestrictedAbility(AttachableToRestrictedAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
public boolean canEquip(Permanent toEquip, Ability source, Game game) {
|
||||
for (Target target : getTargets()) {
|
||||
if (source == null) {
|
||||
if (!target.canTarget(toEquip.getId(), game)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!target.canTarget(toEquip.getId(), source, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachableToRestrictedAbility copy() {
|
||||
return new AttachableToRestrictedAbility(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue