mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
ChangeZoneEffect: will use inputs where possible (zone == battlefield or zone == gui player's hand) to ease card selection
added facedown Predicate removed import-related warnings
This commit is contained in:
@@ -167,6 +167,13 @@ public final class CardPredicates {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Predicate<Card> FACE_DOWN = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isFaceDown();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* a Predicate<Card> to get all cards that are untapped.
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class FlipACoinAi extends SpellAbilityAi {
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.FThreads;
|
||||
import forge.GameEntity;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
@@ -19,6 +20,7 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityStackInstance;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.control.input.InputSelectCardsFromList;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.AIPlayer;
|
||||
@@ -693,17 +695,14 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
if (!defined) {
|
||||
if (origin.contains(ZoneType.Library) && !defined && !sa.hasParam("NoLooking")) {
|
||||
final int fetchNum = Math.min(player.getCardsIn(ZoneType.Library).size(), 4);
|
||||
List<Card> shown = !decider.hasKeyword("LimitSearchLibrary") ? player.getCardsIn(ZoneType.Library) : player.getCardsIn(ZoneType.Library, fetchNum);
|
||||
// Look at whole library before moving onto choosing a card
|
||||
GuiChoose.oneOrNone(sa.getSourceCard().getName() + " - Looking at Library",
|
||||
!decider.hasKeyword("LimitSearchLibrary")
|
||||
? player.getCardsIn(ZoneType.Library)
|
||||
: player.getCardsIn(ZoneType.Library, fetchNum));
|
||||
decider.getController().reveal(sa.getSourceCard().getName() + " - Looking at library", shown, ZoneType.Library, player);
|
||||
}
|
||||
|
||||
// Look at opponents hand before moving onto choosing a card
|
||||
if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) {
|
||||
GuiChoose.oneOrNone(sa.getSourceCard().getName() + " - Looking at Opponent's Hand", player
|
||||
.getCardsIn(ZoneType.Hand));
|
||||
decider.getController().reveal(sa.getSourceCard().getName() + " - Looking at Opponent's Hand", player.getCardsIn(ZoneType.Hand), ZoneType.Hand, player);
|
||||
}
|
||||
fetchList = AbilityUtils.filterListByType(fetchList, sa.getParam("ChangeType"), sa);
|
||||
}
|
||||
@@ -712,7 +711,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
final boolean champion = sa.hasParam("Champion");
|
||||
final String forget = sa.getParam("ForgetChanged");
|
||||
final String imprint = sa.getParam("Imprint");
|
||||
final String selectPrompt = sa.hasParam("SelectPrompt") ? sa.getParam("SelectPrompt") : "Select a card";
|
||||
final String selectPrompt = sa.hasParam("SelectPrompt") ? sa.getParam("SelectPrompt") : "Select a card from " + origin;
|
||||
final String totalcmc = sa.getParam("WithTotalCMC");
|
||||
int totcmc = AbilityUtils.calculateAmount(card, totalcmc, sa);
|
||||
|
||||
@@ -735,15 +734,25 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
break;
|
||||
}
|
||||
|
||||
// card has to be on battlefield or in own hand
|
||||
boolean canUseInputToSelectCard = origin.size() == 1 && ( origin.get(0) == ZoneType.Battlefield || origin.get(0) == ZoneType.Hand && player == decider);
|
||||
|
||||
Object o;
|
||||
if (sa.hasParam("AtRandom")) {
|
||||
o = Aggregates.random(fetchList);
|
||||
} else if (sa.hasParam("Mandatory")) {
|
||||
o = GuiChoose.one(selectPrompt, fetchList);
|
||||
} else if (sa.hasParam("Defined")) {
|
||||
o = fetchList.get(0);
|
||||
} else {
|
||||
o = GuiChoose.oneOrNone(selectPrompt, fetchList);
|
||||
boolean mustChoose = sa.hasParam("Mandatory");
|
||||
if( canUseInputToSelectCard ) {
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(1, 1, fetchList);
|
||||
inp.setCancelAllowed(!mustChoose);
|
||||
inp.setMessage(selectPrompt);
|
||||
FThreads.setInputAndWait(inp);
|
||||
o = inp.getSelected().get(0);
|
||||
}
|
||||
else
|
||||
o = GuiChoose.getChoices(selectPrompt, 0, mustChoose ? 1 : 0, fetchList);
|
||||
}
|
||||
|
||||
if (o != null) {
|
||||
@@ -887,7 +896,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("Reveal") && !movedCards.isEmpty()) {
|
||||
GuiChoose.one(card + " - Revealed card: ", movedCards);
|
||||
decider.getController().reveal(card + " - Revealed card: ", movedCards, origin.get(0), player);
|
||||
}
|
||||
|
||||
if ((origin.contains(ZoneType.Library) && !destination.equals(ZoneType.Library) && !defined)
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.card.staticability;
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.Card;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class ZoneAction extends ForgeAction {
|
||||
for (Card crd : choices) {
|
||||
Card toAdd = crd;
|
||||
if (crd.isFaceDown()) {
|
||||
if (crd.canBeSeenBy(Singletons.getControl().getLobby().getGuiPlayer().getPlayer(crd.getGame()))) {
|
||||
if (crd.canBeSeenBy(Singletons.getControl().getPlayer())) {
|
||||
toAdd = CardFactory.copyCard(crd);
|
||||
toAdd.setState(CardCharacteristicName.Original);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user