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() {
//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() {
// 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;
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++) {
Card buffedcard = buffed.get(j);
if (buffedcard.getSVar("BuffedBy").length() > 0) {
@@ -67,7 +67,7 @@ public class ComputerAI_General implements Computer {
}
}//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++) {
Card buffedcard = antibuffed.get(k);
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
@@ -79,31 +79,26 @@ public class ComputerAI_General implements Computer {
if(c.isLand()) return false;
CardList Vengevines = new CardList();
Vengevines.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards());
Vengevines = Vengevines.getName("Vengevine");
if(Vengevines.size() > 0) {
CardList Creatures = new CardList();
CardList Creatures2 = new CardList();
Creatures.addAll(AllZone.getZone(Constant.Zone.Hand, AllZone.ComputerPlayer).getCards());
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));
CardList vengevines = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer, "Vengevine");
if(vengevines.size() > 0) {
CardList creatures = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
CardList creatures2 = new CardList();
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;
} // AI Improvement for Vengevine
// Beached As End
return false;
}
});
CardList all = new CardList();
all.addAll(hand.toArray());
all.addAll(AllZone.Computer_Battlefield.getCards());
CardList all = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
all.addAll(hand);
CardList humanPlayable = new CardList();
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
humanPlayable = humanPlayable.filter(new CardListFilter()
{
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);
}//getMain1()
@@ -120,8 +115,7 @@ public class ComputerAI_General implements Computer {
private SpellAbility[] getMain2() {
//Card list of all cards to consider
CardList all = new CardList();
all.addAll(AllZone.Computer_Hand.getCards());
CardList all = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
//Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() {
public boolean addCard(Card c) {
@@ -131,8 +125,8 @@ public class ComputerAI_General implements Computer {
return true;
}
});
all.addAll(AllZone.Computer_Battlefield.getCards());
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer).toArray());
all.addAll(AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer));
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer));
// 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.");
@@ -144,8 +138,7 @@ public class ComputerAI_General implements Computer {
}
});
CardList humanPlayable = new CardList();
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
humanPlayable = humanPlayable.filter(new CardListFilter()
{
public boolean addCard(Card c)
@@ -159,8 +152,7 @@ public class ComputerAI_General implements Computer {
}//getMain2()
private CardList getAvailableSpellAbilities(){
CardList all = new CardList();
all.addAll(AllZone.Computer_Hand.getCards());
CardList all = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
//Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() {
public boolean addCard(Card c) {
@@ -170,12 +162,11 @@ public class ComputerAI_General implements Computer {
return true;
}
});
all.addAll(AllZone.Computer_Battlefield.getCards());
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer).toArray());
all.addAll(AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer));
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer));
CardList humanPlayable = new CardList();
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
humanPlayable = humanPlayable.filter(new CardListFilter()
{
public boolean addCard(Card c)