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
public void resolve() {
//get all creatures
CardList list = new CardList();
list.addAll(AllZone.Human_Battlefield.getCards());
list.addAll(AllZone.Computer_Battlefield.getCards());
list = list.getType("Creature");
CardList list = AllZoneUtil.getCreaturesInPlay();
for(int i = 0; i < list.size(); i++) {
final Card[] target = new Card[1];
@@ -428,9 +424,7 @@ public class CardFactory_Sorceries {
@Override
public void resolve() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, getTargetPlayer());
CardList list = new CardList(play.getCards());
list = list.getType("Creature");
CardList list = AllZoneUtil.getCreaturesInPlay(getTargetPlayer());
list.shuffle();
@@ -489,7 +483,6 @@ public class CardFactory_Sorceries {
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 - 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_two.setStackDescription("Lab Rats - Buyback, Put a 1/1 black Rat token into play");
@@ -673,38 +666,6 @@ public class CardFactory_Sorceries {
spell.setBeforePayMana(target);
}//*************** 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 **************************
else if(cardName.equals("Grapeshot")) {
@@ -753,8 +714,6 @@ public class CardFactory_Sorceries {
handChoices[i] = null;
}
AllZone.Display.getChoice("Random card", handChoices);
//AllZone.GameAction.addDamage(opponent, card,
// CardUtil.getConvertedManaCost(choice.getManaCost()));
opponent.addDamage(CardUtil.getConvertedManaCost(choice.getManaCost()), card);
}
}//resolve()
@@ -1556,10 +1515,7 @@ public class CardFactory_Sorceries {
@Override
public void resolve() {
CardList all = new CardList();
all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards());
all = all.getType("Creature");
CardList all = AllZoneUtil.getCreaturesInPlay();
for(int i = 0; i < all.size(); i++)
if(!all.get(i).getKeyword().contains("Flying")) {
@@ -1646,11 +1602,7 @@ public class CardFactory_Sorceries {
for(int i = 0; i < all.size(); i++)
if(all.get(i).getName().equals(c.getName())) {
if(player.equals(AllZone.HumanPlayer)) {
AllZone.GameAction.moveTo(AllZone.Human_Exile, all.get(i));
} else {
AllZone.GameAction.moveTo(AllZone.Computer_Exile, all.get(i));
}
AllZone.GameAction.exile(all.get(i));
}
}//remove()
@@ -1723,9 +1675,7 @@ public class CardFactory_Sorceries {
if(!getTargetCard().isFaceDown()) {
//get all creatures
CardList list = new CardList();
list.addAll(AllZone.Human_Battlefield.getCards());
list.addAll(AllZone.Computer_Battlefield.getCards());
CardList list = AllZoneUtil.getCardsInPlay();
list = list.getName(getTargetCard().getName());
list.remove(getTargetCard());
@@ -2197,9 +2147,7 @@ public class CardFactory_Sorceries {
@Override
public void resolve() {
CardList all = new CardList();
all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards());
CardList all = AllZoneUtil.getCardsInPlay();
int Soldiers = card.getXManaCostPaid();
for(int i = 0; i < Soldiers; i++) {
CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card.getController(), "W", new String[] {
@@ -2215,11 +2163,8 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
CardList human = new CardList(AllZone.Human_Battlefield.getCards());
CardList computer = new CardList(AllZone.Computer_Battlefield.getCards());
human = human.getType("Creature");
computer = computer.getType("Creature");
CardList human = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer);
CardList computer = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
// the computer will at least destroy 2 more human creatures
return (computer.size() < human.size() - 1
@@ -2252,6 +2197,7 @@ public class CardFactory_Sorceries {
//System.out.println(userChoice);
//System.out.println(m_land[0]);
//System.out.println(m_player[0]);
//"Incendiary Command deals 4 damage to target player",
for(int i = 0; i <card.getChoices().size(); i++) {
if(card.getChoice(i).equals(cardChoice[0])) {
@@ -2670,11 +2616,9 @@ public class CardFactory_Sorceries {
}
};
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.setSVar("PlayMain1", "TRUE");
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
@@ -2708,104 +2652,6 @@ public class CardFactory_Sorceries {
card.setFlashback(true);
}//*************** 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 **************************
else if(cardName.equals("Pulse of the Tangle")) {
@@ -3580,15 +3426,8 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlay() {
Player oppPlayer = card.getController().getOpponent();
PlayerZone selfZone = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
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");
CardList self = AllZoneUtil.getPlayerLandsInPlay(card.getController());
CardList opp = AllZoneUtil.getPlayerLandsInPlay(oppPlayer);
return (self.size() < opp.size()) && super.canPlay();
}//canPlay()
@@ -3623,11 +3462,8 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
PlayerZone cPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer);
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer);
CardList hList = new CardList(hPlay.getCards());
CardList cList = new CardList(cPlay.getCards());
CardList hList = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
CardList cList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
CardList smallCreats = cList.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature() && c.getNetAttack() < 2 && c.getNetDefense() < 3;
@@ -3646,74 +3482,6 @@ public class CardFactory_Sorceries {
card.addSpellAbility(spell);
}//*************** 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 **************************
else if(cardName.equals("Rite of Replication")) {
@@ -3721,12 +3489,8 @@ public class CardFactory_Sorceries {
private static final long serialVersionUID = -2902112019334177L;
@Override
public boolean canPlayAI() {
PlayerZone zone = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
Card biggest = null;
if(zone != null) {
CardList creature = new CardList();
creature.addAll(zone.getCards());
creature = creature.getType("Creature");
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
creature = creature.filter(new CardListFilter() {
public boolean addCard(Card card) {
return (!card.getType().contains("Legendary"));
@@ -3737,7 +3501,7 @@ public class CardFactory_Sorceries {
for(int i = 0; i < creature.size(); i++)
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
setTargetCard(biggest);
}
return biggest.getNetAttack() > 4;
}
@@ -4997,10 +4761,8 @@ public class CardFactory_Sorceries {
public void resolve()
{
//Lands:
CardList humLand = new CardList(AllZone.Human_Battlefield.getCards());
humLand = humLand.getType("Land");
CardList compLand = new CardList(AllZone.Computer_Battlefield.getCards());
compLand = compLand.getType("Land");
CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.ComputerPlayer);
if (compLand.size() > humLand.size())
{
@@ -5015,8 +4777,8 @@ public class CardFactory_Sorceries {
}
//Hand
CardList humHand = new CardList(AllZone.Human_Hand.getCards());
CardList compHand = new CardList(AllZone.Computer_Hand.getCards());
CardList humHand = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
CardList compHand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
int handDiff = humHand.size() - compHand.size();
if (compHand.size() > humHand.size())
@@ -5029,10 +4791,8 @@ public class CardFactory_Sorceries {
}
//Creatures:
CardList humCreats = new CardList(AllZone.Human_Battlefield.getCards());
humCreats = humCreats.getType("Creature");
CardList compCreats = new CardList(AllZone.Computer_Battlefield.getCards());
compCreats = compCreats.getType("Creature");
CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer);
CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
if (compCreats.size() > humCreats.size())
{
@@ -5052,20 +4812,17 @@ public class CardFactory_Sorceries {
public boolean canPlayAI()
{
int diff = 0;
CardList humLand = new CardList(AllZone.Human_Battlefield.getCards());
humLand = humLand.getType("Land");
CardList compLand = new CardList(AllZone.Computer_Battlefield.getCards());
compLand = compLand.getType("Land");
CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.ComputerPlayer);
diff += humLand.size() - compLand.size();
CardList humCreats = new CardList(AllZone.Human_Battlefield.getCards());
humCreats = humCreats.getType("Creature");
CardList compCreats = new CardList(AllZone.Computer_Battlefield.getCards());
CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer);
CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
compCreats = compCreats.getType("Creature");
diff += 1.5 * (humCreats.size() - compCreats.size());
CardList humHand = new CardList(AllZone.Human_Hand.getCards());
CardList compHand = new CardList(AllZone.Computer_Hand.getCards());
CardList humHand = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
CardList compHand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
diff += 0.5 * (humHand.size() - compHand.size());
return diff > 2;
@@ -5173,16 +4930,10 @@ public class CardFactory_Sorceries {
// The computer should only play this card if it has at least
// one land in its hand. Because of the way the computer turn
// is structured, it will already have played land to it's limit
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand,
AllZone.ComputerPlayer);
CardList list = new CardList(hand.getCards());
list = list.getType("Land");
if (list.size() > 0)
return true;
else
return false;
CardList hand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
hand = hand.getType("Land");
return hand.size() > 0;
}
public void resolve() {
@@ -5271,32 +5022,19 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
return getCreatures(AllZone.ComputerPlayer).size() > 0;
return AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer).size() > 0;
}
@Override
public void resolve() {
Card[] c = getCreatures(card.getController()).toArray();
for(int i = 0; i < c.length; i++) {
if(c[i].isCreature()) {
AllZone.GameAction.sacrifice(c[i]);
CardFactoryUtil.makeToken("Hellion", "R 4 4 hellion", c[i].getController(), "R", new String[] {
CardList cards = AllZoneUtil.getCreaturesInPlay(card.getController());
for(Card creature:cards) {
AllZone.GameAction.sacrifice(creature);
CardFactoryUtil.makeToken("Hellion", "R 4 4 hellion", creature.getController(), "R", 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
card.clearSpellAbility();
card.addSpellAbility(spell);
@@ -6476,7 +6214,6 @@ public class CardFactory_Sorceries {
else if(cardName.equals("Patriarch's Bidding")) {
final String[] input = new String[2];
// final SpellAbility ability = new Ability(card, "0") {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -2182173662547136798L;
@@ -6557,18 +6294,7 @@ public class CardFactory_Sorceries {
}
}//resolve()
};//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.addSpellAbility(spell);
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.");
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Rite of Flame")) {
final SpellAbility spell = new Spell(card) {