forked from External/mage
More target adding, reattach improves (#13807)
* Add Target to Provoke, Soulshift, remove from AttachableToRestrictedAbility * Add Target to CurseOfInertia, FarrelsMantle, Incendiary, JubilantMascot, MantleOfTheAncients, MuseVessel, SoulSeizer. Fix DreamEater text. * Fix CardImpl.cantBeAttachedBy to not early return with Protection abilities * Improve tests
This commit is contained in:
parent
8fda57401d
commit
7d7e517084
17 changed files with 273 additions and 260 deletions
|
|
@ -4,35 +4,30 @@ 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;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AttachableToRestrictedAbility extends SimpleStaticAbility {
|
||||
|
||||
private final Target attachable;
|
||||
public AttachableToRestrictedAbility(Target target) {
|
||||
super(Zone.BATTLEFIELD, new InfoEffect("{this} can be attached only to a " + target.getTargetName()));
|
||||
addTarget(target);
|
||||
this.attachable = target.copy();
|
||||
}
|
||||
|
||||
private AttachableToRestrictedAbility(AttachableToRestrictedAbility ability) {
|
||||
super(ability);
|
||||
this.attachable = ability.attachable; // Since we never modify the target, we don't need to re-copy it
|
||||
}
|
||||
|
||||
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;
|
||||
public boolean canEquip(UUID toEquip, Ability source, Game game) {
|
||||
if (source == null) {
|
||||
return attachable.canTarget(toEquip, game);
|
||||
} else return attachable.canTarget(toEquip, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue