Implement Splash Portal (#12605)

* Implement Splash Portal

* Add test

* Add an afterEffect to ExileThenReturnTargetEffect for use in Splash Portal

* Modify Essence Flux to use new ExileThenReturnTargetEffect and write test

* use withAfterEffect for ExileThenReturnTargetEffect

* use ConditionalOneShotEffect

* Restrict effects to one shot
This commit is contained in:
jimga150 2024-08-14 21:12:55 -04:00 committed by GitHub
parent 9a872b4446
commit d5c76489ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 182 additions and 72 deletions

View file

@ -2,6 +2,7 @@ package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
@ -9,6 +10,8 @@ import mage.constants.PutCards;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.targetpointer.FixedTargets;
import mage.util.CardUtil;
import java.util.LinkedHashSet;
import java.util.Objects;
@ -23,6 +26,7 @@ public class ExileThenReturnTargetEffect extends OneShotEffect {
private final boolean yourControl;
private final boolean textThatCard;
private final PutCards putCards;
private OneShotEffect afterEffect = null;
public ExileThenReturnTargetEffect(boolean yourControl, boolean textThatCard) {
this(yourControl, textThatCard, PutCards.BATTLEFIELD);
@ -40,6 +44,7 @@ public class ExileThenReturnTargetEffect extends OneShotEffect {
this.putCards = effect.putCards;
this.yourControl = effect.yourControl;
this.textThatCard = effect.textThatCard;
this.afterEffect = effect.afterEffect;
}
@Override
@ -47,6 +52,11 @@ public class ExileThenReturnTargetEffect extends OneShotEffect {
return new ExileThenReturnTargetEffect(this);
}
public ExileThenReturnTargetEffect withAfterEffect(OneShotEffect afterEffect) {
this.afterEffect = afterEffect;
return this;
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -68,6 +78,10 @@ public class ExileThenReturnTargetEffect extends OneShotEffect {
yourControl ? controller : game.getPlayer(card.getOwnerId()),
card.getMainCard(), source, game, "card");
}
if (afterEffect != null){
afterEffect.setTargetPointer(new FixedTargets(toFlicker, game));
afterEffect.apply(game, source);
}
return true;
}
@ -91,6 +105,9 @@ public class ExileThenReturnTargetEffect extends OneShotEffect {
sb.append(this.yourControl ? "your" : "its owner's");
}
sb.append(" control");
if (afterEffect != null){
sb.append(". ").append(CardUtil.getTextWithFirstCharUpperCase(afterEffect.getText(mode)));
}
return sb.toString();
}