diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index c7b845e9051..fb9fd6239dd 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -164,8 +164,20 @@ public class PlayerControllerAi extends PlayerController { public List chooseEntitiesForEffect( FCollectionView optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title, Player targetedPlayer) { - // this isn't used - return null; + if (delayedReveal != null) { + reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix()); + } + FCollection remaining = new FCollection(optionList); + List selecteds = new ArrayList(); + T selected; + do { + selected = chooseSingleEntityForEffect(remaining, null, sa, title, selecteds.size()>=min, targetedPlayer); + if ( selected != null ) { + remaining.remove(selected); + selecteds.add(selected); + } + } while ( (selected != null ) && (selecteds.size() < max) ); + return selecteds; } @Override diff --git a/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java index 9d3fd658b19..80b301f6cdc 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java @@ -194,7 +194,7 @@ public class DigEffect extends SpellAbilityEffect { } } else { - // If all the cards are valid choices, no need for a separate reveal dialog to the chooser. + // If all the cards are valid choices, no need for a separate reveal dialog to the chooser. pfps?? if (p == chooser && destZone1ChangeNum > 1) { delayedReveal = null; } @@ -238,55 +238,83 @@ public class DigEffect extends SpellAbilityEffect { if (sa.hasParam("RandomOrder")) { CardLists.shuffle(movedCards); } - } - else { + } else { String prompt; - if (sa.hasParam("PrimaryPrompt")) { - prompt = sa.getParam("PrimaryPrompt"); - } else { - prompt = "Choose a card to put into " + destZone1.name(); - if (destZone1.equals(ZoneType.Library)) { - if (libraryPosition == -1) { - prompt = "Choose a card to put on the bottom of {player's} library"; - } - else if (libraryPosition == 0) { - prompt = "Choose a card to put on top of {player's} library"; - } - } - } + if (!andOrValid.equals("")) { // pfps: old way - to be fixed soon - movedCards = new CardCollection(); - for (int i = 0; i < destZone1ChangeNum || (anyNumber && i < numToDig); i++) { - // let user get choice - Card chosen = null; - if (!valid.isEmpty()) { - // If we're choosing multiple cards, only need to show the reveal dialog the first time through. - boolean shouldReveal = (i == 0); - chosen = chooser.getController().chooseSingleEntityForEffect(valid, shouldReveal ? delayedReveal : null, sa, prompt, anyNumber || optional, p); - } - else { - if (i == 0) { - chooser.getController().notifyOfValue(sa, null, "No valid cards"); - } - } + if (sa.hasParam("PrimaryPrompt")) { + prompt = sa.getParam("PrimaryPrompt"); + } else { + prompt = "Choose a card to put into " + destZone1.name(); + if (destZone1.equals(ZoneType.Library)) { + if (libraryPosition == -1) { + prompt = "Choose a card to put on the bottom of {player's} library"; + } + else if (libraryPosition == 0) { + prompt = "Choose a card to put on top of {player's} library"; + } + } + } - if (chosen == null) { - break; - } + movedCards = new CardCollection(); + for (int i = 0; i < destZone1ChangeNum || (anyNumber && i < numToDig); i++) { + // let user get choice + Card chosen = null; + if (!valid.isEmpty()) { + // If we're choosing multiple cards, only need to show the reveal dialog the first time through. + boolean shouldReveal = (i == 0); + chosen = chooser.getController().chooseSingleEntityForEffect(valid, shouldReveal ? delayedReveal : null, sa, prompt, anyNumber || optional, p); + } + else { + if (i == 0) { + chooser.getController().notifyOfValue(sa, null, "No valid cards"); + } + } + if (chosen == null) { break; } + movedCards.add(chosen); + valid.remove(chosen); + if (!andOrValid.equals("")) { + andOrCards.remove(chosen); + if (!chosen.isValid(andOrValid.split(","), host.getController(), host, sa)) { + valid = new CardCollection(andOrCards); + } + else if (!chosen.isValid(changeValid.split(","), host.getController(), host, sa)) { + valid.removeAll((Collection)andOrCards); + } + } + } - movedCards.add(chosen); - valid.remove(chosen); - if (!andOrValid.equals("")) { - andOrCards.remove(chosen); - if (!chosen.isValid(andOrValid.split(","), host.getController(), host, sa)) { - valid = new CardCollection(andOrCards); - } - else if (!chosen.isValid(changeValid.split(","), host.getController(), host, sa)) { - valid.removeAll((Collection)andOrCards); - } - } - } + } else { // pfps: new way + + if (sa.hasParam("PrimaryPrompt")) { + prompt = sa.getParam("PrimaryPrompt"); + } else { + prompt = "Choose card(s) to put into " + destZone1.name(); + if (destZone1.equals(ZoneType.Library)) { + if (libraryPosition == -1) { + prompt = "Choose card(s) to put on the bottom of {player's} library"; + } + else if (libraryPosition == 0) { + prompt = "Choose card(s) to put on top of {player's} library"; + } + } + } + + movedCards = new CardCollection(); + int min = (anyNumber || optional) ? 0 : numToDig; + int max = Math.max(destZone1ChangeNum, anyNumber ? valid.size() : 0); +1 if (!valid.isEmpty()) { + if ( p == chooser ) { // the digger can still see all the dug cards when choosing + chooser.getController().tempShowCards(top); + } + List chosen = chooser.getController().chooseEntitiesForEffect(valid, min, max, delayedReveal, sa, prompt, p); + chooser.getController().endTempShowCards(); + movedCards.addAll(chosen); + } else { + chooser.getController().notifyOfValue(sa, null, "No valid cards"); + } + } if (!changeValid.isEmpty() && !sa.hasParam("ExileFaceDown") && !sa.hasParam("NoReveal")) { game.getAction().reveal(movedCards, chooser, true, diff --git a/forge-game/src/main/java/forge/game/player/PlayerController.java b/forge-game/src/main/java/forge/game/player/PlayerController.java index 33295250a62..f6d58aec623 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerController.java +++ b/forge-game/src/main/java/forge/game/player/PlayerController.java @@ -81,6 +81,9 @@ public abstract class PlayerController { public Player getPlayer() { return player; } public LobbyPlayer getLobbyPlayer() { return lobbyPlayer; } + public void tempShowCards(final Iterable cards) { } // show cards in UI until ended + public void endTempShowCards() { } + public final SpellAbility getAbilityToPlay(final Card hostCard, final List abilities) { return getAbilityToPlay(hostCard, abilities, null); } public abstract SpellAbility getAbilityToPlay(Card hostCard, List abilities, ITriggerEvent triggerEvent); diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 1a2c2cb43d1..7818470b439 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -156,7 +156,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont c.setMayLookAt(player, true, true); } - private void tempShowCards(final Iterable cards) { + @Override + public void tempShowCards(final Iterable cards) { if (mayLookAtAllCards) { return; } // no needed if this is set @@ -166,7 +167,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont } } - private void endTempShowCards() { + @Override + public void endTempShowCards() { if (tempShownCards.isEmpty()) { return; } @@ -479,11 +481,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont } if (useSelectCardsInput(optionList)) { - if (delayedReveal != null) { - reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), - delayedReveal.getMessagePrefix()); - } + // if (delayedReveal != null) { + // reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), + // delayedReveal.getMessagePrefix()); + //} tempShow(optionList); + if (delayedReveal != null) { + tempShow(delayedReveal.getCards()); + } final InputSelectEntitiesFromList input = new InputSelectEntitiesFromList(this, min, max, optionList, sa); input.setCancelAllowed(true);