forked from External/mage
Add new methods to Target and TargetPointer to help generate card rules text. Currently only used by ExileUntilSourceLeavesEffect
This commit is contained in:
parent
c6e1ce6697
commit
addfd5166e
38 changed files with 156 additions and 208 deletions
|
|
@ -1,10 +1,12 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -13,9 +15,8 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class ExileUntilSourceLeavesEffect extends OneShotEffect {
|
||||
|
||||
public ExileUntilSourceLeavesEffect(String targetName) {
|
||||
public ExileUntilSourceLeavesEffect() {
|
||||
super(Outcome.Removal);
|
||||
this.staticText = "exile target " + targetName + " an opponent controls until {this} leaves the battlefield";
|
||||
}
|
||||
|
||||
public ExileUntilSourceLeavesEffect(final ExileUntilSourceLeavesEffect effect) {
|
||||
|
|
@ -29,13 +30,10 @@ public class ExileUntilSourceLeavesEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
|
||||
// If Banishing Light leaves the battlefield before its triggered ability resolves, the target permanent won't be exiled.
|
||||
// (2021-03-19)
|
||||
if (game.getPermanent(source.getSourceId()) == null) {
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -45,4 +43,12 @@ public class ExileUntilSourceLeavesEffect extends OneShotEffect {
|
|||
}
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "exile " + getTargetPointer().describeTargets(mode.getTargets(), "that creature") + " until {this} leaves the battlefield";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue