Allow activating equip ability

This commit is contained in:
Noah Gleason 2018-06-25 22:36:49 -04:00
parent b408643d58
commit cf571122ea
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40
4 changed files with 81 additions and 22 deletions

View 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 thats also a creature cant equip a creature. An Equipment that loses the subtype
// Equipment cant equip a creature. An Equipment cant 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 cant equip more than one creature. If a spell or ability
// would cause an Equipment to equip more than one creature, the Equipments 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);
}
}