- 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")) if (c.getSVar("PlayMain1").equals("TRUE"))
return 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 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++) {
@@ -119,8 +120,10 @@ public class ComputerAI_General implements Computer {
//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()
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility))) && c.hasKeyword("Flash")
&& (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
return false; return false;
return true; return true;
} }
@@ -156,8 +159,10 @@ public class ComputerAI_General implements Computer {
//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()
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility))) && c.hasKeyword("Flash")
&& (AllZone.Phase.isPlayerTurn(AllZone.ComputerPlayer)
|| AllZone.Phase.isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
return false; return false;
return true; return true;
} }
@@ -253,7 +258,7 @@ public class ComputerAI_General implements Computer {
for(int i = 0; i < att.length; i++) { for(int i = 0; i < att.length; i++) {
// tapping of attackers happens after Propaganda is paid for // 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."); 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 //re-add creatures with vigilance
for (Card c:attackers) for (Card c:attackers)
{ {
if (c.getKeyword().contains("Vigilance")) if (c.hasKeyword("Vigilance"))
notNeededAsBlockers.add(c); notNeededAsBlockers.add(c);
} }
@@ -255,10 +255,10 @@ public class ComputerUtil_Attack2 {
//Atackers that don't really have a choice //Atackers that don't really have a choice
for (Card attacker : attackers) for (Card attacker : attackers)
{ {
if ( (attacker.getKeyword().contains("CARDNAME attacks each turn if able.") if ( (attacker.hasKeyword("CARDNAME attacks each turn if able.")
|| attacker.getKeyword().contains("At the beginning of the end step, destroy CARDNAME.") || attacker.hasKeyword("At the beginning of the end step, destroy CARDNAME.")
|| attacker.getKeyword().contains("At the beginning of the end step, exile CARDNAME.") || attacker.hasKeyword("At the beginning of the end step, exile CARDNAME.")
|| attacker.getKeyword().contains("At the beginning of the end step, sacrifice CARDNAME.") || attacker.hasKeyword("At the beginning of the end step, sacrifice CARDNAME.")
|| attacker.getSacrificeAtEOT() || attacker.getSacrificeAtEOT()
|| attacker.getSirenAttackOrDestroy()) || attacker.getSirenAttackOrDestroy())
&& CombatUtil.canAttack(attacker, combat)) { && CombatUtil.canAttack(attacker, combat)) {
@@ -483,7 +483,7 @@ public class ComputerUtil_Attack2 {
CardList list = AllZoneUtil.getPlayerCardsInPlay(player); CardList list = AllZoneUtil.getPlayerCardsInPlay(player);
list = list.filter(new CardListFilter(){ list = list.filter(new CardListFilter(){
public boolean addCard(Card c) { 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(); int n = c.getNetCombatDamage();
if(c.getKeyword().contains("Double Strike")) if (c.hasKeyword("Double Strike"))
n *= 2; n *= 2;
return n; 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 // 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; 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 canKillAllDangerous = false; // there is a dangerous creature that can survive an attack from this creature
} }
} }