forked from External/mage
50 lines
1.2 KiB
Java
50 lines
1.2 KiB
Java
|
|
package mage.abilities.effects.common;
|
|
|
|
import mage.abilities.Ability;
|
|
import mage.abilities.effects.OneShotEffect;
|
|
import mage.constants.Outcome;
|
|
import mage.game.Game;
|
|
import mage.game.permanent.Permanent;
|
|
|
|
/**
|
|
*
|
|
* @author BetaSteward_at_googlemail.com
|
|
*/
|
|
public class DestroySourceEffect extends OneShotEffect {
|
|
|
|
protected boolean noRegen;
|
|
|
|
public DestroySourceEffect() {
|
|
this(false);
|
|
}
|
|
|
|
public DestroySourceEffect(boolean noRegen) {
|
|
super(Outcome.DestroyPermanent);
|
|
this.noRegen = noRegen;
|
|
staticText = "destroy {this}";
|
|
}
|
|
|
|
public DestroySourceEffect(final DestroySourceEffect effect) {
|
|
super(effect);
|
|
this.noRegen = effect.noRegen;
|
|
}
|
|
|
|
@Override
|
|
public DestroySourceEffect copy() {
|
|
return new DestroySourceEffect(this);
|
|
}
|
|
|
|
@Override
|
|
public boolean apply(Game game, Ability source) {
|
|
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
|
if (permanent != null
|
|
&& permanent.isPhasedIn()
|
|
&& !permanent.isPhasedOutIndirectly()) {
|
|
permanent.destroy(source, game, noRegen);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|