foul-magics/Mage/src/main/java/mage/abilities/effects/common/UntapAttachedEffect.java
Susucre f75b1c9f0a
Code cleanup: protect all copy constructors (#10750)
* apply regex to change public copy constructors to protected
* cleanup code using now protected constructors
* fix manaBuilder weird casting of Mana into ConditionalMana
2023-08-04 19:34:58 -04:00

47 lines
1.2 KiB
Java

package mage.abilities.effects.common;
import mage.constants.AttachmentType;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
/**
* @author LevelX
*/
public class UntapAttachedEffect extends OneShotEffect {
public UntapAttachedEffect() {
this(AttachmentType.AURA, "creature");
}
public UntapAttachedEffect(AttachmentType attachmentType, String name) {
super(Outcome.Untap);
staticText = "untap " + CardUtil.getTextWithFirstCharLowerCase(attachmentType.verb()) + ' ' + name;
}
protected UntapAttachedEffect(final UntapAttachedEffect 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 UntapAttachedEffect copy() {
return new UntapAttachedEffect(this);
}
}