code cleanup/consolidation in CardFactory_Sorceries

This commit is contained in:
jendave
2011-08-06 14:14:45 +00:00
parent abd4ae7edd
commit 77d202b325

View File

@@ -106,11 +106,7 @@ public class CardFactory_Sorceries {
@Override @Override
public void resolve() { public void resolve() {
//get all creatures CardList list = AllZoneUtil.getCreaturesInPlay();
CardList list = new CardList();
list.addAll(AllZone.Human_Battlefield.getCards());
list.addAll(AllZone.Computer_Battlefield.getCards());
list = list.getType("Creature");
for(int i = 0; i < list.size(); i++) { for(int i = 0; i < list.size(); i++) {
final Card[] target = new Card[1]; final Card[] target = new Card[1];
@@ -428,9 +424,7 @@ public class CardFactory_Sorceries {
@Override @Override
public void resolve() { public void resolve() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, getTargetPlayer()); CardList list = AllZoneUtil.getCreaturesInPlay(getTargetPlayer());
CardList list = new CardList(play.getCards());
list = list.getType("Creature");
list.shuffle(); list.shuffle();
@@ -489,7 +483,6 @@ public class CardFactory_Sorceries {
spell_one.setDescription("Put a 1/1 black Rat token into play."); spell_one.setDescription("Put a 1/1 black Rat token into play.");
spell_two.setDescription("Buyback 4 (You may pay an additional 4 as you cast this spell. If you do, put this card into your hand as it resolves.)"); spell_two.setDescription("Buyback 4 (You may pay an additional 4 as you cast this spell. If you do, put this card into your hand as it resolves.)");
// spell_two.setDescription("Buyback 4 - Pay 4B, put this card into your hand as it resolves.");
spell_one.setStackDescription("Lab Rats - Put a 1/1 black Rat token into play"); spell_one.setStackDescription("Lab Rats - Put a 1/1 black Rat token into play");
spell_two.setStackDescription("Lab Rats - Buyback, Put a 1/1 black Rat token into play"); spell_two.setStackDescription("Lab Rats - Buyback, Put a 1/1 black Rat token into play");
@@ -673,60 +666,28 @@ public class CardFactory_Sorceries {
spell.setBeforePayMana(target); spell.setBeforePayMana(target);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
/*
//*************** START *********** START **************************
else if(cardName.equals("Blinding Light")) {
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -631672055247954361L;
@Override
public void resolve() {
CardList nonwhite = AllZoneUtil.getCreaturesInPlay();
nonwhite = nonwhite.filter(new CardListFilter() {
public boolean addCard(Card c) {
return !c.isWhite();
}
});
for(int i = 0; i < nonwhite.size(); i++)
nonwhite.get(i).tap();
}//resolve()
@Override
public boolean canPlayAI() {
//the computer seems to play this card at stupid times
return false;
}
};
card.setSVar("PlayMain1", "TRUE");
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
*/
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Grapeshot")) { else if(cardName.equals("Grapeshot")) {
final SpellAbility spell = new Spell(card) { final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 74155521291969L; private static final long serialVersionUID = 74155521291969L;
@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() {
if(getTargetCard() != null) { if(getTargetCard() != null) {
if(AllZone.GameAction.isCardInPlay(getTargetCard()) if(AllZone.GameAction.isCardInPlay(getTargetCard())
&& CardFactoryUtil.canTarget(card, getTargetCard())) && CardFactoryUtil.canTarget(card, getTargetCard()))
getTargetCard().addDamage(1,card); getTargetCard().addDamage(1, card);
} else getTargetPlayer().addDamage(1, card); } else getTargetPlayer().addDamage(1, card);
}; };
}; };
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell, true, false)); spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell, true, false));
}//*************** END ************ END ************************** }//*************** END ************ END **************************
@@ -753,8 +714,6 @@ public class CardFactory_Sorceries {
handChoices[i] = null; handChoices[i] = null;
} }
AllZone.Display.getChoice("Random card", handChoices); AllZone.Display.getChoice("Random card", handChoices);
//AllZone.GameAction.addDamage(opponent, card,
// CardUtil.getConvertedManaCost(choice.getManaCost()));
opponent.addDamage(CardUtil.getConvertedManaCost(choice.getManaCost()), card); opponent.addDamage(CardUtil.getConvertedManaCost(choice.getManaCost()), card);
} }
}//resolve() }//resolve()
@@ -889,8 +848,8 @@ public class CardFactory_Sorceries {
CardList creature2 = new CardList(); CardList creature2 = new CardList();
creature2.addAll(zone.getCards()); creature2.addAll(zone.getCards());
creature2 = creature2.getType("Creature"); creature2 = creature2.getType("Creature");
return (Deck.size() > 2 && (opponent.getLife() <= 5 || (creature.size() > 0 && creature2.size() > 0))); return (Deck.size() > 2 && (opponent.getLife() <= 5 || (creature.size() > 0 && creature2.size() > 0)));
} }
};//SpellAbility };//SpellAbility
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
@@ -899,23 +858,23 @@ public class CardFactory_Sorceries {
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Tendrils of Agony")) { else if(cardName.equals("Tendrils of Agony")) {
SpellAbility spell = new Spell(card) { SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -6598023699468746L; private static final long serialVersionUID = -6598023699468746L;
@Override @Override
public void resolve() { public void resolve() {
Player opponent = card.getController().getOpponent(); Player opponent = card.getController().getOpponent();
opponent.loseLife(2, card); opponent.loseLife(2, card);
card.getController().gainLife(2, card); card.getController().gainLife(2, card);
} }
public boolean canPlayAI() { public boolean canPlayAI() {
return 1 < Phase.StormCount; return 1 < Phase.StormCount;
} }
};//SpellAbility };//SpellAbility
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
@@ -985,11 +944,11 @@ public class CardFactory_Sorceries {
private static final long serialVersionUID = -650147710658746L; private static final long serialVersionUID = -650147710658746L;
@Override @Override
public void resolve() { public void resolve() {
if(AllZone.GameAction.isCardInPlay(getTargetCard()) if(AllZone.GameAction.isCardInPlay(getTargetCard())
&& CardFactoryUtil.canTarget(card, getTargetCard())) { && CardFactoryUtil.canTarget(card, getTargetCard())) {
AllZone.GameAction.destroy(getTargetCard()); AllZone.GameAction.destroy(getTargetCard());
} }
} }
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
@@ -1052,7 +1011,7 @@ public class CardFactory_Sorceries {
};//SpellAbility };//SpellAbility
final Ability freeCast = new Ability(card, "0") final Ability freeCast = new Ability(card, "0")
{ {
private static final long serialVersionUID = 4455819149429678456L; private static final long serialVersionUID = 4455819149429678456L;
@Override @Override
@@ -1279,17 +1238,17 @@ public class CardFactory_Sorceries {
AllZone.Display.getChoice("Revealing top " + Count + " cards of library: ", cards.toArray()); AllZone.Display.getChoice("Revealing top " + Count + " cards of library: ", cards.toArray());
//Human chooses //Human chooses
if(card.getController().equals(AllZone.ComputerPlayer)) { if(card.getController().equals(AllZone.ComputerPlayer)) {
for(int i = 0; i < Count; i++) { for(int i = 0; i < Count; i++) {
if(stop == false) { if(stop == false) {
choice = AllZone.Display.getChoiceOptional("Choose cards to put into the first pile: ", cards.toArray()); choice = AllZone.Display.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));
@@ -1328,8 +1287,8 @@ public class CardFactory_Sorceries {
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.)
{ {
@@ -1362,48 +1321,48 @@ public class CardFactory_Sorceries {
if(q.equals(0)) { if(q.equals(0)) {
int Spells = Pile1.size(); int Spells = Pile1.size();
for( int i = 0; i < Spells; i++) { for( int i = 0; i < Spells; i++) {
if(stop2 == false) { if(stop2 == false) {
Object check = AllZone.Display.getChoiceOptional("Select spells to play in reserve order: ", Pile1.toArray()); Object check = AllZone.Display.getChoiceOptional("Select spells to play in reserve order: ", Pile1.toArray());
if(check != null) { if(check != null) {
if(((Card) check).isLand() == true) { if(((Card) check).isLand() == true) {
if(CardFactoryUtil.canHumanPlayLand()) { if(CardFactoryUtil.canHumanPlayLand()) {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
GameAction.playLand((Card)check, play); GameAction.playLand((Card)check, play);
} 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 if(((Card) check).isPermanent() == true && ((Card) check).isAura() == false) { } else if(((Card) check).isPermanent() == true && ((Card) check).isAura() == false) {
AllZone.Stack.add(((Card) check).getSpellAbility()[0]); AllZone.Stack.add(((Card) check).getSpellAbility()[0]);
} else { } else {
AllZone.GameAction.playCardNoCost(((Card) check)); AllZone.GameAction.playCardNoCost(((Card) check));
} }
Pile1.remove((Card) check); Pile1.remove((Card) check);
} }
} else stop2 = true; } else stop2 = true;
} }
} else { } else {
int Spells = Pile2.size(); int Spells = Pile2.size();
for( int i = 0; i < Spells; i++) { for( int i = 0; i < Spells; i++) {
if(stop2 == false) { if(stop2 == false) {
Object check = AllZone.Display.getChoiceOptional("Select spells to play in reserve order: ", Pile2.toArray()); Object check = AllZone.Display.getChoiceOptional("Select spells to play in reserve order: ", Pile2.toArray());
if(check != null) { if(check != null) {
if(((Card) check).isLand() == true) { if(((Card) check).isLand() == true) {
if(CardFactoryUtil.canHumanPlayLand()) { if(CardFactoryUtil.canHumanPlayLand()) {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
GameAction.playLand((Card)check, play); GameAction.playLand((Card)check, play);
} 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 if(((Card) check).isPermanent() == true && ((Card) check).isAura() == false) { } else if(((Card) check).isPermanent() == true && ((Card) check).isAura() == false) {
AllZone.Stack.add(((Card) check).getSpellAbility()[0]); AllZone.Stack.add(((Card) check).getSpellAbility()[0]);
} else { } else {
AllZone.GameAction.playCardNoCost(((Card) check)); AllZone.GameAction.playCardNoCost(((Card) check));
} }
Pile2.remove((Card) check); Pile2.remove((Card) check);
} }
} else stop2 = true; } else stop2 = true;
} }
} }
} }
Pile1.clear(); Pile1.clear();
Pile2.clear(); Pile2.clear();
@@ -1556,10 +1515,7 @@ public class CardFactory_Sorceries {
@Override @Override
public void resolve() { public void resolve() {
CardList all = new CardList(); CardList all = AllZoneUtil.getCreaturesInPlay();
all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards());
all = all.getType("Creature");
for(int i = 0; i < all.size(); i++) for(int i = 0; i < all.size(); i++)
if(!all.get(i).getKeyword().contains("Flying")) { if(!all.get(i).getKeyword().contains("Flying")) {
@@ -1646,11 +1602,7 @@ public class CardFactory_Sorceries {
for(int i = 0; i < all.size(); i++) for(int i = 0; i < all.size(); i++)
if(all.get(i).getName().equals(c.getName())) { if(all.get(i).getName().equals(c.getName())) {
if(player.equals(AllZone.HumanPlayer)) { AllZone.GameAction.exile(all.get(i));
AllZone.GameAction.moveTo(AllZone.Human_Exile, all.get(i));
} else {
AllZone.GameAction.moveTo(AllZone.Computer_Exile, all.get(i));
}
} }
}//remove() }//remove()
@@ -1723,9 +1675,7 @@ public class CardFactory_Sorceries {
if(!getTargetCard().isFaceDown()) { if(!getTargetCard().isFaceDown()) {
//get all creatures //get all creatures
CardList list = new CardList(); CardList list = AllZoneUtil.getCardsInPlay();
list.addAll(AllZone.Human_Battlefield.getCards());
list.addAll(AllZone.Computer_Battlefield.getCards());
list = list.getName(getTargetCard().getName()); list = list.getName(getTargetCard().getName());
list.remove(getTargetCard()); list.remove(getTargetCard());
@@ -2197,9 +2147,7 @@ public class CardFactory_Sorceries {
@Override @Override
public void resolve() { public void resolve() {
CardList all = new CardList(); CardList all = AllZoneUtil.getCardsInPlay();
all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards());
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[] {
@@ -2215,11 +2163,8 @@ public class CardFactory_Sorceries {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList human = new CardList(AllZone.Human_Battlefield.getCards()); CardList human = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer);
CardList computer = new CardList(AllZone.Computer_Battlefield.getCards()); CardList computer = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
human = human.getType("Creature");
computer = computer.getType("Creature");
// the computer will at least destroy 2 more human creatures // the computer will at least destroy 2 more human creatures
return (computer.size() < human.size() - 1 return (computer.size() < human.size() - 1
@@ -2249,9 +2194,10 @@ public class CardFactory_Sorceries {
@Override @Override
public void resolve() { public void resolve() {
// System.out.println(userChoice); //System.out.println(userChoice);
// System.out.println(m_land[0]); //System.out.println(m_land[0]);
// System.out.println(m_player[0]); //System.out.println(m_player[0]);
//"Incendiary Command deals 4 damage to target player", //"Incendiary Command deals 4 damage to target player",
for(int i = 0; i <card.getChoices().size(); i++) { for(int i = 0; i <card.getChoices().size(); i++) {
if(card.getChoice(i).equals(cardChoice[0])) { if(card.getChoice(i).equals(cardChoice[0])) {
@@ -2670,11 +2616,9 @@ public class CardFactory_Sorceries {
} }
}; };
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell)); spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.setSVar("PlayMain1", "TRUE"); card.setSVar("PlayMain1", "TRUE");
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
@@ -2708,104 +2652,6 @@ public class CardFactory_Sorceries {
card.setFlashback(true); card.setFlashback(true);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
/*
//*************** START *********** START **************************
else if(cardName.equals("Allied Strategies")) {
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 2730790148899002194L;
@Override
public void resolve() {
int n = countLandTypes();
getTargetPlayer().drawCards(n);
}
int countLandTypes() {
PlayerZone play = AllZone.getZone(Constant.Zone.Play, getTargetPlayer());
CardList land = new CardList(play.getCards());
String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
int count = 0;
for(int i = 0; i < basic.length; i++) {
CardList c = land.getType(basic[i]);
if(!c.isEmpty()) count++;
}
return count;
}//countLandTypes()
@Override
public boolean canPlayAI() {
return AllZone.Computer_Hand.getCards().length <= 5;
}
};
spell.setChooseTargetAI(CardFactoryUtil.AI_targetComputer());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Sylvan Tutor")) {
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 1873791994168389407L;
@Override
public boolean canPlayAI() {
return 6 < AllZone.Phase.getTurn();
}
@Override
public void resolve() {
Player player = card.getController();
if(player.equals(AllZone.HumanPlayer)) humanResolve();
else computerResolve();
}
public void computerResolve() {
CardList creature = new CardList(AllZone.Computer_Library.getCards());
creature = creature.getType("Creature");
if(creature.size() != 0) {
Card c = creature.get(0);
card.getController().shuffle();
//move to top of library
AllZone.Computer_Library.remove(c);
AllZone.Computer_Library.add(c, 0);
CardList list = new CardList();
list.add(c);
AllZone.Display.getChoiceOptional("Computer picked:", list.toArray());
}
}//computerResolve()
public void humanResolve() {
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
CardList list = new CardList(library.getCards());
list = list.getType("Creature");
if(list.size() != 0) {
Object o = AllZone.Display.getChoiceOptional("Select a creature", list.toArray());
card.getController().shuffle();
if(o != null) {
//put creature on top of library
library.remove(o);
library.add((Card) o, 0);
}
}//if
}//resolve()
};
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
*/
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Pulse of the Tangle")) { else if(cardName.equals("Pulse of the Tangle")) {
@@ -3580,15 +3426,8 @@ public class CardFactory_Sorceries {
@Override @Override
public boolean canPlay() { public boolean canPlay() {
Player oppPlayer = card.getController().getOpponent(); Player oppPlayer = card.getController().getOpponent();
CardList self = AllZoneUtil.getPlayerLandsInPlay(card.getController());
PlayerZone selfZone = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList opp = AllZoneUtil.getPlayerLandsInPlay(oppPlayer);
PlayerZone oppZone = AllZone.getZone(Constant.Zone.Battlefield, oppPlayer);
CardList self = new CardList(selfZone.getCards());
CardList opp = new CardList(oppZone.getCards());
self = self.getType("Land");
opp = opp.getType("Land");
return (self.size() < opp.size()) && super.canPlay(); return (self.size() < opp.size()) && super.canPlay();
}//canPlay() }//canPlay()
@@ -3623,11 +3462,8 @@ public class CardFactory_Sorceries {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
PlayerZone cPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer); CardList hList = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer); CardList cList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
CardList hList = new CardList(hPlay.getCards());
CardList cList = new CardList(cPlay.getCards());
CardList smallCreats = cList.filter(new CardListFilter() { CardList smallCreats = cList.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
return c.isCreature() && c.getNetAttack() < 2 && c.getNetDefense() < 3; return c.isCreature() && c.getNetAttack() < 2 && c.getNetDefense() < 3;
@@ -3646,74 +3482,6 @@ public class CardFactory_Sorceries {
card.addSpellAbility(spell); card.addSpellAbility(spell);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
/*
//*************** START *********** START **************************
else if(cardName.equals("Chainer's Edict")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 1139979866902867554L;
@Override
public void resolve() {
getTargetPlayer().sacrificeCreature();
}
@Override
public boolean canPlayAI() {
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer);
CardList hList = new CardList(hPlay.getCards());
hList = hList.getType("Creature");
return hList.size() > 0;
}
};
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
final SpellAbility flashback = new Spell(card) {
private static final long serialVersionUID = -4889392369463499074L;
@Override
public boolean canPlay() {
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
return AllZone.GameAction.isCardInZone(card, grave)
&& Phase.canCastSorcery(card.getController());
}
@Override
public boolean canPlayAI() {
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer);
CardList hList = new CardList(hPlay.getCards());
hList = hList.getType("Creature");
return hList.size() > 0;
}
@Override
public void resolve() {
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
PlayerZone removed = AllZone.getZone(Constant.Zone.Exile, card.getController());
getTargetPlayer().sacrificeCreature();
grave.remove(card);
removed.add(card);
}
};
flashback.setManaCost("5 B B");
flashback.setBeforePayMana(CardFactoryUtil.input_targetPlayer(flashback));
flashback.setDescription("Flashback: 5 B B");
flashback.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
card.addSpellAbility(flashback);
card.setFlashback(true);
}//*************** END ************ END **************************
*/
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Rite of Replication")) { else if(cardName.equals("Rite of Replication")) {
@@ -3721,12 +3489,8 @@ public class CardFactory_Sorceries {
private static final long serialVersionUID = -2902112019334177L; private static final long serialVersionUID = -2902112019334177L;
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
PlayerZone zone = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
Card biggest = null; Card biggest = null;
if(zone != null) { CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
CardList creature = new CardList();
creature.addAll(zone.getCards());
creature = creature.getType("Creature");
creature = creature.filter(new CardListFilter() { creature = creature.filter(new CardListFilter() {
public boolean addCard(Card card) { public boolean addCard(Card card) {
return (!card.getType().contains("Legendary")); return (!card.getType().contains("Legendary"));
@@ -3737,7 +3501,7 @@ public class CardFactory_Sorceries {
for(int i = 0; i < creature.size(); i++) for(int i = 0; i < creature.size(); i++)
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i); if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest); setTargetCard(biggest);
}
return biggest.getNetAttack() > 4; return biggest.getNetAttack() > 4;
} }
@@ -4590,34 +4354,34 @@ public class CardFactory_Sorceries {
//*************** START *********** START ************************** //*************** START *********** START **************************
else if (cardName.equals("Prosperity")) else if (cardName.equals("Prosperity"))
{ {
final SpellAbility spell = new Spell(card) final SpellAbility spell = new Spell(card)
{ {
private static final long serialVersionUID = -4885933011194027735L; private static final long serialVersionUID = -4885933011194027735L;
public void resolve() public void resolve()
{ {
for (int i=0;i<card.getXManaCostPaid();i++) for (int i=0;i<card.getXManaCostPaid();i++)
{ {
AllZone.HumanPlayer.drawCard(); AllZone.HumanPlayer.drawCard();
AllZone.ComputerPlayer.drawCard(); AllZone.ComputerPlayer.drawCard();
} }
card.setXManaCostPaid(0); card.setXManaCostPaid(0);
} }
public boolean canPlayAI() public boolean canPlayAI()
{ {
return AllZone.Computer_Hand.size() < 5 && ComputerUtil.canPayCost("3 U"); return AllZone.Computer_Hand.size() < 5 && ComputerUtil.canPayCost("3 U");
} }
}; };
spell.setDescription("Each player draws X cards."); spell.setDescription("Each player draws X cards.");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(card).append(" - Each player draws X cards."); sb.append(card).append(" - Each player draws X cards.");
spell.setStackDescription(sb.toString()); spell.setStackDescription(sb.toString());
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
} }
//*************** END ************ END ************************** //*************** END ************ END **************************
@@ -4801,58 +4565,58 @@ public class CardFactory_Sorceries {
//*************** START *********** START ************************** //*************** START *********** START **************************
else if (cardName.equals("Savage Twister")) else if (cardName.equals("Savage Twister"))
{ {
final SpellAbility spell = new Spell(card) final SpellAbility spell = new Spell(card)
{ {
private static final long serialVersionUID = -2579177525478645067L; private static final long serialVersionUID = -2579177525478645067L;
public void resolve() public void resolve()
{ {
CardList all = new CardList(); CardList all = new CardList();
all.addAll(AllZone.Human_Battlefield.getCards()); all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards()); all.addAll(AllZone.Computer_Battlefield.getCards());
all = all.filter(new CardListFilter() all = all.filter(new CardListFilter()
{ {
public boolean addCard(Card c) public boolean addCard(Card c)
{ {
return c.isCreature() && CardFactoryUtil.canDamage(card, c); return c.isCreature() && CardFactoryUtil.canDamage(card, c);
} }
}); });
for(int i = 0; i < all.size(); i++) for(int i = 0; i < all.size(); i++)
all.get(i).addDamage(card.getXManaCostPaid(), card); all.get(i).addDamage(card.getXManaCostPaid(), card);
card.setXManaCostPaid(0); card.setXManaCostPaid(0);
} }
public boolean canPlayAI() public boolean canPlayAI()
{ {
final int maxX = ComputerUtil.getAvailableMana().size() - 1; final int maxX = ComputerUtil.getAvailableMana().size() - 1;
CardListFilter filter = new CardListFilter(){ CardListFilter filter = new CardListFilter(){
public boolean addCard(Card c) public boolean addCard(Card c)
{ {
return c.isCreature() && CardFactoryUtil.canDamage(card, c) && return c.isCreature() && CardFactoryUtil.canDamage(card, c) &&
maxX >= (c.getNetDefense() + c.getDamage()); maxX >= (c.getNetDefense() + c.getDamage());
} }
}; };
CardList humanAll = new CardList(AllZone.Human_Battlefield.getCards()); CardList humanAll = new CardList(AllZone.Human_Battlefield.getCards());
humanAll = humanAll.filter(filter); humanAll = humanAll.filter(filter);
CardList compAll = new CardList(AllZone.Computer_Battlefield.getCards()); CardList compAll = new CardList(AllZone.Computer_Battlefield.getCards());
compAll = compAll.filter(filter); compAll = compAll.filter(filter);
return humanAll.size() > (compAll.size() + 2); return humanAll.size() > (compAll.size() + 2);
} }
}; };
StringBuilder sbDesc = new StringBuilder(); StringBuilder sbDesc = new StringBuilder();
sbDesc.append(cardName).append(" deals X damage to each creature."); sbDesc.append(cardName).append(" deals X damage to each creature.");
spell.setDescription(sbDesc.toString()); spell.setDescription(sbDesc.toString());
StringBuilder sbStack = new StringBuilder(); StringBuilder sbStack = new StringBuilder();
sbStack.append(cardName).append(" - deals X damage to each creature."); sbStack.append(cardName).append(" - deals X damage to each creature.");
spell.setStackDescription(sbStack.toString()); spell.setStackDescription(sbStack.toString());
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
} }
//*************** END ************ END ************************** //*************** END ************ END **************************
@@ -4997,10 +4761,8 @@ public class CardFactory_Sorceries {
public void resolve() public void resolve()
{ {
//Lands: //Lands:
CardList humLand = new CardList(AllZone.Human_Battlefield.getCards()); CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
humLand = humLand.getType("Land"); CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.ComputerPlayer);
CardList compLand = new CardList(AllZone.Computer_Battlefield.getCards());
compLand = compLand.getType("Land");
if (compLand.size() > humLand.size()) if (compLand.size() > humLand.size())
{ {
@@ -5015,8 +4777,8 @@ public class CardFactory_Sorceries {
} }
//Hand //Hand
CardList humHand = new CardList(AllZone.Human_Hand.getCards()); CardList humHand = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
CardList compHand = new CardList(AllZone.Computer_Hand.getCards()); CardList compHand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
int handDiff = humHand.size() - compHand.size(); int handDiff = humHand.size() - compHand.size();
if (compHand.size() > humHand.size()) if (compHand.size() > humHand.size())
@@ -5029,10 +4791,8 @@ public class CardFactory_Sorceries {
} }
//Creatures: //Creatures:
CardList humCreats = new CardList(AllZone.Human_Battlefield.getCards()); CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer);
humCreats = humCreats.getType("Creature"); CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
CardList compCreats = new CardList(AllZone.Computer_Battlefield.getCards());
compCreats = compCreats.getType("Creature");
if (compCreats.size() > humCreats.size()) if (compCreats.size() > humCreats.size())
{ {
@@ -5052,20 +4812,17 @@ public class CardFactory_Sorceries {
public boolean canPlayAI() public boolean canPlayAI()
{ {
int diff = 0; int diff = 0;
CardList humLand = new CardList(AllZone.Human_Battlefield.getCards()); CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
humLand = humLand.getType("Land"); CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.ComputerPlayer);
CardList compLand = new CardList(AllZone.Computer_Battlefield.getCards());
compLand = compLand.getType("Land");
diff += humLand.size() - compLand.size(); diff += humLand.size() - compLand.size();
CardList humCreats = new CardList(AllZone.Human_Battlefield.getCards()); CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer);
humCreats = humCreats.getType("Creature"); CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
CardList compCreats = new CardList(AllZone.Computer_Battlefield.getCards());
compCreats = compCreats.getType("Creature"); compCreats = compCreats.getType("Creature");
diff += 1.5 * (humCreats.size() - compCreats.size()); diff += 1.5 * (humCreats.size() - compCreats.size());
CardList humHand = new CardList(AllZone.Human_Hand.getCards()); CardList humHand = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
CardList compHand = new CardList(AllZone.Computer_Hand.getCards()); CardList compHand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
diff += 0.5 * (humHand.size() - compHand.size()); diff += 0.5 * (humHand.size() - compHand.size());
return diff > 2; return diff > 2;
@@ -5173,16 +4930,10 @@ 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 land to it's limit // is structured, it will already have played land to it's limit
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand,
AllZone.ComputerPlayer); CardList hand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
hand = hand.getType("Land");
CardList list = new CardList(hand.getCards()); return hand.size() > 0;
list = list.getType("Land");
if (list.size() > 0)
return true;
else
return false;
} }
public void resolve() { public void resolve() {
@@ -5271,32 +5022,19 @@ public class CardFactory_Sorceries {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
return getCreatures(AllZone.ComputerPlayer).size() > 0; return AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer).size() > 0;
} }
@Override @Override
public void resolve() { public void resolve() {
Card[] c = getCreatures(card.getController()).toArray(); CardList cards = AllZoneUtil.getCreaturesInPlay(card.getController());
for(int i = 0; i < c.length; i++) { for(Card creature:cards) {
if(c[i].isCreature()) { AllZone.GameAction.sacrifice(creature);
AllZone.GameAction.sacrifice(c[i]); CardFactoryUtil.makeToken("Hellion", "R 4 4 hellion", creature.getController(), "R", new String[] {
CardFactoryUtil.makeToken("Hellion", "R 4 4 hellion", c[i].getController(), "R", new String[] {
"Creature", "Hellion"}, 4, 4, new String[] {""}); "Creature", "Hellion"}, 4, 4, new String[] {""});
}
} }
} }
private CardList getCreatures(Player player) {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player);
CardList creatures = new CardList();
creatures.addAll(play.getCards());
creatures = creatures.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature();
}
});
return creatures;
}
};//SpellAbility };//SpellAbility
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
@@ -6476,7 +6214,6 @@ public class CardFactory_Sorceries {
else if(cardName.equals("Patriarch's Bidding")) { else if(cardName.equals("Patriarch's Bidding")) {
final String[] input = new String[2]; final String[] input = new String[2];
// final SpellAbility ability = new Ability(card, "0") {
final SpellAbility spell = new Spell(card) { final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -2182173662547136798L; private static final long serialVersionUID = -2182173662547136798L;
@@ -6557,18 +6294,7 @@ public class CardFactory_Sorceries {
} }
}//resolve() }//resolve()
};//SpellAbility };//SpellAbility
/* No longer needed.
Command intoPlay = new Command() {
private static final long serialVersionUID = 5634360316643996274L;
public void execute() {
ability.setStackDescription("When " + card.getName()
+ " comes into play, choose a creature type.");
AllZone.Stack.add(ability);
}
};
card.addComesIntoPlayCommand(intoPlay);
*/
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(spell); card.addSpellAbility(spell);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -7248,6 +6974,7 @@ public class CardFactory_Sorceries {
spell.setDescription(abCost+"Destroy target non-Swamp land. If that land was nonbasic, Choking Sands deals 2 damage to the land's controller."); spell.setDescription(abCost+"Destroy target non-Swamp land. If that land was nonbasic, Choking Sands deals 2 damage to the land's controller.");
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Rite of Flame")) { else if(cardName.equals("Rite of Flame")) {
final SpellAbility spell = new Spell(card) { final SpellAbility spell = new Spell(card) {