more code simplification in CF_Sorceries

This commit is contained in:
jendave
2011-08-07 00:47:13 +00:00
parent a4741b480d
commit 40a292f974

View File

@@ -133,72 +133,18 @@ public class CardFactory_Sorceries {
}//*************** END ************ END ************************** }//*************** END ************ END **************************
/*
//*************** START *********** START **************************
//should REALLY be an aura:
else if(cardName.equals("Lignify")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 5323770119451400755L;
@Override
public boolean canPlayAI() {
CardList c = CardFactoryUtil.AI_getHumanCreature(card, true);
CardListUtil.sortAttack(c);
CardListUtil.sortFlying(c);
if(c.isEmpty()) return false;
if(2 <= c.get(0).getNetAttack() && c.get(0).getKeyword().contains("Flying")) {
setTargetCard(c.get(0));
return true;
}
CardListUtil.sortAttack(c);
if(4 <= c.get(0).getNetAttack()) {
setTargetCard(c.get(0));
return true;
}
return false;
}//canPlayAI()
@Override
public void resolve() {
Card c = getTargetCard();
if(AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) {
c.setBaseAttack(0);
c.setBaseDefense(4);
c.setType(new ArrayList<String>());
c.addType("Creature");
c.addType("Treefolk");
c.setIntrinsicKeyword(new ArrayList<String>());
c.clearSpellAbility();
}
}//resolve()
};//SpellAbility
// Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
}//*************** END ************ END **************************
*/
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Identity Crisis")) { else if(cardName.equals("Identity Crisis")) {
final SpellAbility spell = new Spell(card) { Target t = new Target(card, "Select target player", "Player");
Cost cost = new Cost("2 W W B B", cardName, false);
final SpellAbility spell = new Spell(card, cost, t) {
private static final long serialVersionUID = 42470566751344693L; private static final long serialVersionUID = 42470566751344693L;
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
Player player = getTargetPlayer(); Player player = AllZone.HumanPlayer;
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player); CardList libList = AllZoneUtil.getPlayerCardsInLibrary(player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0; return libList.size() > 0;
} }
@@ -206,27 +152,22 @@ public class CardFactory_Sorceries {
public void resolve() { public void resolve() {
Player player = getTargetPlayer(); Player player = getTargetPlayer();
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); CardList handList = AllZoneUtil.getPlayerHand(player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player); CardList graveList = AllZoneUtil.getPlayerGraveyard(player);
PlayerZone exiled = AllZone.getZone(Constant.Zone.Exile, player);
CardList handList = new CardList(hand.getCards());
CardList graveList = new CardList(grave.getCards());
int max = handList.size(); int max = handList.size();
for(int i = 0; i < max; i++) { for(int i = 0; i < max; i++) {
Card c = handList.get(i); Card c = handList.get(i);
hand.remove(c); AllZone.GameAction.exile(c);
exiled.add(c);
} }
int grv = graveList.size(); int grv = graveList.size();
for(int i = 0; i < grv; i++) { for(int i = 0; i < grv; i++) {
Card c = graveList.get(i); Card c = graveList.get(i);
grave.remove(c); AllZone.GameAction.exile(c);
exiled.add(c);
} }
} }
};//SpellAbility };//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell)); spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
// Do not remove SpellAbilities created by AbilityFactory or Keywords. // Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility(); card.clearFirstSpellAbility();
@@ -335,32 +276,29 @@ public class CardFactory_Sorceries {
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Ignite Memories")) { else if(cardName.equals("Ignite Memories")) {
SpellAbility spell = new Spell(card) { Target t = new Target(card, "Select target player", "Player");
Cost cost = new Cost("4 R", cardName, false);
SpellAbility spell = new Spell(card, cost, t) {
private static final long serialVersionUID = 143904782338241969L; private static final long serialVersionUID = 143904782338241969L;
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
return AllZone.Phase.getPhase().equals(Constant.Phase.Main2); return AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
} }
@Override @Override
public void resolve() { public void resolve() {
Card choice = null;
Player player = getTargetPlayer(); Player player = getTargetPlayer();
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); CardList handChoices = AllZoneUtil.getPlayerHand(player);
Card[] handChoices = hand.getCards(); if (handChoices.size() > 0) {
if (handChoices.length > 0) Card choice = CardUtil.getRandom(handChoices.toArray());
{ GuiUtils.getChoice("Random card", new CardList(choice));
choice = CardUtil.getRandom(handChoices);
handChoices[0] = choice;
for(int i = 1; i < handChoices.length; i++) {
handChoices[i] = null;
}
GuiUtils.getChoice("Random card", handChoices);
player.addDamage(CardUtil.getConvertedManaCost(choice.getManaCost()), card); player.addDamage(CardUtil.getConvertedManaCost(choice.getManaCost()), card);
} }
}//resolve() }//resolve()
}; };
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
// Do not remove SpellAbilities created by AbilityFactory or Keywords. // Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility(); card.clearFirstSpellAbility();
@@ -368,11 +306,8 @@ public class CardFactory_Sorceries {
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Roiling Terrain")) { else if(cardName.equals("Roiling Terrain")) {
//SpellAbility spell = new Spell(card) {
Cost cost = new Cost("2 R R", cardName, false); Cost cost = new Cost("2 R R", cardName, false);
final Target tgt = new Target(card, "Select a Land", "Land".split(",")); final Target tgt = new Target(card, "Select a Land", "Land".split(","));
@@ -393,8 +328,7 @@ public class CardFactory_Sorceries {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList land = new CardList(AllZone.Human_Battlefield.getCards()); CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
land = land.getType("Land");
if (land.size() != 0) if (land.size() != 0)
return false; return false;
@@ -520,15 +454,14 @@ public class CardFactory_Sorceries {
PlayerZone Play = AllZone.getZone(Constant.Zone.Battlefield, player); PlayerZone Play = AllZone.getZone(Constant.Zone.Battlefield, player);
Card Minds_D = card; Card Minds_D = card;
if(player.isHuman()) card.getController().shuffle(); if(player.isHuman()) card.getController().shuffle();
CardList MindsList = new CardList(Play.getCards()); CardList MindsList = AllZoneUtil.getPlayerCardsInPlay(player);
MindsList = MindsList.getName("Mind's Desire"); MindsList = MindsList.getName("Mind's Desire");
MindsList.remove(card); MindsList.remove(card);
if(MindsList.size() > 0) { if(MindsList.size() > 0) {
Play.remove(card); Play.remove(card);
Minds_D = MindsList.get(0); Minds_D = MindsList.get(0);
} else JOptionPane.showMessageDialog(null, "Click Mind's Desire to see the available cards to play without paying its mana cost.", "", JOptionPane.INFORMATION_MESSAGE); } else JOptionPane.showMessageDialog(null, "Click Mind's Desire to see the available cards to play without paying its mana cost.", "", JOptionPane.INFORMATION_MESSAGE);
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player); CardList libList = AllZoneUtil.getPlayerCardsInLibrary(player);
CardList libList = new CardList(lib.getCards());
Card c = null; Card c = null;
if(libList.size() > 0) { if(libList.size() > 0) {
c = libList.get(0); c = libList.get(0);
@@ -572,165 +505,160 @@ public class CardFactory_Sorceries {
//*************** END ************ END ************************** //*************** END ************ END **************************
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Brilliant Ultimatum")) { else if(cardName.equals("Brilliant Ultimatum")) {
final SpellAbility spell = new Spell(card) { final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 1481112451519L; private static final long serialVersionUID = 1481112451519L;
@Override @Override
public void resolve() { public void resolve() {
Card choice = null; Card choice = null;
//check for no cards in hand on resolve //check for no cards in hand on resolve
PlayerZone Library = AllZone.getZone(Constant.Zone.Library, card.getController()); CardList lib = AllZoneUtil.getPlayerCardsInLibrary(card.getController());
CardList Lib = new CardList(Library.getCards()); CardList cards = new CardList();
PlayerZone Exile = AllZone.getZone(Constant.Zone.Exile, card.getController()); CardList exiled = new CardList();
CardList cards = new CardList(); if(lib.size() == 0) {
CardList Exiled = new CardList(); JOptionPane.showMessageDialog(null, "No more cards in library.", "", JOptionPane.INFORMATION_MESSAGE);
if(Lib.size() == 0) { return;
JOptionPane.showMessageDialog(null, "No more cards in library.", "", JOptionPane.INFORMATION_MESSAGE); }
return; int Count = 5;
} if(lib.size() < 5) Count = lib.size();
int Count = 5; for(int i = 0; i < Count; i++) cards.add(lib.get(i));
if(Lib.size() < 5) Count = Lib.size(); for(int i = 0; i < Count; i++) {
for(int i = 0; i < Count; i++) cards.add(Lib.get(i)); exiled.add(lib.get(i));
for(int i = 0; i < Count; i++) { AllZone.GameAction.exile(lib.get(i));
Exiled.add(Lib.get(i)); }
AllZone.GameAction.moveTo(Exile, Lib.get(i)); CardList Pile1 = new CardList();
} CardList Pile2 = new CardList();
CardList Pile1 = new CardList(); boolean stop = false;
CardList Pile2 = new CardList(); int Pile1CMC = 0;
boolean stop = false; int Pile2CMC = 0;
int Pile1CMC = 0;
int Pile2CMC = 0;
GuiUtils.getChoice("Revealing top " + Count + " cards of library: ", cards.toArray()); GuiUtils.getChoice("Revealing top " + Count + " cards of library: ", cards.toArray());
//Human chooses //Human chooses
if(card.getController().isComputer()) { if(card.getController().isComputer()) {
for(int i = 0; i < Count; i++) { for(int i = 0; i < Count; i++) {
if(stop == false) { if(stop == false) {
choice = GuiUtils.getChoiceOptional("Choose cards to put into the first pile: ", cards.toArray()); choice = GuiUtils.getChoiceOptional("Choose cards to put into the first pile: ", cards.toArray());
if(choice != null) { if(choice != null) {
Pile1.add(choice); Pile1.add(choice);
cards.remove(choice); cards.remove(choice);
Pile1CMC = Pile1CMC + CardUtil.getConvertedManaCost(choice); Pile1CMC = Pile1CMC + CardUtil.getConvertedManaCost(choice);
} }
else stop = true; else stop = true;
} }
} }
for(int i = 0; i < Count; i++) { for(int i = 0; i < Count; i++) {
if(!Pile1.contains(Exiled.get(i))) { if(!Pile1.contains(exiled.get(i))) {
Pile2.add(Exiled.get(i)); Pile2.add(exiled.get(i));
Pile2CMC = Pile2CMC + CardUtil.getConvertedManaCost(Exiled.get(i)); Pile2CMC = Pile2CMC + CardUtil.getConvertedManaCost(exiled.get(i));
} }
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("You have spilt the cards into the following piles" + "\r\n" + "\r\n"); sb.append("You have spilt the cards into the following piles" + "\r\n" + "\r\n");
sb.append("Pile 1: " + "\r\n"); sb.append("Pile 1: " + "\r\n");
for(int i = 0; i < Pile1.size(); i++) sb.append(Pile1.get(i).getName() + "\r\n"); for(int i = 0; i < Pile1.size(); i++) sb.append(Pile1.get(i).getName() + "\r\n");
sb.append("\r\n" + "Pile 2: " + "\r\n"); sb.append("\r\n" + "Pile 2: " + "\r\n");
for(int i = 0; i < Pile2.size(); i++) sb.append(Pile2.get(i).getName() + "\r\n"); for(int i = 0; i < Pile2.size(); i++) sb.append(Pile2.get(i).getName() + "\r\n");
JOptionPane.showMessageDialog(null, sb, "", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, sb, "", JOptionPane.INFORMATION_MESSAGE);
if(Pile1CMC >= Pile2CMC) { if(Pile1CMC >= Pile2CMC) {
JOptionPane.showMessageDialog(null, "Computer chooses the Pile 1", "", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Computer chooses the Pile 1", "", JOptionPane.INFORMATION_MESSAGE);
for(int i = 0; i < Pile1.size(); i++) { for(int i = 0; i < Pile1.size(); i++) {
ArrayList<SpellAbility> choices = Pile1.get(i).getBasicSpells(); ArrayList<SpellAbility> choices = Pile1.get(i).getBasicSpells();
for(SpellAbility sa:choices) { for(SpellAbility sa:choices) {
if(sa.canPlayAI()) { if(sa.canPlayAI()) {
ComputerUtil.playStackFree(sa); ComputerUtil.playStackFree(sa);
if(Pile1.get(i).isPermanent()) Exiled.remove(Pile1.get(i)); if(Pile1.get(i).isPermanent()) exiled.remove(Pile1.get(i));
break; break;
} }
} }
} }
} else { } else {
JOptionPane.showMessageDialog(null, "Computer chooses the Pile 2", "", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Computer chooses the Pile 2", "", JOptionPane.INFORMATION_MESSAGE);
for(int i = 0; i < Pile2.size(); i++) { for(int i = 0; i < Pile2.size(); i++) {
ArrayList<SpellAbility> choices = Pile2.get(i).getBasicSpells(); ArrayList<SpellAbility> choices = Pile2.get(i).getBasicSpells();
for(SpellAbility sa:choices) { for(SpellAbility sa:choices) {
if(sa.canPlayAI()) { if(sa.canPlayAI()) {
ComputerUtil.playStackFree(sa); ComputerUtil.playStackFree(sa);
if(Pile2.get(i).isPermanent()) Exiled.remove(Pile2.get(i)); if(Pile2.get(i).isPermanent()) exiled.remove(Pile2.get(i));
break; break;
} }
} }
} }
} }
} }
else{//Computer chooses (It picks the highest converted mana cost card and 1 random card.) else{//Computer chooses (It picks the highest converted mana cost card and 1 random card.)
Card biggest = Exiled.get(0); Card biggest = exiled.get(0);
for(Card c : Exiled) for(Card c : exiled)
if(CardUtil.getConvertedManaCost(biggest.getManaCost()) < CardUtil.getConvertedManaCost(c.getManaCost())) if(CardUtil.getConvertedManaCost(biggest.getManaCost()) < CardUtil.getConvertedManaCost(c.getManaCost()))
biggest = c; biggest = c;
Pile1.add(biggest); Pile1.add(biggest);
cards.remove(biggest); cards.remove(biggest);
if(cards.size() > 2) { if(cards.size() > 2) {
Card Random = CardUtil.getRandom(cards.toArray()); Card Random = CardUtil.getRandom(cards.toArray());
Pile1.add(Random); Pile1.add(Random);
} }
for(int i = 0; i < Count; i++) if(!Pile1.contains(Exiled.get(i))) Pile2.add(Exiled.get(i)); for(int i = 0; i < Count; i++) if(!Pile1.contains(exiled.get(i))) Pile2.add(exiled.get(i));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Choose a pile to add to your hand: " + "\r\n" + "\r\n"); sb.append("Choose a pile to add to your hand: " + "\r\n" + "\r\n");
sb.append("Pile 1: " + "\r\n"); sb.append("Pile 1: " + "\r\n");
for(int i = 0; i < Pile1.size(); i++) sb.append(Pile1.get(i).getName() + "\r\n"); for(int i = 0; i < Pile1.size(); i++) sb.append(Pile1.get(i).getName() + "\r\n");
sb.append("\r\n" + "Pile 2: " + "\r\n"); sb.append("\r\n" + "Pile 2: " + "\r\n");
for(int i = 0; i < Pile2.size(); i++) sb.append(Pile2.get(i).getName() + "\r\n"); for(int i = 0; i < Pile2.size(); i++) sb.append(Pile2.get(i).getName() + "\r\n");
Object[] possibleValues = {"Pile 1", "Pile 2"}; Object[] possibleValues = {"Pile 1", "Pile 2"};
Object q = JOptionPane.showOptionDialog(null, sb, "Brilliant Ultimatum", Object q = JOptionPane.showOptionDialog(null, sb, "Brilliant Ultimatum",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, possibleValues, possibleValues[0]); null, possibleValues, possibleValues[0]);
CardList chosen; CardList chosen;
if (q.equals(0)) if (q.equals(0))
chosen = Pile1; chosen = Pile1;
else else
chosen = Pile2; chosen = Pile2;
int numChosen = chosen.size(); int numChosen = chosen.size();
for( int i = 0; i < numChosen; i++) { for( int i = 0; i < numChosen; i++) {
Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", chosen.toArray()); Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", chosen.toArray());
if (check == null) if (check == null)
break; break;
Card playing = (Card)check; Card playing = (Card)check;
if(playing.isLand()) { if(playing.isLand()) {
if(card.getController().canPlayLand()) { if(card.getController().canPlayLand()) {
card.getController().playLand(playing); card.getController().playLand(playing);
} else { } else {
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
} }
} else { } else {
AllZone.GameAction.playCardNoCost(playing); AllZone.GameAction.playCardNoCost(playing);
} }
chosen.remove(playing); chosen.remove(playing);
} }
} }
Pile1.clear(); Pile1.clear();
Pile2.clear(); Pile2.clear();
}//resolve() }//resolve()
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
PlayerZone Library = AllZone.getZone(Constant.Zone.Library, card.getController()); CardList cards = AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer);
CardList cards = new CardList(Library.getCards()); return cards.size() >= 8;
return cards.size() >= 8; }
} };//SpellAbility
};//SpellAbility
// Do not remove SpellAbilities created by AbilityFactory or Keywords. // Do not remove SpellAbilities created by AbilityFactory or Keywords.
card.clearFirstSpellAbility(); card.clearFirstSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
@@ -983,13 +911,8 @@ public class CardFactory_Sorceries {
//randomly choose a nonland card //randomly choose a nonland card
int getDamage() { int getDamage() {
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController()); CardList notLand = AllZoneUtil.getPlayerCardsInLibrary(card.getController());
CardList notLand = new CardList(library.getCards()); notLand = notLand.filter(AllZoneUtil.nonlands);
notLand = notLand.filter(new CardListFilter() {
public boolean addCard(Card c) {
return !c.isLand();
}
});
notLand.shuffle(); notLand.shuffle();
if(notLand.isEmpty()) return 0; if(notLand.isEmpty()) return 0;
@@ -1018,17 +941,17 @@ public class CardFactory_Sorceries {
@Override @Override
public void resolve() { public void resolve() {
CardList all = AllZoneUtil.getCardsInPlay(); CardList all = AllZoneUtil.getCardsInPlay();
int Soldiers = card.getXManaCostPaid(); int Soldiers = card.getXManaCostPaid();
for(int i = 0; i < Soldiers; i++) { for(int i = 0; i < Soldiers; i++) {
CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card.getController(), "W", new String[] { CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card.getController(), "W", new String[] {
"Creature", "Soldier"}, 1, 1, new String[] {""}); "Creature", "Soldier"}, 1, 1, new String[] {""});
} }
if(Soldiers >= 5) { if(Soldiers >= 5) {
for(int i = 0; i < all.size(); i++) { for(int i = 0; i < all.size(); i++) {
Card c = all.get(i); Card c = all.get(i);
if(c.isCreature()) AllZone.GameAction.destroy(c); if(c.isCreature()) AllZone.GameAction.destroy(c);
} }
} }
}// resolve() }// resolve()
@@ -1084,34 +1007,28 @@ public class CardFactory_Sorceries {
} }
} }
//"Incendiary Command deals 2 damage to each creature", //"Incendiary Command deals 2 damage to each creature",
if(userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) { if(userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) {
//get all creatures CardList list = AllZoneUtil.getCreaturesInPlay();
CardList list = AllZoneUtil.getCreaturesInPlay();
for(int i = 0; i < list.size(); i++) {
for(int i = 0; i < list.size(); i++) { list.get(i).addDamage(2, card);
list.get(i).addDamage(2, card);
}
}
//"Destroy target nonbasic land",
for(int i = 0; i <card.getChoices().size(); i++) {
if(card.getChoice(i).equals(cardChoice[2])) {
PlayerZone Hplay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer);
PlayerZone Cplay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer);
// CardList all = AllZone.CardFactory.getAllCards();
CardList all = new CardList(Hplay.getCards());
all.add(new CardList(Cplay.getCards()));
for(int i2 = 0; i2 < all.size(); i2++) {
if(String.valueOf(all.get(i2).getUniqueNumber()).equals(card.getChoiceTarget(card.getChoices().size() - 1))) {
setTargetCard(all.get(i2));
AllZone.GameAction.destroy(getTargetCard());
}
}
} }
} }
//"Destroy target nonbasic land",
for(int i = 0; i <card.getChoices().size(); i++) {
if(card.getChoice(i).equals(cardChoice[2])) {
CardList all = AllZoneUtil.getCardsInPlay();
for(int i2 = 0; i2 < all.size(); i2++) {
if(String.valueOf(all.get(i2).getUniqueNumber()).equals(card.getChoiceTarget(card.getChoices().size() - 1))) {
setTargetCard(all.get(i2));
AllZone.GameAction.destroy(getTargetCard());
}
}
}
}
//"Each player discards all cards in his or her hand, then draws that many cards" //"Each player discards all cards in his or her hand, then draws that many cards"
if(userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) { if(userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) {
discardDraw(AllZone.ComputerPlayer); discardDraw(AllZone.ComputerPlayer);
@@ -1120,7 +1037,7 @@ public class CardFactory_Sorceries {
}//resolve() }//resolve()
void discardDraw(Player player) { void discardDraw(Player player) {
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); CardList hand = AllZoneUtil.getPlayerHand(player);
int n = hand.size(); int n = hand.size();
//technically should let the user discard one card at a time //technically should let the user discard one card at a time
@@ -1239,9 +1156,7 @@ public class CardFactory_Sorceries {
ArrayList<String> display = new ArrayList<String>(); ArrayList<String> display = new ArrayList<String>();
//get all //get all
CardList list = new CardList(); CardList list = AllZoneUtil.getCardsInPlay();
list.addAll(AllZone.Human_Battlefield.getCards());
list.addAll(AllZone.Computer_Battlefield.getCards());
CardList land = list.getType("Land"); CardList land = list.getType("Land");
CardList basicLand = list.getType("Basic"); CardList basicLand = list.getType("Basic");
@@ -1461,8 +1376,7 @@ public class CardFactory_Sorceries {
&& c.getType().contains(humanBasic.get(count)) && c.getType().contains(humanBasic.get(count))
/*&& !saveList.contains(c) */) { /*&& !saveList.contains(c) */) {
//get all other basic[count] lands human player controls and add them to target //get all other basic[count] lands human player controls and add them to target
PlayerZone humanPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer); CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
CardList land = new CardList(humanPlay.getCards()).getType("Land");
CardList cl = land.getType(humanBasic.get(count)); CardList cl = land.getType(humanBasic.get(count));
cl = cl.filter(new CardListFilter() cl = cl.filter(new CardListFilter()
{ {
@@ -1683,23 +1597,17 @@ public class CardFactory_Sorceries {
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
PlayerZone zone = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList creature = AllZoneUtil.getCreaturesInPlay();
if(zone != null) { creature = creature.filter(new CardListFilter() {
CardList creature = new CardList(); public boolean addCard(Card card) {
creature.addAll(zone.getCards()); return (!card.getType().contains("Legendary"));
creature.addAll(AllZone.getZone(Constant.Zone.Battlefield, card.getController().getOpponent()).getCards());
creature = creature.getType("Creature");
creature = creature.filter(new CardListFilter() {
public boolean addCard(Card card) {
return (!card.getType().contains("Legendary"));
}
});
if(creature.size() > 0) {
Card biggest = creature.get(0);
for(int i = 0; i < creature.size(); i++)
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest);
} }
});
if(creature.size() > 0) {
Card biggest = creature.get(0);
for(int i = 0; i < creature.size(); i++)
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest);
} }
} }
@@ -1720,10 +1628,6 @@ public class CardFactory_Sorceries {
AllZone.TriggerHandler.registerTrigger(t); AllZone.TriggerHandler.registerTrigger(t);
} }
Copy.addLeavesPlayCommand(new Command() { Copy.addLeavesPlayCommand(new Command() {
/**
*
*/
private static final long serialVersionUID = 1988240749380718859L; private static final long serialVersionUID = 1988240749380718859L;
public void execute() { public void execute() {
@@ -1749,46 +1653,38 @@ public class CardFactory_Sorceries {
SpellAbility kicker = new Spell(card) { SpellAbility kicker = new Spell(card) {
private static final long serialVersionUID = 13762512058673590L; private static final long serialVersionUID = 13762512058673590L;
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
PlayerZone zone = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); Card biggest = null;
Card biggest = null; CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
if(zone != null) { creature = creature.filter(new CardListFilter() {
CardList creature = new CardList(); public boolean addCard(Card card) {
creature.addAll(zone.getCards()); return (!card.getType().contains("Legendary"));
creature = creature.getType("Creature"); }
creature = creature.filter(new CardListFilter() { });
public boolean addCard(Card card) { if(creature.size() == 0) return false;
return (!card.getType().contains("Legendary")); biggest = creature.get(0);
} for(int i = 0; i < creature.size(); i++)
}); if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
if(creature.size() == 0) return false; setTargetCard(biggest);
biggest = creature.get(0);
for(int i = 0; i < creature.size(); i++) return biggest.getNetAttack() > 3;
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest);
}
return biggest.getNetAttack() > 3;
} }
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
PlayerZone zone = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
if(zone != null) { creature = creature.filter(new CardListFilter() {
CardList creature = new CardList(); public boolean addCard(Card card) {
creature.addAll(zone.getCards()); return (!card.getType().contains("Legendary"));
creature = creature.getType("Creature");
creature = creature.filter(new CardListFilter() {
public boolean addCard(Card card) {
return (!card.getType().contains("Legendary"));
}
});
if(creature.size() > 0) {
Card biggest = creature.get(0);
for(int i = 0; i < creature.size(); i++)
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest);
} }
});
if(creature.size() > 0) {
Card biggest = creature.get(0);
for(int i = 0; i < creature.size(); i++)
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest);
} }
} }
@@ -2140,8 +2036,7 @@ public class CardFactory_Sorceries {
int damage = card.getXManaCostPaid(); int damage = card.getXManaCostPaid();
Player player = getTargetPlayer(); Player player = getTargetPlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player); CardList list = AllZoneUtil.getPlayerCardsInPlay(player);
CardList list = new CardList(play.getCards());
list = list.filter(new CardListFilter() list = list.filter(new CardListFilter()
{ {
@@ -2172,7 +2067,7 @@ public class CardFactory_Sorceries {
} }
}; };
CardList killableCreatures = new CardList(AllZone.Human_Battlefield.getCards()); CardList killableCreatures = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
killableCreatures = killableCreatures.filter(filter); killableCreatures = killableCreatures.filter(filter);
return (killableCreatures.size() >= 2); // kill at least two of the human's creatures return (killableCreatures.size() >= 2); // kill at least two of the human's creatures
@@ -2324,10 +2219,7 @@ public class CardFactory_Sorceries {
// The computer should only play this card if it has at least // The computer should only play this card if it has at least
// one land in its hand. Because of the way the computer turn // one land in its hand. Because of the way the computer turn
// is structured, it will already have played its first land. // is structured, it will already have played its first land.
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, CardList list = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
AllZone.ComputerPlayer);
CardList list = new CardList(hand.getCards());
list = list.getType("Land"); list = list.getType("Land");
if (list.size() > 0) if (list.size() > 0)
@@ -2342,7 +2234,6 @@ public class CardFactory_Sorceries {
Command untilEOT = new Command() Command untilEOT = new Command()
{ {
private static final long serialVersionUID = -2618916698575607634L; private static final long serialVersionUID = -2618916698575607634L;
public void execute(){ public void execute(){
@@ -2928,25 +2819,17 @@ public class CardFactory_Sorceries {
} }
public boolean canPlayAI() { public boolean canPlayAI() {
CardList check = new CardList(); CardList check = AllZoneUtil.getPlayerGraveyard(card.getController());
PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
check.addAll(zone.getCards());
return getCreaturesAI().length != 0 || check.size() >= 7; return getCreaturesAI().length != 0 || check.size() >= 7;
} }
public Card[] getCreatures() { public Card[] getCreatures() {
CardList creature = new CardList(); CardList creature = AllZoneUtil.getPlayerTypeInGraveyard(card.getController(), "Creature");
PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
creature.addAll(zone.getCards());
creature = creature.getType("Creature");
return creature.toArray(); return creature.toArray();
} }
public Card[] getCreaturesAI() { public Card[] getCreaturesAI() {
CardList creature = new CardList(); CardList creature = AllZoneUtil.getPlayerTypeInGraveyard(card.getController(), "Creature");
PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
creature.addAll(zone.getCards());
creature = creature.getType("Creature");
creature = creature.filter(new CardListFilter() { creature = creature.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
return c.getNetAttack() > 4; return c.getNetAttack() > 4;
@@ -2975,20 +2858,13 @@ public class CardFactory_Sorceries {
@Override @Override
public void showMessage() { public void showMessage() {
Object check = GuiUtils.getChoiceOptional("Select creature", getCreatures()); CardList creature = AllZoneUtil.getPlayerTypeInGraveyard(card.getController(), "Creature");
Object check = GuiUtils.getChoiceOptional("Select creature", creature);
if(check != null) { if(check != null) {
spell.setTargetCard((Card) check); spell.setTargetCard((Card) check);
stopSetNext(new Input_PayManaCost(spell)); stopSetNext(new Input_PayManaCost(spell));
} else stop(); } else stop();
}//showMessage() }//showMessage()
public Card[] getCreatures() {
CardList creature = new CardList();
PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
creature.addAll(zone.getCards());
creature = creature.getType("Creature");
return creature.toArray();
}
};//Input };//Input
spell.setBeforePayMana(target); spell.setBeforePayMana(target);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
@@ -3016,9 +2892,8 @@ public class CardFactory_Sorceries {
if(input[0] == null) input[0] = ""; if(input[0] == null) input[0] = "";
PlayerZone aiGrave = AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer);
HashMap<String,Integer> countInGraveyard = new HashMap<String,Integer>(); HashMap<String,Integer> countInGraveyard = new HashMap<String,Integer>();
CardList allGrave = new CardList(aiGrave.getCards()); CardList allGrave = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer);
allGrave.getType("Creature"); allGrave.getType("Creature");
for(Card c:allGrave) for(Card c:allGrave)
{ {