mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
break out more reusable code to GameAction.promptForShuffle(Player);
updated Natural Selection to exercise this new function
This commit is contained in:
@@ -287,46 +287,41 @@ public class AllZoneUtil {
|
|||||||
|
|
||||||
//zone manipulation, maybe be better off in GameAction.java...
|
//zone manipulation, maybe be better off in GameAction.java...
|
||||||
/**
|
/**
|
||||||
* use this when you need to rearrange the top X cards in a player's library. You
|
* use this when Human needs to rearrange the top X cards in a player's library. You
|
||||||
* may also specify a shuffle when done
|
* may also specify a shuffle when done
|
||||||
*
|
*
|
||||||
* @param player the player to target (currently *cannot* be Computer - no effect)
|
* @param player the player to target
|
||||||
* @param numCards the number of cards from the top to rearrange
|
* @param numCards the number of cards from the top to rearrange
|
||||||
* @param shuffle true if a shuffle is desired at the end, false otherwise
|
* @param shuffle true if a shuffle is desired at the end, false otherwise
|
||||||
*/
|
*/
|
||||||
public static void rearrangeTopOfLibrary(final String player, final int numCards, boolean shuffle) {
|
public static void rearrangeTopOfLibrary(final String player, final int numCards, boolean shuffle) {
|
||||||
if(player.equals(Constant.Player.Human)) {
|
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
||||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
int maxCards = lib.size();
|
||||||
int maxCards = lib.size();
|
maxCards = Math.min(maxCards, numCards);
|
||||||
maxCards = Math.min(maxCards, numCards);
|
if(maxCards == 0) return;
|
||||||
if(maxCards == 0) return;
|
CardList topCards = new CardList();
|
||||||
CardList topCards = new CardList();
|
//show top n cards:
|
||||||
//show top n cards:
|
for(int j = 0; j < maxCards; j++ ) {
|
||||||
for(int j = 0; j < maxCards; j++ ) {
|
topCards.add(lib.get(j));
|
||||||
topCards.add(lib.get(j));
|
|
||||||
}
|
|
||||||
for(int i = 1; i <= maxCards; i++) {
|
|
||||||
String suffix = "";
|
|
||||||
switch(i) {
|
|
||||||
case 1: suffix="st"; break;
|
|
||||||
case 2: suffix="nd"; break;
|
|
||||||
case 3: suffix="rd"; break;
|
|
||||||
default: suffix="th";
|
|
||||||
}
|
|
||||||
String title = "Put "+i+suffix+" in Library: ";
|
|
||||||
Object o = AllZone.Display.getChoiceOptional(title, topCards.toArray());
|
|
||||||
if(o == null) break;
|
|
||||||
Card c_1 = (Card) o;
|
|
||||||
topCards.remove(c_1);
|
|
||||||
lib.remove(c_1);
|
|
||||||
lib.add(c_1, i - 1);
|
|
||||||
}
|
|
||||||
if(shuffle) {
|
|
||||||
AllZone.GameAction.shuffle(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
for(int i = 1; i <= maxCards; i++) {
|
||||||
//this does not and is not expected to work for the AI at this time
|
String suffix = "";
|
||||||
|
switch(i) {
|
||||||
|
case 1: suffix="st"; break;
|
||||||
|
case 2: suffix="nd"; break;
|
||||||
|
case 3: suffix="rd"; break;
|
||||||
|
default: suffix="th";
|
||||||
|
}
|
||||||
|
String title = "Put "+i+suffix+" in Library: ";
|
||||||
|
Object o = AllZone.Display.getChoiceOptional(title, topCards.toArray());
|
||||||
|
if(o == null) break;
|
||||||
|
Card c_1 = (Card) o;
|
||||||
|
topCards.remove(c_1);
|
||||||
|
lib.remove(c_1);
|
||||||
|
lib.add(c_1, i - 1);
|
||||||
|
}
|
||||||
|
if(shuffle) {
|
||||||
|
AllZone.GameAction.shuffle(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17779,12 +17779,7 @@ public class CardFactory implements NewConstants {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
String player = getTargetPlayer();
|
String player = getTargetPlayer();
|
||||||
AllZoneUtil.rearrangeTopOfLibrary(player, 3, false);
|
AllZoneUtil.rearrangeTopOfLibrary(player, 3, false);
|
||||||
String[] choices = new String[] {"Yes", "No"};
|
AllZone.GameAction.promptForShuffle(player);
|
||||||
Object o = AllZone.Display.getChoice("Shuffle target player's library?", choices);
|
|
||||||
String myChoice = (String) o;
|
|
||||||
if(myChoice.equals("Yes")) {
|
|
||||||
AllZone.GameAction.shuffle(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
|
|||||||
Reference in New Issue
Block a user