forked from External/mage
[FDN] Implement Strongbox Raider
This commit is contained in:
parent
e0c39f10e8
commit
9226e5239f
15 changed files with 156 additions and 516 deletions
|
|
@ -6,11 +6,16 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.targetpointer.FixedTargets;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
|
@ -19,22 +24,29 @@ import java.util.Set;
|
|||
public class ExileTopXMayPlayUntilEffect extends OneShotEffect {
|
||||
|
||||
private final DynamicValue amount;
|
||||
private final boolean chooseOne;
|
||||
private final Duration duration;
|
||||
|
||||
public ExileTopXMayPlayUntilEffect(int amount, Duration duration) {
|
||||
this(StaticValue.get(amount), duration);
|
||||
this(amount, false, duration);
|
||||
}
|
||||
|
||||
public ExileTopXMayPlayUntilEffect(DynamicValue amount, Duration duration) {
|
||||
public ExileTopXMayPlayUntilEffect(int amount, boolean chooseOne, Duration duration) {
|
||||
this(StaticValue.get(amount), chooseOne, duration);
|
||||
}
|
||||
|
||||
public ExileTopXMayPlayUntilEffect(DynamicValue amount, boolean chooseOne, Duration duration) {
|
||||
super(Outcome.Benefit);
|
||||
this.amount = amount.copy();
|
||||
this.chooseOne = chooseOne;
|
||||
this.duration = duration;
|
||||
makeText(amount.toString().equals("1") ? "that card" : "those cards", duration == Duration.EndOfTurn);
|
||||
makeText(amount.toString().equals("1") || chooseOne ? "that card" : "those cards", duration == Duration.EndOfTurn);
|
||||
}
|
||||
|
||||
protected ExileTopXMayPlayUntilEffect(final ExileTopXMayPlayUntilEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount.copy();
|
||||
this.chooseOne = effect.chooseOne;
|
||||
this.duration = effect.duration;
|
||||
}
|
||||
|
||||
|
|
@ -50,18 +62,29 @@ public class ExileTopXMayPlayUntilEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
int resolvedAmount = amount.calculate(game, source, this);
|
||||
Set<Card> cards = controller.getLibrary().getTopCards(game, resolvedAmount);
|
||||
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, resolvedAmount));
|
||||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
|
||||
controller.moveCardsToExile(
|
||||
cards.getCards(game), source, game, true,
|
||||
CardUtil.getExileZoneId(game, source),
|
||||
CardUtil.getSourceName(game, source)
|
||||
);
|
||||
// remove cards that could not be moved to exile
|
||||
cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
|
||||
if (!cards.isEmpty()) {
|
||||
game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, duration)
|
||||
.setTargetPointer(new FixedTargets(cards, game)), source);
|
||||
effectCards(game, source, cards);
|
||||
cards.retainZone(Zone.EXILED, game);
|
||||
if (chooseOne && cards.size() > 1) {
|
||||
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD);
|
||||
target.withNotTarget(true);
|
||||
controller.choose(outcome, cards, target, source, game);
|
||||
cards.removeIf(uuid -> !uuid.equals(target.getFirstTarget()));
|
||||
}
|
||||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, duration)
|
||||
.setTargetPointer(new FixedTargets(cards, game)), source);
|
||||
effectCards(game, source, cards.getCards(game));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +109,9 @@ public class ExileTopXMayPlayUntilEffect extends OneShotEffect {
|
|||
} else {
|
||||
text += " of your library. ";
|
||||
}
|
||||
if (chooseOne) {
|
||||
text += "Choose one of them. ";
|
||||
}
|
||||
if (durationRuleAtEnd) {
|
||||
text += "You may play " + refCardText + ' ' + (duration == Duration.EndOfTurn ? "this turn" : duration.toString());
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue