From ea35e04ba87daf429a1b437f525c96ec3634039c Mon Sep 17 00:00:00 2001 From: Agetian Date: Thu, 15 Nov 2018 18:48:30 +0300 Subject: [PATCH] - Back to the more complex yet comprehensive way of figuring out damage on attach, but keep AITgts in AttachAi, might come in handy later. --- .../main/java/forge/ai/ability/AttachAi.java | 22 +++++++++++++++++++ .../java/forge/game/card/CardProperty.java | 6 +---- .../res/cardsfolder/t/tilonallis_crown.txt | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index d248a4ca60d..64de7d65a3d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -905,6 +905,28 @@ public class AttachAi extends SpellAbilityAi { }); } + // Look for triggers that will damage the creature and remove AI-owned creatures that will die + CardCollection toRemove = new CardCollection(); + for (Trigger t : attachSource.getTriggers()) { + if (t.getMode() == TriggerType.ChangesZone) { + final Map params = t.getMapParams(); + if ("Card.Self".equals(params.get("ValidCard")) && "Battlefield".equals(params.get("Destination")) && t.hasParam("Execute")) { + SpellAbility trigSa = AbilityFactory.getAbility(attachSource.getSVar(params.get("Execute")), attachSource); + if (trigSa.getApi() == ApiType.DealDamage && "Enchanted".equals(trigSa.getParam("Defined"))) { + for (Card target : list) { + if (!target.getController().isOpponentOf(ai)) { + int numDmg = AbilityUtils.calculateAmount(target, trigSa.getParam("NumDmg"), trigSa); + if (target.getNetToughness() - target.getDamage() <= numDmg && !target.hasKeyword(Keyword.INDESTRUCTIBLE)) { + toRemove.add(target); + } + } + } + } + } + } + } + list.removeAll(toRemove); + if (magnetList != null) { // Look for Heroic triggers diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index d0575e1e793..d2be541192c 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -1395,8 +1395,7 @@ public class CardProperty { return false; } } else if (property.startsWith("power") || property.startsWith("toughness") - || property.startsWith("cmc") || property.startsWith("totalPT") - || property.startsWith("effectiveToughness")) { + || property.startsWith("cmc") || property.startsWith("totalPT")) { int x; int y = 0; String rhs = ""; @@ -1407,9 +1406,6 @@ public class CardProperty { } else if (property.startsWith("toughness")) { rhs = property.substring(11); y = card.getNetToughness(); - } else if (property.startsWith("effectiveToughness")) { - rhs = property.substring(20); - y = card.getNetToughness() - card.getDamage(); } else if (property.startsWith("cmc")) { rhs = property.substring(5); y = card.getCMC(); diff --git a/forge-gui/res/cardsfolder/t/tilonallis_crown.txt b/forge-gui/res/cardsfolder/t/tilonallis_crown.txt index 6a30dbc3e03..5e5c6c76579 100644 --- a/forge-gui/res/cardsfolder/t/tilonallis_crown.txt +++ b/forge-gui/res/cardsfolder/t/tilonallis_crown.txt @@ -2,7 +2,7 @@ Name:Tilonalli's Crown ManaCost:1 R Types:Enchantment Aura K:Enchant creature -A:SP$ Attach | Cost$ 1 R | ValidTgts$ Creature | AILogic$ Pump | AITgts$ Creature.YouCtrl+effectiveToughnessGT1 +A:SP$ Attach | Cost$ 1 R | ValidTgts$ Creature | AILogic$ Pump T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigDealDamage | TriggerDescription$ When CARDNAME enters the battlefield, it deals 1 damage to enchanted creature. SVar:TrigDealDamage:DB$ DealDamage | Defined$ Enchanted | NumDmg$ 1 S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddPower$ 3 | AddKeyword$ Trample | Description$ Enchanted creature gets +3/+0 and has trample.