foul-magics/Mage/src/main/java/mage/abilities/effects/EquipEffect.java
2018-06-25 22:36:49 -04:00

39 lines
1.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}