mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +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)) {
|
for (final SpellAbility sa : getOriginalAndAltCostAbilities(all)) {
|
||||||
// Don't add Counterspells to the "normal" playcard lookups
|
// Don't add Counterspells to the "normal" playcard lookups
|
||||||
if (sa.getApi() == ApiType.Counter && skipCounter) {
|
if (skipCounter && sa.getApi() == ApiType.Counter) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sa.setActivatingPlayer(player);
|
sa.setActivatingPlayer(player);
|
||||||
|
|||||||
@@ -1019,18 +1019,6 @@ public class ComputerUtil {
|
|||||||
int defense = 0;
|
int defense = 0;
|
||||||
boolean grantIndestructible = false;
|
boolean grantIndestructible = false;
|
||||||
boolean grantShroud = 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) {
|
if (topStack == null) {
|
||||||
return objects;
|
return objects;
|
||||||
@@ -1051,20 +1039,36 @@ public class ComputerUtil {
|
|||||||
} else if (topStack.hasParam("ValidCards")) {
|
} else if (topStack.hasParam("ValidCards")) {
|
||||||
CardCollectionView battleField = aiPlayer.getCardsIn(ZoneType.Battlefield);
|
CardCollectionView battleField = aiPlayer.getCardsIn(ZoneType.Battlefield);
|
||||||
objects = CardLists.getValidCards(battleField, topStack.getParam("ValidCards").split(","), source.getController(), source);
|
objects = CardLists.getValidCards(battleField, topStack.getParam("ValidCards").split(","), source.getController(), source);
|
||||||
|
} else {
|
||||||
|
return threatened;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
objects = topStack.getTargets().getTargets();
|
objects = topStack.getTargets().getTargets();
|
||||||
if (tgt != null) {
|
final ArrayList<GameObject> canBeTargeted = new ArrayList<GameObject>();
|
||||||
final ArrayList<GameObject> canBeTargeted = new ArrayList<GameObject>();
|
for (Object o : objects) {
|
||||||
for (Object o : objects) {
|
if (o instanceof Card) {
|
||||||
if (o instanceof Card) {
|
final Card c = (Card) o;
|
||||||
final Card c = (Card) o;
|
if (c.canBeTargetedBy(topStack)) {
|
||||||
if (c.canBeTargetedBy(topStack)) {
|
canBeTargeted.add(c);
|
||||||
canBeTargeted.add(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
objects = canBeTargeted;
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -796,7 +796,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
if (!ai.getGame().getStack().isEmpty()) {
|
if (!ai.getGame().getStack().isEmpty()) {
|
||||||
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), null);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), null);
|
||||||
for (Card c : blockers) {
|
for (Card c : blockers) {
|
||||||
if (objects.contains(c) && blockers.contains(c)) {
|
if (objects.contains(c)) {
|
||||||
untappedCreats.add(c);
|
untappedCreats.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user