mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Fix HideawayPlayEffect to allow you to attempt to play everything (#13009)
* Fix HideawayPlayEffect to allow you to attempt to play everything, in cases of multiple Hideaway triggers. * Allow users to choose order of cards to be potentially played. * Update HideawayPlay and Arcane Bombardment to not ask if you want to play the cards you chose. Update tests, add tests for - Select the order in which to play cards - Attempt to play two lands with only one land drop available, only the first land enters play - Play two lands with extra land drops available. * Fix no-parameter constructor.
This commit is contained in:
parent
06f630b00a
commit
57deccae61
3 changed files with 169 additions and 39 deletions
|
|
@ -4,12 +4,17 @@ import mage.ApprovingObject;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -17,13 +22,25 @@ import java.util.UUID;
|
|||
*/
|
||||
public class HideawayPlayEffect extends OneShotEffect {
|
||||
|
||||
private final boolean playOne;
|
||||
|
||||
public HideawayPlayEffect() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public HideawayPlayEffect(boolean playOne) {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "you may play the exiled card without paying its mana cost";
|
||||
this.playOne = playOne;
|
||||
if (playOne) {
|
||||
staticText = "if there are cards exiled with it, you may play one of them without paying its mana cost";
|
||||
} else {
|
||||
staticText = "you may play the exiled card without paying its mana cost";
|
||||
}
|
||||
}
|
||||
|
||||
protected HideawayPlayEffect(final HideawayPlayEffect effect) {
|
||||
super(effect);
|
||||
this.playOne = effect.playOne;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -38,33 +55,39 @@ public class HideawayPlayEffect extends OneShotEffect {
|
|||
if (controller == null || zone == null || zone.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
Card card = zone.getRandom(game);
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
if (!controller.chooseUse(Outcome.PlayForFree, "Play " + card.getIdName() + " for free?", source, game)) {
|
||||
return false;
|
||||
}
|
||||
card.setFaceDown(false, game);
|
||||
int zcc = card.getZoneChangeCounter(game);
|
||||
CardsImpl cards = new CardsImpl(zone.getCards(game));
|
||||
|
||||
/* 702.74. Hideaway, rulings:
|
||||
* If the removed card is a land, you may play it as a result of the last ability only if it's your turn
|
||||
* and you haven't already played a land that turn. This counts as your land play for the turn.
|
||||
* TODO: this doesn't work correctly with the back half of MDFCs
|
||||
*/
|
||||
if (card.isLand(game)) {
|
||||
UUID playerId = controller.getId();
|
||||
if (!game.isActivePlayer(playerId) || !game.getPlayer(playerId).canPlayLand()) {
|
||||
return false;
|
||||
boolean cardPlayed = false;
|
||||
int maxChoices = (this.playOne) ? 1 : cards.size();
|
||||
TargetCard target = new TargetCard(0, maxChoices, Zone.EXILED, new FilterCard("cards to play (in order they're chosen)"));
|
||||
controller.choose(Outcome.PlayForFree, cards, target, source, game);
|
||||
List<UUID> targets = target.getTargets();
|
||||
|
||||
for (UUID targetId : targets) {
|
||||
Card card = game.getCard(targetId);
|
||||
/* 702.74. Hideaway, rulings:
|
||||
* If the removed card is a land, you may play it as a result of the last ability only if it's your turn
|
||||
* and you haven't already played a land that turn. This counts as your land play for the turn.
|
||||
* TODO: this doesn't work correctly with the back half of MDFCs
|
||||
*/
|
||||
if (card.isLand(game)) {
|
||||
UUID playerId = controller.getId();
|
||||
if (!game.isActivePlayer(playerId) || !game.getPlayer(playerId).canPlayLand()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
card.setFaceDown(false, game);
|
||||
int zcc = card.getZoneChangeCounter(game);
|
||||
|
||||
if (controller.playCard(card, game, true, new ApprovingObject(source, game))) {
|
||||
cardPlayed = true;
|
||||
} else {
|
||||
if (card.getZoneChangeCounter(game) == zcc) {
|
||||
card.setFaceDown(true, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!controller.playCard(card, game, true, new ApprovingObject(source, game))) {
|
||||
if (card.getZoneChangeCounter(game) == zcc) {
|
||||
card.setFaceDown(true, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return cardPlayed;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue