Generalize UntapEnchantedEffect to UntapAttachedEffect

This commit is contained in:
xenohedron 2023-07-13 00:28:03 -04:00
parent 9c7d53fd2b
commit eeffafcc62
15 changed files with 45 additions and 41 deletions

View file

@ -1,44 +0,0 @@
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX
*/
public class UntapEnchantedEffect extends OneShotEffect {
public UntapEnchantedEffect() {
super(Outcome.Untap);
staticText = "untap enchanted creature";
}
public UntapEnchantedEffect(final UntapEnchantedEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Permanent attach = game.getPermanent(permanent.getAttachedTo());
if (attach != null) {
attach.untap(game);
return true;
}
}
return false;
}
@Override
public UntapEnchantedEffect copy() {
return new UntapEnchantedEffect(this);
}
}