mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Cleanup and performance fixes in AI functions.
This commit is contained in:
@@ -1253,7 +1253,7 @@ public class AiController {
|
||||
|
||||
for (final SpellAbility sa : getOriginalAndAltCostAbilities(all)) {
|
||||
// Don't add Counterspells to the "normal" playcard lookups
|
||||
if (sa.getApi() == ApiType.Counter && skipCounter) {
|
||||
if (skipCounter && sa.getApi() == ApiType.Counter) {
|
||||
continue;
|
||||
}
|
||||
sa.setActivatingPlayer(player);
|
||||
|
||||
@@ -1019,18 +1019,6 @@ public class ComputerUtil {
|
||||
int defense = 0;
|
||||
boolean grantIndestructible = false;
|
||||
boolean grantShroud = false;
|
||||
if (saviourApi == ApiType.Pump || saviourApi == ApiType.PumpAll) {
|
||||
defense = saviour.hasParam("NumDef") ?
|
||||
AbilityUtils.calculateAmount(saviour.getHostCard(), saviour.getParam("NumDef"), saviour) : 0;
|
||||
final List<String> keywords = saviour.hasParam("KW") ?
|
||||
Arrays.asList(saviour.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
if (keywords.contains("Indestructible")) {
|
||||
grantIndestructible = true;
|
||||
}
|
||||
if (keywords.contains("Hexproof") || keywords.contains("Shroud")) {
|
||||
grantShroud = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (topStack == null) {
|
||||
return objects;
|
||||
@@ -1051,10 +1039,11 @@ public class ComputerUtil {
|
||||
} else if (topStack.hasParam("ValidCards")) {
|
||||
CardCollectionView battleField = aiPlayer.getCardsIn(ZoneType.Battlefield);
|
||||
objects = CardLists.getValidCards(battleField, topStack.getParam("ValidCards").split(","), source.getController(), source);
|
||||
} else {
|
||||
return threatened;
|
||||
}
|
||||
} else {
|
||||
objects = topStack.getTargets().getTargets();
|
||||
if (tgt != null) {
|
||||
final ArrayList<GameObject> canBeTargeted = new ArrayList<GameObject>();
|
||||
for (Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
@@ -1064,8 +1053,23 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canBeTargeted.isEmpty()) {
|
||||
return threatened;
|
||||
}
|
||||
objects = canBeTargeted;
|
||||
}
|
||||
|
||||
if (saviourApi == ApiType.Pump || saviourApi == ApiType.PumpAll) {
|
||||
defense = saviour.hasParam("NumDef") ?
|
||||
AbilityUtils.calculateAmount(saviour.getHostCard(), saviour.getParam("NumDef"), saviour) : 0;
|
||||
final List<String> keywords = saviour.hasParam("KW") ?
|
||||
Arrays.asList(saviour.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
if (keywords.contains("Indestructible")) {
|
||||
grantIndestructible = true;
|
||||
}
|
||||
if (keywords.contains("Hexproof") || keywords.contains("Shroud")) {
|
||||
grantShroud = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if Defined Objects are "threatened" will be destroyed
|
||||
|
||||
@@ -796,7 +796,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
if (!ai.getGame().getStack().isEmpty()) {
|
||||
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), null);
|
||||
for (Card c : blockers) {
|
||||
if (objects.contains(c) && blockers.contains(c)) {
|
||||
if (objects.contains(c)) {
|
||||
untappedCreats.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user