foul-magics/Mage/src/main/java/mage/abilities/effects/common/PhaseOutAttachedEffect.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

45 lines
1.4 KiB
Java

package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public class PhaseOutAttachedEffect extends OneShotEffect {
public PhaseOutAttachedEffect() {
super(Outcome.Detriment);
this.staticText = "Enchanted creature phases out";
}
protected PhaseOutAttachedEffect(final PhaseOutAttachedEffect effect) {
super(effect);
}
@Override
public PhaseOutAttachedEffect copy() {
return new PhaseOutAttachedEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment != null) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (enchanted != null) {
return enchanted.phaseOut(game);
}
}
return false;
}
}