forked from External/mage
Generalize UntapEnchantedEffect to UntapAttachedEffect
This commit is contained in:
parent
9c7d53fd2b
commit
eeffafcc62
15 changed files with 45 additions and 41 deletions
|
|
@ -0,0 +1,48 @@
|
|||
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;
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue