updating calls to GameAction.shuffle (part 4)

This commit is contained in:
jendave
2011-08-06 09:38:56 +00:00
parent 281be1452c
commit 13c52d949e
2 changed files with 105 additions and 163 deletions

View File

@@ -58,7 +58,7 @@ public class CardFactory_Sorceries {
}
// Shuffle library
AllZone.GameAction.shuffle(player);
player.shuffle();
// Draw seven cards
player.drawCards(7);
@@ -532,12 +532,11 @@ public class CardFactory_Sorceries {
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
AllZone.GameAction.moveTo(hand, (Card) check);
}
AllZone.GameAction.shuffle(AllZone.HumanPlayer);
AllZone.HumanPlayer.shuffle();
//lose 3 life
if(cardName.equals("Grim Tutor")) {
Player player = AllZone.HumanPlayer;
//PlayerLife life = AllZone.GameAction.getPlayerLife(player);
player.subtractLife(3,card);
}
}
@@ -549,14 +548,12 @@ public class CardFactory_Sorceries {
//pick best creature
Card c = CardFactoryUtil.AI_getBestCreature(list);
if(c == null) c = library[0];
//System.out.println("comptuer picked - " +c);
AllZone.Computer_Library.remove(c);
AllZone.Computer_Hand.add(c);
//lose 3 life
if(cardName.equals("Grim Tutor")) {
Player player = AllZone.ComputerPlayer;
//PlayerLife life = AllZone.GameAction.getPlayerLife(player);
player.subtractLife(3,card);
}
}
@@ -867,7 +864,7 @@ public class CardFactory_Sorceries {
//shuffle card back into the library
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
library.add(card);
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
}
}//resolve()
@@ -1407,7 +1404,7 @@ public class CardFactory_Sorceries {
Player player = AllZone.Phase.getActivePlayer();
PlayerZone Play = AllZone.getZone(Constant.Zone.Play, player);
Card Minds_D = card;
if(player.isHuman()) AllZone.GameAction.shuffle(card.getController());
if(player.isHuman()) card.getController().shuffle();
CardList MindsList = new CardList(Play.getCards());
MindsList = MindsList.getName("Mind's Desire");
MindsList.remove(card);
@@ -1719,7 +1716,7 @@ public class CardFactory_Sorceries {
if(dragons.size() != 0) {
Object o = AllZone.Display.getChoiceOptional("Select an Dragon to put onto the battlefield", dragons.toArray());
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
if(o != null) {
//put card in hand
AllZone.Human_Library.remove(o);
@@ -1741,7 +1738,7 @@ public class CardFactory_Sorceries {
if(dragons.size() != 0) {
CardListUtil.sortAttack(dragons);
Card c = dragons.get(0);
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
//move to hand
AllZone.Computer_Library.remove(c);
AllZone.Computer_Play.add(c);
@@ -2956,7 +2953,7 @@ public class CardFactory_Sorceries {
play.add(c);
AllZone.GameAction.shuffle(opponent);
opponent.shuffle();
}//resolve()
};
@@ -3079,7 +3076,7 @@ public class CardFactory_Sorceries {
creature = creature.getType("Creature");
if(creature.size() != 0) {
Card c = creature.get(0);
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
//move to top of library
AllZone.Computer_Library.remove(c);
@@ -3100,7 +3097,7 @@ public class CardFactory_Sorceries {
if(list.size() != 0) {
Object o = AllZone.Display.getChoiceOptional("Select a creature", list.toArray());
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
if(o != null) {
//put creature on top of library
library.remove(o);
@@ -3825,7 +3822,7 @@ public class CardFactory_Sorceries {
library.add(g[i], 0);
}
// Shuffle library
AllZone.GameAction.shuffle(player);;
player.shuffle();;
}
@Override
@@ -3939,16 +3936,14 @@ public class CardFactory_Sorceries {
c = creature.get(0);
}
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
//move to top of library
AllZone.Computer_Library.remove(c);
AllZone.Computer_Library.add(c, 0);
//lose 2 life
Player player = AllZone.ComputerPlayer;
//PlayerLife life = AllZone.GameAction.getPlayerLife(player);
player.subtractLife(2,card);
AllZone.ComputerPlayer.subtractLife(2,card);
}
}//computerResolve()
@@ -3960,16 +3955,14 @@ public class CardFactory_Sorceries {
if(list.size() != 0) {
Object o = AllZone.Display.getChoiceOptional("Select a card", list.toArray());
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
if(o != null) {
//put card on top of library
library.remove(o);
library.add((Card) o, 0);
}
//lose 2 life
Player player = AllZone.HumanPlayer;
//PlayerLife life = AllZone.GameAction.getPlayerLife(player);
player.subtractLife(2,card);
AllZone.HumanPlayer.subtractLife(2,card);
}//if
@@ -4480,7 +4473,7 @@ public class CardFactory_Sorceries {
Card crd = CardFactoryUtil.AI_getBestArtifact(list);
lib.remove(crd);
play.add(crd);
AllZone.GameAction.shuffle(AllZone.ComputerPlayer);
AllZone.ComputerPlayer.shuffle();
}
} else //human
{
@@ -4499,22 +4492,12 @@ public class CardFactory_Sorceries {
play.add(crd);
}
AllZone.GameAction.shuffle(AllZone.HumanPlayer);
AllZone.HumanPlayer.shuffle();
}
}
}//if isCardInPlay
}
};
/*
final Command sac = new Command()
{
private static final long serialVersionUID = -8925816099640324876L;
public void execute() {
AllZone.GameAction.sacrifice(spell.getTargetCard());
}
};
*/
Input runtime = new Input() {
private static final long serialVersionUID = -4653972223582155502L;
@@ -5365,7 +5348,7 @@ public class CardFactory_Sorceries {
// shuffle back into library
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
library.add(card);
AllZone.GameAction.shuffle(card.getController());
card.getController().shuffle();
}//resolve()
@@ -6135,7 +6118,7 @@ public class CardFactory_Sorceries {
lib.add(toLib);
}
}
AllZone.GameAction.shuffle(target);
target.shuffle();
}
@Override
@@ -6255,7 +6238,7 @@ public class CardFactory_Sorceries {
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
AllZone.GameAction.moveTo(grave, (Card) check);
}
AllZone.GameAction.shuffle(AllZone.HumanPlayer);
AllZone.HumanPlayer.shuffle();
}
} // humanResolve
@@ -7933,7 +7916,7 @@ public class CardFactory_Sorceries {
}
// Shuffle library
AllZone.GameAction.shuffle(player);
player.shuffle();
player.drawCards(handSize);
}

View File

@@ -4,7 +4,6 @@ package forge;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -13,7 +12,6 @@ import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import com.esotericsoftware.minlog.Log;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT;
@@ -1898,86 +1896,86 @@ public class GameAction {
}
Card[] Search (Card Source, Card Initiator ,String[] Keyword_Details, final String[] Custom_Strings) {
String SearchDescription = " ";
boolean SearchLib = true;
if(Keyword_Details[7].contains("Choice_Instant-SearchLibrary")) {
if(Source.getController().equals(AllZone.HumanPlayer)) {
Object[] possibleValues = {"Yes", "No"};
Object q = JOptionPane.showOptionDialog(null, "Search Libraries?",Source.getName() + " F_SpellAbility",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, possibleValues, possibleValues[0]);
if(q.equals(1)) {
SearchLib = false;
}
}
}
int Target_Conditions = 1;
String TargetParse = Keyword_Details[5];
String Targets[] = TargetParse.split("!");
Target_Conditions = Targets.length;
Player Zone_Owner = Source.getController();
Card SearchedCard[] = new Card[Target_Conditions];
for(int y = 0; y < Target_Conditions; y++) {
if(Targets[y].contains("SearchShuffle") /** && Keyword_Details[4] != "Null" **/) {
if(Targets[y].contains("OSearchShuffle")) {
Zone_Owner = Source.getController().getOpponent();
SearchDescription = SearchDescription + "Opponent's ";
}
else Zone_Owner = Source.getController();
String SearchParse = Targets[y];
String Search[] = SearchParse.split("/");
String[] SearchZone = new String[Search.length - 1];
PlayerZone[] PZones = new PlayerZone[SearchZone.length];
CardList SearchBase = new CardList();
for(int z = 0; z < PZones.length; z++) {
SearchZone[z] = Search[z+1];
if(SearchZone[z].equals("Hand")) PZones[z] = AllZone.getZone(Constant.Zone.Hand, Zone_Owner);
if(SearchZone[z].equals("Graveyard")) PZones[z] = AllZone.getZone(Constant.Zone.Graveyard, Zone_Owner);
if(SearchZone[z].equals("Play")) PZones[z] = AllZone.getZone(Constant.Zone.Play, Zone_Owner);
if(SearchZone[z].contains("Library") && SearchLib) PZones[z] = AllZone.getZone(Constant.Zone.Library, Zone_Owner);
if(SearchZone[z].contains("Exiled")) PZones[z] = AllZone.getZone(Constant.Zone.Removed_From_Play, Zone_Owner);
// if(ZoneConditions[z].contains("Sideboard")) PZones[z] = AllZone.getZone(Constant.Zone.Sideboard, Zone_Owner);
if(PZones[z] != null) {
SearchBase.addAll(PZones[z].getCards());
SearchDescription = SearchDescription + SearchZone[z] + " ";
}
if(z + 2 < PZones.length && PZones[z] != null) SearchDescription = SearchDescription + ", ";
else if(z + 2 == PZones.length) SearchDescription = SearchDescription + "and ";
}
@SuppressWarnings("unused")
Object check2 = AllZone.Display.getChoiceOptional("View" + SearchDescription,
SearchBase.toArray());
if(Search[0].contains("SearchShuffle_SameName")) SearchBase = SearchBase.getName(Initiator.getName());
if(Search[0].contains("SearchShuffle_Type")) {
for(int TypeRestrict = 0; TypeRestrict < Custom_Strings.length; TypeRestrict ++) {
if(Custom_Strings[TypeRestrict].startsWith("Type")) SearchBase = SearchBase.getType(Custom_Strings[TypeRestrict].replaceFirst("Type", ""));
if(Custom_Strings[TypeRestrict].startsWith("Color")) {
final int Number = TypeRestrict;
SearchBase = SearchBase.filter(new CardListFilter() {
public boolean addCard(Card c) {
if(CardUtil.getColors(c).contains(Custom_Strings[Number].replaceFirst("Color", ""))) return true;
return false;
}
});
}
}
}
if(SearchBase.size() != 0) {
Object check = AllZone.Display.getChoiceOptional("Select a Suitable Card",
SearchBase.toArray());
if(check != null) {
SearchedCard[y] = (Card) check;
if(SearchLib) AllZone.GameAction.shuffle(((Card) check).getController());
}
} else {
JOptionPane.showMessageDialog(null, "No suitable cards in" + SearchDescription, "", JOptionPane.INFORMATION_MESSAGE);
if(SearchLib && Targets[y].contains("OSearchShuffle")) AllZone.GameAction.shuffle(Source.getController().getOpponent());
else if(SearchLib) AllZone.GameAction.shuffle((Source.getController()));
}
}
}
return SearchedCard;
String SearchDescription = " ";
boolean SearchLib = true;
if(Keyword_Details[7].contains("Choice_Instant-SearchLibrary")) {
if(Source.getController().equals(AllZone.HumanPlayer)) {
Object[] possibleValues = {"Yes", "No"};
Object q = JOptionPane.showOptionDialog(null, "Search Libraries?",Source.getName() + " F_SpellAbility",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, possibleValues, possibleValues[0]);
if(q.equals(1)) {
SearchLib = false;
}
}
}
int Target_Conditions = 1;
String TargetParse = Keyword_Details[5];
String Targets[] = TargetParse.split("!");
Target_Conditions = Targets.length;
Player Zone_Owner = Source.getController();
Card SearchedCard[] = new Card[Target_Conditions];
for(int y = 0; y < Target_Conditions; y++) {
if(Targets[y].contains("SearchShuffle") /** && Keyword_Details[4] != "Null" **/) {
if(Targets[y].contains("OSearchShuffle")) {
Zone_Owner = Source.getController().getOpponent();
SearchDescription = SearchDescription + "Opponent's ";
}
else Zone_Owner = Source.getController();
String SearchParse = Targets[y];
String Search[] = SearchParse.split("/");
String[] SearchZone = new String[Search.length - 1];
PlayerZone[] PZones = new PlayerZone[SearchZone.length];
CardList SearchBase = new CardList();
for(int z = 0; z < PZones.length; z++) {
SearchZone[z] = Search[z+1];
if(SearchZone[z].equals("Hand")) PZones[z] = AllZone.getZone(Constant.Zone.Hand, Zone_Owner);
if(SearchZone[z].equals("Graveyard")) PZones[z] = AllZone.getZone(Constant.Zone.Graveyard, Zone_Owner);
if(SearchZone[z].equals("Play")) PZones[z] = AllZone.getZone(Constant.Zone.Play, Zone_Owner);
if(SearchZone[z].contains("Library") && SearchLib) PZones[z] = AllZone.getZone(Constant.Zone.Library, Zone_Owner);
if(SearchZone[z].contains("Exiled")) PZones[z] = AllZone.getZone(Constant.Zone.Removed_From_Play, Zone_Owner);
// if(ZoneConditions[z].contains("Sideboard")) PZones[z] = AllZone.getZone(Constant.Zone.Sideboard, Zone_Owner);
if(PZones[z] != null) {
SearchBase.addAll(PZones[z].getCards());
SearchDescription = SearchDescription + SearchZone[z] + " ";
}
if(z + 2 < PZones.length && PZones[z] != null) SearchDescription = SearchDescription + ", ";
else if(z + 2 == PZones.length) SearchDescription = SearchDescription + "and ";
}
@SuppressWarnings("unused")
Object check2 = AllZone.Display.getChoiceOptional("View" + SearchDescription,
SearchBase.toArray());
if(Search[0].contains("SearchShuffle_SameName")) SearchBase = SearchBase.getName(Initiator.getName());
if(Search[0].contains("SearchShuffle_Type")) {
for(int TypeRestrict = 0; TypeRestrict < Custom_Strings.length; TypeRestrict ++) {
if(Custom_Strings[TypeRestrict].startsWith("Type")) SearchBase = SearchBase.getType(Custom_Strings[TypeRestrict].replaceFirst("Type", ""));
if(Custom_Strings[TypeRestrict].startsWith("Color")) {
final int Number = TypeRestrict;
SearchBase = SearchBase.filter(new CardListFilter() {
public boolean addCard(Card c) {
if(CardUtil.getColors(c).contains(Custom_Strings[Number].replaceFirst("Color", ""))) return true;
return false;
}
});
}
}
}
if(SearchBase.size() != 0) {
Object check = AllZone.Display.getChoiceOptional("Select a Suitable Card",
SearchBase.toArray());
if(check != null) {
SearchedCard[y] = (Card) check;
if(SearchLib) ((Card) check).getController().shuffle();
}
} else {
JOptionPane.showMessageDialog(null, "No suitable cards in" + SearchDescription, "", JOptionPane.INFORMATION_MESSAGE);
if(SearchLib && Targets[y].contains("OSearchShuffle")) Source.getController().getOpponent().shuffle();
else if(SearchLib) Source.getController().shuffle();
}
}
}
return SearchedCard;
}
String[] Search_Description(Card Initiator ,String[] Keyword_Details, final String[] Custom_Strings) {
@@ -2244,7 +2242,7 @@ public class GameAction {
else if(c.getName().equals("Guan Yu, Sainted Warrior")) {
PlayerZone library = AllZone.getZone(Constant.Zone.Library, c.getOwner());
moveTo(library, c);
AllZone.GameAction.shuffle(c.getOwner());
c.getOwner().shuffle();
}
}//sacrificeDestroy()
@@ -2468,45 +2466,6 @@ public class GameAction {
|| PlayerZoneUtil.isCardInZone(AllZone.Human_Removed, c);
}
//TODO: shuffling seems to change a card's unique number but i'm not 100% sure
@Deprecated
public void shuffle(Player player) {
player.shuffle();
/*
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
Card c[] = library.getCards();
if(c.length <= 1) return;
ArrayList<Object> list = new ArrayList<Object>(Arrays.asList(c));
//overdone but wanted to make sure it was really random
Random random = new Random();
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Object o;
for(int i = 0; i < list.size(); i++) {
o = list.remove(random.nextInt(list.size()));
list.add(random.nextInt(list.size()), o);
}
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
list.toArray(c);
library.setCards(c);
*/
}//shuffle
/**
* prompts Human to see if a target player's library should be shuffled. This should
* only be called when the choice is made by the Human (target can be either), then
@@ -2519,7 +2478,7 @@ public class GameAction {
Object o = AllZone.Display.getChoice("Shuffle "+player+"'s library?", choices);
String myChoice = (String) o;
if(myChoice.equals("Yes")) {
AllZone.GameAction.shuffle(player);
player.shuffle();
}
}
@@ -2665,7 +2624,7 @@ public class GameAction {
}//end re-numbering
for(int i = 0; i < 100; i++)
this.shuffle(AllZone.HumanPlayer);
AllZone.HumanPlayer.shuffle();
//do this instead of shuffling Computer's deck
boolean smoothLand = Constant.Runtime.Smooth[0];
@@ -2675,7 +2634,7 @@ public class GameAction {
AllZone.Computer_Library.setCards(c);
} else {
AllZone.Computer_Library.setCards(AllZone.Computer_Library.getCards());
this.shuffle(AllZone.ComputerPlayer);
AllZone.ComputerPlayer.shuffle();
}
// Only cut/coin toss if it's the first game of the match
@@ -3564,7 +3523,7 @@ public class GameAction {
aiSearchTwoLand(type, Zone1, tapFirstLand, Zone2, tapSecondLand);
}
AllZone.GameAction.shuffle(player);
player.shuffle();
}
public void searchLibraryTwoBasicLand(Player player,