mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
- AI precaution against attacking into Sarkhan the Masterless
This commit is contained in:
@@ -191,6 +191,27 @@ public class AiAttackController {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the attacker will die to a triggered ability (e.g. Sarkhan the Masterless)
|
||||
for (Card c : ai.getOpponents().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (Trigger t : c.getTriggers()) {
|
||||
if (t.getMode() == TriggerType.Attacks) {
|
||||
SpellAbility sa = t.getOverridingAbility();
|
||||
if (sa == null && t.hasParam("Execute")) {
|
||||
sa = AbilityFactory.getAbility(c, t.getParam("Execute"));
|
||||
}
|
||||
|
||||
if (sa != null && sa.getApi() == ApiType.EachDamage && "TriggeredAttacker".equals(sa.getParam("DefinedPlayers"))) {
|
||||
List<Card> valid = CardLists.getValidCards(c.getController().getCreaturesInPlay(), sa.getParam("ValidCards"), c.getController(), c, sa);
|
||||
// TODO: this assumes that 1 damage is dealt per creature. Improve this to check the parameter/X to determine
|
||||
// how much damage is dealt by each of the creatures in the valid list.
|
||||
if (attacker.getNetToughness() <= valid.size() * this.attackers.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("TRUE".equals(attacker.getSVar("HasAttackEffect"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user