forked from External/mage
Allow activating equip ability
This commit is contained in:
parent
b408643d58
commit
cf571122ea
4 changed files with 81 additions and 22 deletions
39
Mage/src/main/java/mage/abilities/effects/EquipEffect.java
Normal file
39
Mage/src/main/java/mage/abilities/effects/EquipEffect.java
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package mage.abilities.effects;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
public class EquipEffect extends AttachEffect {
|
||||
|
||||
public EquipEffect(Outcome outcome) {
|
||||
super(outcome, "Equip");
|
||||
}
|
||||
|
||||
public EquipEffect(EquipEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
//301.5c An Equipment that’s also a creature can’t equip a creature. An Equipment that loses the subtype
|
||||
// “Equipment” can’t equip a creature. An Equipment can’t equip itself. An Equipment that equips an illegal or
|
||||
// nonexistent permanent becomes unattached from that permanent but remains on the battlefield. (This is a
|
||||
// state-based action. See rule 704.) An Equipment can’t equip more than one creature. If a spell or ability
|
||||
// would cause an Equipment to equip more than one creature, the Equipment’s controller chooses which creature
|
||||
// it equips.
|
||||
if (sourcePermanent != null && sourcePermanent.hasSubtype(SubType.EQUIPMENT, game) && !sourcePermanent.isCreature()) {
|
||||
return super.apply(game, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquipEffect copy(){
|
||||
return new EquipEffect(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue