mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
- Attempting to improve Haste detection for the AI such that the AI properly casts creatures in main 1 when there's an Avatar or Emblem or something else giving Haste from the command zone, or if the opponent has something on the battlefield that gives Haste to AI's creatures as well (e.g. Mass Hysteria).
This commit is contained in:
@@ -951,7 +951,8 @@ public class ComputerUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (card.isCreature() && !card.hasKeyword("Defender") && (card.hasKeyword("Haste") || ComputerUtil.hasACardGivingHaste(ai) || sa.isDash())) {
|
||||
if (card.isCreature() && !card.hasKeyword("Defender")
|
||||
&& (card.hasKeyword("Haste") || ComputerUtil.hasACardGivingHaste(ai, true) || sa.isDash())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1237,9 +1238,9 @@ public class ComputerUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasACardGivingHaste(final Player ai) {
|
||||
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
|
||||
|
||||
public static boolean hasACardGivingHaste(final Player ai, final boolean checkOpponentCards) {
|
||||
final CardCollection all = new CardCollection(ai.getCardsIn(Lists.newArrayList(ZoneType.Battlefield, ZoneType.Command)));
|
||||
|
||||
// Special for Anger
|
||||
if (!ai.getGame().isCardInPlay("Yixlid Jailer")
|
||||
&& !ai.getCardsIn(ZoneType.Graveyard, "Anger").isEmpty()
|
||||
@@ -1305,6 +1306,28 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkOpponentCards) {
|
||||
// Check if the opponents have any cards giving Haste to all creatures on the battlefield
|
||||
CardCollection opp = new CardCollection();
|
||||
opp.addAll(ai.getOpponents().getCardsIn(ZoneType.Battlefield));
|
||||
opp.addAll(ai.getOpponents().getCardsIn(ZoneType.Command));
|
||||
|
||||
for (final Card c : opp) {
|
||||
for (StaticAbility stAb : c.getStaticAbilities()) {
|
||||
Map<String, String> params = stAb.getMapParams();
|
||||
if ("Continuous".equals(params.get("Mode")) && params.containsKey("AddKeyword")
|
||||
&& params.get("AddKeyword").contains("Haste")) {
|
||||
|
||||
final ArrayList affected = Lists.newArrayList(params.get("Affected").split(","));
|
||||
if (affected.contains("Creature")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user