- Simplified the code found in forge.ComputerAI_General and forge.ComputerUtil_Attack2.

This commit is contained in:
jendave
2011-08-07 01:02:37 +00:00
parent 985bc86046
commit 4624f7730a
2 changed files with 20 additions and 15 deletions

View File

@@ -55,7 +55,8 @@ public class ComputerAI_General implements Computer {
if (c.getSVar("PlayMain1").equals("TRUE"))
return true;
if(c.isCreature() && (c.getKeyword().contains("Haste")) || c.getKeyword().contains("Exalted")) return true;
if (c.isCreature()
&& (c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) return true;
CardList buffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer); //get all cards the computer controls with BuffedBy
for(int j = 0; j < buffed.size(); j++) {
@@ -119,8 +120,10 @@ public class ComputerAI_General implements Computer {
//Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() {
public boolean addCard(Card c) {
if(c.isPermanent() && c.getKeyword().contains("Flash") && (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
if (c.isPermanent()
&& c.hasKeyword("Flash")
&& (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
return false;
return true;
}
@@ -156,8 +159,10 @@ public class ComputerAI_General implements Computer {
//Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() {
public boolean addCard(Card c) {
if(c.isPermanent() && c.getKeyword().contains("Flash") && (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
if (c.isPermanent()
&& c.hasKeyword("Flash")
&& (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
return false;
return true;
}
@@ -253,7 +258,7 @@ public class ComputerAI_General implements Computer {
for(int i = 0; i < att.length; i++) {
// tapping of attackers happens after Propaganda is paid for
//if(!att[i].getKeyword().contains("Vigilance")) att[i].tap();
//if (!att[i].hasKeyword("Vigilance")) att[i].tap();
Log.debug("Computer just assigned " + att[i].getName() + " as an attacker.");
}

View File

@@ -165,7 +165,7 @@ public class ComputerUtil_Attack2 {
//re-add creatures with vigilance
for (Card c:attackers)
{
if (c.getKeyword().contains("Vigilance"))
if (c.hasKeyword("Vigilance"))
notNeededAsBlockers.add(c);
}
@@ -255,10 +255,10 @@ public class ComputerUtil_Attack2 {
//Atackers that don't really have a choice
for (Card attacker : attackers)
{
if ( (attacker.getKeyword().contains("CARDNAME attacks each turn if able.")
|| attacker.getKeyword().contains("At the beginning of the end step, destroy CARDNAME.")
|| attacker.getKeyword().contains("At the beginning of the end step, exile CARDNAME.")
|| attacker.getKeyword().contains("At the beginning of the end step, sacrifice CARDNAME.")
if ( (attacker.hasKeyword("CARDNAME attacks each turn if able.")
|| attacker.hasKeyword("At the beginning of the end step, destroy CARDNAME.")
|| attacker.hasKeyword("At the beginning of the end step, exile CARDNAME.")
|| attacker.hasKeyword("At the beginning of the end step, sacrifice CARDNAME.")
|| attacker.getSacrificeAtEOT()
|| attacker.getSirenAttackOrDestroy())
&& CombatUtil.canAttack(attacker, combat)) {
@@ -483,7 +483,7 @@ public class ComputerUtil_Attack2 {
CardList list = AllZoneUtil.getPlayerCardsInPlay(player);
list = list.filter(new CardListFilter(){
public boolean addCard(Card c) {
return c.getKeyword().contains("Exalted");
return c.hasKeyword("Exalted");
}
});
@@ -494,7 +494,7 @@ public class ComputerUtil_Attack2 {
{
int n = c.getNetCombatDamage();
if(c.getKeyword().contains("Double Strike"))
if (c.hasKeyword("Double Strike"))
n *= 2;
return n;
@@ -523,9 +523,9 @@ public class ComputerUtil_Attack2 {
}
}
// see if this attacking creature can destroy this defender, if not record that it can't kill everything
if(!CombatUtil.canDestroyBlocker(defender, attacker, combat, false)){
if (!CombatUtil.canDestroyBlocker(defender, attacker, combat, false)) {
canKillAll = false;
if(defender.getKeyword().contains("Wither") || defender.getKeyword().contains("Infect")){
if (defender.hasKeyword("Wither") || defender.hasKeyword("Infect")) {
canKillAllDangerous = false; // there is a dangerous creature that can survive an attack from this creature
}
}