mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
1) AllZoneUtil.java - add a function rearrangeTopOfLibrary(Player, numCards, shuffle?);
2) update Natural Selection to use this new function
This commit is contained in:
@@ -284,4 +284,49 @@ public class AllZoneUtil {
|
|||||||
return c.isArtifact();
|
return c.isArtifact();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//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
|
||||||
|
* may also specify a shuffle when done
|
||||||
|
*
|
||||||
|
* @param player the player to target (currently *cannot* be Computer - no effect)
|
||||||
|
* @param numCards the number of cards from the top to rearrange
|
||||||
|
* @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) {
|
||||||
|
if(player.equals(Constant.Player.Human)) {
|
||||||
|
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
||||||
|
int maxCards = lib.size();
|
||||||
|
maxCards = Math.min(maxCards, numCards);
|
||||||
|
if(maxCards == 0) return;
|
||||||
|
CardList topCards = new CardList();
|
||||||
|
//show top n cards:
|
||||||
|
for(int j = 0; j < maxCards; 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 {
|
||||||
|
//this does not and is not expected to work for the AI at this time
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17767,52 +17767,34 @@ public class CardFactory implements NewConstants {
|
|||||||
|
|
||||||
|
|
||||||
//*************** START *********** START **************************
|
//*************** START *********** START **************************
|
||||||
|
|
||||||
else if(cardName.equals("Natural Selection")) {
|
else if(cardName.equals("Natural Selection")) {
|
||||||
/* Look at the top 3 cards of target player's library and put them
|
/* Look at the top 3 cards of target player's library and put them
|
||||||
* back in any order. You may have that player shuffle his or
|
* back in any order. You may have that player shuffle his or
|
||||||
* her library */
|
* her library */
|
||||||
|
|
||||||
final SpellAbility spell = new Spell(card) {
|
final SpellAbility spell = new Spell(card) {
|
||||||
private static final long serialVersionUID = 8649520296192617609L;
|
private static final long serialVersionUID = 8649520296192617609L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
String player = getTargetPlayer();
|
String player = getTargetPlayer();
|
||||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
AllZoneUtil.rearrangeTopOfLibrary(player, 3, false);
|
||||||
if(lib.size() < 3) return;
|
String[] choices = new String[] {"Yes", "No"};
|
||||||
CardList topThree = new CardList();
|
Object o = AllZone.Display.getChoice("Shuffle target player's library?", choices);
|
||||||
//show top 3 cards:
|
String myChoice = (String) o;
|
||||||
topThree.add(lib.get(0));
|
if(myChoice.equals("Yes")) {
|
||||||
topThree.add(lib.get(1));
|
AllZone.GameAction.shuffle(player);
|
||||||
topThree.add(lib.get(2));
|
}
|
||||||
for(int i = 1; i <= 3; i++) {
|
}
|
||||||
String Title = "Put on top: ";
|
@Override
|
||||||
if(i == 2) Title = "Put second from top: ";
|
public boolean canPlayAI() {
|
||||||
if(i == 3) Title = "Put third from top: ";
|
//basically the same reason as Sensei's Diving Top
|
||||||
Object o = AllZone.Display.getChoiceOptional(Title, topThree.toArray());
|
return false;
|
||||||
if(o == null) break;
|
}
|
||||||
Card c_1 = (Card) o;
|
};//spell
|
||||||
topThree.remove(c_1);
|
card.clearSpellAbility();
|
||||||
lib.remove(c_1);
|
card.addSpellAbility(spell);
|
||||||
lib.add(c_1, i - 1);
|
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
|
||||||
}
|
|
||||||
String[] choices = new String[] {"Yes", "No"};
|
|
||||||
Object o = AllZone.Display.getChoice("Shuffle target player's library?", choices);
|
|
||||||
String myChoice = (String) o;
|
|
||||||
if(myChoice.equals("Yes")) {
|
|
||||||
AllZone.GameAction.shuffle(getTargetPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean canPlayAI() {
|
|
||||||
//basically the same reason as Sensei's Diving Top
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};//spell
|
|
||||||
card.clearSpellAbility();
|
|
||||||
card.addSpellAbility(spell);
|
|
||||||
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
|
|
||||||
}
|
}
|
||||||
//*************** END ************ END **************************
|
//*************** END ************ END **************************
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user