mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge branch 'ai-haste-detection' into 'master'
Improve the AI Haste detection from Command zone and opponent's Battlefield See merge request core-developers/forge!410
This commit is contained in:
@@ -951,7 +951,8 @@ public class ComputerUtil {
|
|||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1237,8 +1238,8 @@ public class ComputerUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasACardGivingHaste(final Player ai) {
|
public static boolean hasACardGivingHaste(final Player ai, final boolean checkOpponentCards) {
|
||||||
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
|
final CardCollection all = new CardCollection(ai.getCardsIn(Lists.newArrayList(ZoneType.Battlefield, ZoneType.Command)));
|
||||||
|
|
||||||
// Special for Anger
|
// Special for Anger
|
||||||
if (!ai.getGame().isCardInPlay("Yixlid Jailer")
|
if (!ai.getGame().isCardInPlay("Yixlid Jailer")
|
||||||
@@ -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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user