some code cleanup in ComputerAI_General

This commit is contained in:
jendave
2011-08-07 00:58:42 +00:00
parent 457aa70df8
commit 32e6723149

View File

@@ -46,7 +46,7 @@ public class ComputerAI_General implements Computer {
private SpellAbility[] getMain1() { private SpellAbility[] getMain1() {
//Card list of all cards to consider //Card list of all cards to consider
CardList hand = new CardList(AllZone.Computer_Hand.getCards()); CardList hand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
hand = hand.filter(new CardListFilter() { hand = hand.filter(new CardListFilter() {
// Beached As Start // Beached As Start
@@ -57,7 +57,7 @@ public class ComputerAI_General implements Computer {
if(c.isCreature() && (c.getKeyword().contains("Haste")) || c.getKeyword().contains("Exalted")) return true; if(c.isCreature() && (c.getKeyword().contains("Haste")) || c.getKeyword().contains("Exalted")) return true;
CardList buffed = new CardList(AllZone.Computer_Battlefield.getCards()); //get all cards the computer controls with BuffedBy CardList buffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer); //get all cards the computer controls with BuffedBy
for(int j = 0; j < buffed.size(); j++) { for(int j = 0; j < buffed.size(); j++) {
Card buffedcard = buffed.get(j); Card buffedcard = buffed.get(j);
if (buffedcard.getSVar("BuffedBy").length() > 0) { if (buffedcard.getSVar("BuffedBy").length() > 0) {
@@ -67,7 +67,7 @@ public class ComputerAI_General implements Computer {
} }
}//BuffedBy }//BuffedBy
CardList antibuffed = new CardList(AllZone.Human_Battlefield.getCards()); //get all cards the human controls with AntiBuffedBy CardList antibuffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer); //get all cards the human controls with AntiBuffedBy
for(int k = 0; k < antibuffed.size(); k++) { for(int k = 0; k < antibuffed.size(); k++) {
Card buffedcard = antibuffed.get(k); Card buffedcard = antibuffed.get(k);
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) { if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
@@ -79,31 +79,26 @@ public class ComputerAI_General implements Computer {
if(c.isLand()) return false; if(c.isLand()) return false;
CardList Vengevines = new CardList(); CardList vengevines = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer, "Vengevine");
Vengevines.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards()); if(vengevines.size() > 0) {
Vengevines = Vengevines.getName("Vengevine"); CardList creatures = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
if(Vengevines.size() > 0) { CardList creatures2 = new CardList();
CardList Creatures = new CardList(); for(int i = 0; i < creatures.size(); i++) {
CardList Creatures2 = new CardList(); if(creatures.get(i).getType().contains("Creature") && CardUtil.getConvertedManaCost(creatures.get(i).getManaCost()) <= 3) {
Creatures.addAll(AllZone.getZone(Constant.Zone.Hand, AllZone.ComputerPlayer).getCards()); creatures2.add(creatures.get(i));
for(int i = 0; i < Creatures.size(); i++) {
if(Creatures.get(i).getType().contains("Creature") && CardUtil.getConvertedManaCost(Creatures.get(i).getManaCost()) <= 3) {
Creatures2.add(Creatures.get(i));
} }
} }
if(Creatures2.size() + Phase.ComputerCreatureSpellCount > 1 if(creatures2.size() + Phase.ComputerCreatureSpellCount > 1
&& c.getType().contains("Creature") && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) return true; && c.getType().contains("Creature") && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) return true;
} // AI Improvement for Vengevine } // AI Improvement for Vengevine
// Beached As End // Beached As End
return false; return false;
} }
}); });
CardList all = new CardList(); CardList all = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
all.addAll(hand.toArray()); all.addAll(hand);
all.addAll(AllZone.Computer_Battlefield.getCards());
CardList humanPlayable = new CardList(); CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
humanPlayable = humanPlayable.filter(new CardListFilter() humanPlayable = humanPlayable.filter(new CardListFilter()
{ {
public boolean addCard(Card c) public boolean addCard(Card c)
@@ -112,7 +107,7 @@ public class ComputerAI_General implements Computer {
} }
}); });
all.addAll(humanPlayable.toArray()); all.addAll(humanPlayable);
return getPlayable(all); return getPlayable(all);
}//getMain1() }//getMain1()
@@ -120,8 +115,7 @@ public class ComputerAI_General implements Computer {
private SpellAbility[] getMain2() { private SpellAbility[] getMain2() {
//Card list of all cards to consider //Card list of all cards to consider
CardList all = new CardList(); CardList all = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
all.addAll(AllZone.Computer_Hand.getCards());
//Don't play permanents with Flash before humans declare attackers step //Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() { all = all.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -131,8 +125,8 @@ public class ComputerAI_General implements Computer {
return true; return true;
} }
}); });
all.addAll(AllZone.Computer_Battlefield.getCards()); all.addAll(AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer));
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer).toArray()); all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer));
// Prevent the computer from summoning Ball Lightning type creatures during main phase 2 // Prevent the computer from summoning Ball Lightning type creatures during main phase 2
all = all.getNotKeyword("At the beginning of the end step, sacrifice CARDNAME."); all = all.getNotKeyword("At the beginning of the end step, sacrifice CARDNAME.");
@@ -144,8 +138,7 @@ public class ComputerAI_General implements Computer {
} }
}); });
CardList humanPlayable = new CardList(); CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
humanPlayable = humanPlayable.filter(new CardListFilter() humanPlayable = humanPlayable.filter(new CardListFilter()
{ {
public boolean addCard(Card c) public boolean addCard(Card c)
@@ -159,8 +152,7 @@ public class ComputerAI_General implements Computer {
}//getMain2() }//getMain2()
private CardList getAvailableSpellAbilities(){ private CardList getAvailableSpellAbilities(){
CardList all = new CardList(); CardList all = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
all.addAll(AllZone.Computer_Hand.getCards());
//Don't play permanents with Flash before humans declare attackers step //Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() { all = all.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -170,12 +162,11 @@ public class ComputerAI_General implements Computer {
return true; return true;
} }
}); });
all.addAll(AllZone.Computer_Battlefield.getCards()); all.addAll(AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer));
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer).toArray()); all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer));
CardList humanPlayable = new CardList(); CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
humanPlayable = humanPlayable.filter(new CardListFilter() humanPlayable = humanPlayable.filter(new CardListFilter()
{ {
public boolean addCard(Card c) public boolean addCard(Card c)