mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Use chooseEntitiesForEffect for dig (except and/or dig)
This commit is contained in:
@@ -164,8 +164,20 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
public <T extends GameEntity> List<T> chooseEntitiesForEffect(
|
public <T extends GameEntity> List<T> chooseEntitiesForEffect(
|
||||||
FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title,
|
FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title,
|
||||||
Player targetedPlayer) {
|
Player targetedPlayer) {
|
||||||
// this isn't used
|
if (delayedReveal != null) {
|
||||||
return null;
|
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix());
|
||||||
|
}
|
||||||
|
FCollection<T> remaining = new FCollection<T>(optionList);
|
||||||
|
List<T> selecteds = new ArrayList<T>();
|
||||||
|
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
|
@Override
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if (p == chooser && destZone1ChangeNum > 1) {
|
||||||
delayedReveal = null;
|
delayedReveal = null;
|
||||||
}
|
}
|
||||||
@@ -238,10 +238,11 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
if (sa.hasParam("RandomOrder")) {
|
if (sa.hasParam("RandomOrder")) {
|
||||||
CardLists.shuffle(movedCards);
|
CardLists.shuffle(movedCards);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String prompt;
|
String prompt;
|
||||||
|
|
||||||
|
if (!andOrValid.equals("")) { // pfps: old way - to be fixed soon
|
||||||
|
|
||||||
if (sa.hasParam("PrimaryPrompt")) {
|
if (sa.hasParam("PrimaryPrompt")) {
|
||||||
prompt = sa.getParam("PrimaryPrompt");
|
prompt = sa.getParam("PrimaryPrompt");
|
||||||
} else {
|
} else {
|
||||||
@@ -270,11 +271,7 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
chooser.getController().notifyOfValue(sa, null, "No valid cards");
|
chooser.getController().notifyOfValue(sa, null, "No valid cards");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (chosen == null) { break; }
|
||||||
if (chosen == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
movedCards.add(chosen);
|
movedCards.add(chosen);
|
||||||
valid.remove(chosen);
|
valid.remove(chosen);
|
||||||
if (!andOrValid.equals("")) {
|
if (!andOrValid.equals("")) {
|
||||||
@@ -288,6 +285,37 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} 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<Card> 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")) {
|
if (!changeValid.isEmpty() && !sa.hasParam("ExileFaceDown") && !sa.hasParam("NoReveal")) {
|
||||||
game.getAction().reveal(movedCards, chooser, true,
|
game.getAction().reveal(movedCards, chooser, true,
|
||||||
chooser + " picked " + (movedCards.size() == 1 ? "this card" : "these cards") + " from ");
|
chooser + " picked " + (movedCards.size() == 1 ? "this card" : "these cards") + " from ");
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ public abstract class PlayerController {
|
|||||||
public Player getPlayer() { return player; }
|
public Player getPlayer() { return player; }
|
||||||
public LobbyPlayer getLobbyPlayer() { return lobbyPlayer; }
|
public LobbyPlayer getLobbyPlayer() { return lobbyPlayer; }
|
||||||
|
|
||||||
|
public void tempShowCards(final Iterable<Card> cards) { } // show cards in UI until ended
|
||||||
|
public void endTempShowCards() { }
|
||||||
|
|
||||||
public final SpellAbility getAbilityToPlay(final Card hostCard, final List<SpellAbility> abilities) { return getAbilityToPlay(hostCard, abilities, null); }
|
public final SpellAbility getAbilityToPlay(final Card hostCard, final List<SpellAbility> abilities) { return getAbilityToPlay(hostCard, abilities, null); }
|
||||||
public abstract SpellAbility getAbilityToPlay(Card hostCard, List<SpellAbility> abilities, ITriggerEvent triggerEvent);
|
public abstract SpellAbility getAbilityToPlay(Card hostCard, List<SpellAbility> abilities, ITriggerEvent triggerEvent);
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
c.setMayLookAt(player, true, true);
|
c.setMayLookAt(player, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tempShowCards(final Iterable<Card> cards) {
|
@Override
|
||||||
|
public void tempShowCards(final Iterable<Card> cards) {
|
||||||
if (mayLookAtAllCards) {
|
if (mayLookAtAllCards) {
|
||||||
return;
|
return;
|
||||||
} // no needed if this is set
|
} // 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()) {
|
if (tempShownCards.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -479,11 +481,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useSelectCardsInput(optionList)) {
|
if (useSelectCardsInput(optionList)) {
|
||||||
if (delayedReveal != null) {
|
// if (delayedReveal != null) {
|
||||||
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(),
|
// reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(),
|
||||||
delayedReveal.getMessagePrefix());
|
// delayedReveal.getMessagePrefix());
|
||||||
}
|
//}
|
||||||
tempShow(optionList);
|
tempShow(optionList);
|
||||||
|
if (delayedReveal != null) {
|
||||||
|
tempShow(delayedReveal.getCards());
|
||||||
|
}
|
||||||
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, min, max,
|
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, min, max,
|
||||||
optionList, sa);
|
optionList, sa);
|
||||||
input.setCancelAllowed(true);
|
input.setCancelAllowed(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user