mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
some code cleanup in ComputerAI_General
This commit is contained in:
@@ -45,146 +45,137 @@ public class ComputerAI_General implements Computer {
|
|||||||
}//playCards()
|
}//playCards()
|
||||||
|
|
||||||
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() {
|
|
||||||
// Beached As Start
|
|
||||||
public boolean addCard(Card c) {
|
|
||||||
//Collection<Card> play = playMain1Cards;
|
|
||||||
if (c.getSVar("PlayMain1").equals("TRUE"))
|
|
||||||
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
|
hand = hand.filter(new CardListFilter() {
|
||||||
for(int j = 0; j < buffed.size(); j++) {
|
// Beached As Start
|
||||||
Card buffedcard = buffed.get(j);
|
public boolean addCard(Card c) {
|
||||||
if (buffedcard.getSVar("BuffedBy").length() > 0) {
|
//Collection<Card> play = playMain1Cards;
|
||||||
String buffedby = buffedcard.getSVar("BuffedBy");
|
if (c.getSVar("PlayMain1").equals("TRUE"))
|
||||||
String bffdby[] = buffedby.split(",");
|
return true;
|
||||||
if (c.isValidCard(bffdby,c.getController(),c)) return true;
|
|
||||||
}
|
|
||||||
}//BuffedBy
|
|
||||||
|
|
||||||
CardList antibuffed = new CardList(AllZone.Human_Battlefield.getCards()); //get all cards the human controls with AntiBuffedBy
|
if(c.isCreature() && (c.getKeyword().contains("Haste")) || c.getKeyword().contains("Exalted")) return true;
|
||||||
for(int k = 0; k < antibuffed.size(); k++) {
|
|
||||||
Card buffedcard = antibuffed.get(k);
|
|
||||||
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
|
|
||||||
String buffedby = buffedcard.getSVar("AntiBuffedBy");
|
|
||||||
String bffdby[] = buffedby.split(",");
|
|
||||||
if (c.isValidCard(bffdby,c.getController(),c)) return true;
|
|
||||||
}
|
|
||||||
}//AntiBuffedBy
|
|
||||||
|
|
||||||
if(c.isLand()) return false;
|
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) {
|
||||||
|
String buffedby = buffedcard.getSVar("BuffedBy");
|
||||||
|
String bffdby[] = buffedby.split(",");
|
||||||
|
if (c.isValidCard(bffdby,c.getController(),c)) return true;
|
||||||
|
}
|
||||||
|
}//BuffedBy
|
||||||
|
|
||||||
CardList Vengevines = new CardList();
|
CardList antibuffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer); //get all cards the human controls with AntiBuffedBy
|
||||||
Vengevines.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards());
|
for(int k = 0; k < antibuffed.size(); k++) {
|
||||||
Vengevines = Vengevines.getName("Vengevine");
|
Card buffedcard = antibuffed.get(k);
|
||||||
if(Vengevines.size() > 0) {
|
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
|
||||||
CardList Creatures = new CardList();
|
String buffedby = buffedcard.getSVar("AntiBuffedBy");
|
||||||
CardList Creatures2 = new CardList();
|
String bffdby[] = buffedby.split(",");
|
||||||
Creatures.addAll(AllZone.getZone(Constant.Zone.Hand, AllZone.ComputerPlayer).getCards());
|
if (c.isValidCard(bffdby,c.getController(),c)) return true;
|
||||||
for(int i = 0; i < Creatures.size(); i++) {
|
}
|
||||||
if(Creatures.get(i).getType().contains("Creature") && CardUtil.getConvertedManaCost(Creatures.get(i).getManaCost()) <= 3) {
|
}//AntiBuffedBy
|
||||||
Creatures2.add(Creatures.get(i));
|
|
||||||
}
|
if(c.isLand()) return false;
|
||||||
}
|
|
||||||
if(Creatures2.size() + Phase.ComputerCreatureSpellCount > 1
|
CardList vengevines = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer, "Vengevine");
|
||||||
&& c.getType().contains("Creature") && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) return true;
|
if(vengevines.size() > 0) {
|
||||||
} // AI Improvement for Vengevine
|
CardList creatures = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
|
||||||
// Beached As End
|
CardList creatures2 = new CardList();
|
||||||
return false;
|
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 all = new CardList();
|
}
|
||||||
all.addAll(hand.toArray());
|
}
|
||||||
all.addAll(AllZone.Computer_Battlefield.getCards());
|
if(creatures2.size() + Phase.ComputerCreatureSpellCount > 1
|
||||||
|
&& c.getType().contains("Creature") && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) return true;
|
||||||
CardList humanPlayable = new CardList();
|
} // AI Improvement for Vengevine
|
||||||
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
|
// Beached As End
|
||||||
humanPlayable = humanPlayable.filter(new CardListFilter()
|
return false;
|
||||||
{
|
}
|
||||||
public boolean addCard(Card c)
|
});
|
||||||
{
|
CardList all = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||||
return (c.canAnyPlayerActivate());
|
all.addAll(hand);
|
||||||
}
|
|
||||||
});
|
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
|
||||||
|
humanPlayable = humanPlayable.filter(new CardListFilter()
|
||||||
all.addAll(humanPlayable.toArray());
|
{
|
||||||
|
public boolean addCard(Card c)
|
||||||
return getPlayable(all);
|
{
|
||||||
|
return (c.canAnyPlayerActivate());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
all.addAll(humanPlayable);
|
||||||
|
|
||||||
|
return getPlayable(all);
|
||||||
}//getMain1()
|
}//getMain1()
|
||||||
|
|
||||||
|
|
||||||
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) {
|
if(c.isPermanent() && c.getKeyword().contains("Flash") && (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|
||||||
if(c.isPermanent() && c.getKeyword().contains("Flash") && (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
|
||||||
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
|
return false;
|
||||||
return false;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
});
|
||||||
});
|
all.addAll(AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer));
|
||||||
all.addAll(AllZone.Computer_Battlefield.getCards());
|
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer));
|
||||||
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer).toArray());
|
|
||||||
|
// 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.");
|
|
||||||
|
all = all.filter(new CardListFilter() {
|
||||||
all = all.filter(new CardListFilter() {
|
public boolean addCard(Card c) {
|
||||||
public boolean addCard(Card c) {
|
if(c.isLand()) return false;
|
||||||
if(c.isLand()) return false;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
|
||||||
CardList humanPlayable = new CardList();
|
humanPlayable = humanPlayable.filter(new CardListFilter()
|
||||||
humanPlayable.addAll(AllZone.Human_Battlefield.getCards());
|
{
|
||||||
humanPlayable = humanPlayable.filter(new CardListFilter()
|
public boolean addCard(Card c)
|
||||||
{
|
{
|
||||||
public boolean addCard(Card c)
|
return (c.canAnyPlayerActivate());
|
||||||
{
|
}
|
||||||
return (c.canAnyPlayerActivate());
|
});
|
||||||
}
|
all.addAll(humanPlayable.toArray());
|
||||||
});
|
|
||||||
all.addAll(humanPlayable.toArray());
|
return getPlayable(all);
|
||||||
|
|
||||||
return getPlayable(all);
|
|
||||||
}//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) {
|
if(c.isPermanent() && c.getKeyword().contains("Flash") && (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|
||||||
if(c.isPermanent() && c.getKeyword().contains("Flash") && (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
|
||||||
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
|
return false;
|
||||||
return false;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
});
|
||||||
});
|
all.addAll(AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer));
|
||||||
all.addAll(AllZone.Computer_Battlefield.getCards());
|
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer));
|
||||||
all.addAll(CardFactoryUtil.getGraveyardActivationCards(AllZone.ComputerPlayer).toArray());
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
{
|
||||||
{
|
return (c.canAnyPlayerActivate());
|
||||||
return (c.canAnyPlayerActivate());
|
}
|
||||||
}
|
});
|
||||||
});
|
all.addAll(humanPlayable.toArray());
|
||||||
all.addAll(humanPlayable.toArray());
|
return all;
|
||||||
return all;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpellAbility[] getOtherPhases(){
|
private SpellAbility[] getOtherPhases(){
|
||||||
|
|||||||
Reference in New Issue
Block a user