- The AI will now also use spells and abilities from external zones in Main1 (enables unearth).

- The AI will now cast creature spells in Main1 if an ability or spell that can give it haste is available.
This commit is contained in:
Sloth
2011-11-04 19:16:15 +00:00
parent a1af13c095
commit 6af745c016

View File

@@ -3,10 +3,12 @@ package forge;
import static forge.error.ErrorViewer.showError;
import java.util.ArrayList;
import java.util.HashMap;
import com.esotericsoftware.minlog.Log;
import forge.Constant.Zone;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
@@ -89,6 +91,8 @@ public class ComputerAIGeneral implements Computer {
// Card list of all cards to consider
CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
final boolean hasACardGivingHaste = hasACardGivingHaste();
if (AllZone.getComputerPlayer().getManaPool().isEmpty()) {
hand = hand.filter(new CardListFilter() {
public boolean addCard(final Card c) {
@@ -102,7 +106,7 @@ public class ComputerAIGeneral implements Computer {
return true;
}
if (c.isCreature() && (c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) {
if (c.isCreature() && (hasACardGivingHaste || c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) {
return true;
}
@@ -158,6 +162,7 @@ public class ComputerAIGeneral implements Computer {
});
}
CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer()));
all.addAll(hand);
CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
@@ -172,6 +177,40 @@ public class ComputerAIGeneral implements Computer {
return getPlayable(all);
} // getMain1()
/**
* <p>
* hasACardGivingHaste.
* </p>
*
* @return a boolean.
*/
public boolean hasACardGivingHaste() {
CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer()));
all.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand));
for (Card c : all) {
for (SpellAbility sa : c.getSpellAbility()) {
if(sa.getAbilityFactory() == null) {
continue;
}
AbilityFactory af = sa.getAbilityFactory();
HashMap<String, String> abilityParams = af.getMapParams();
if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump")) {
continue;
}
if (abilityParams.containsKey("SP") && !abilityParams.get("SP").equals("Pump")) {
continue;
}
if (abilityParams.containsKey("KW") && abilityParams.get("KW").contains("Haste")) {
return true;
}
}
}
return false;
} //hasACardGivingHaste
/**
* <p>
* getMain2.