- Back to the more complex yet comprehensive way of figuring out damage on attach, but keep AITgts in AttachAi, might come in handy later.

This commit is contained in:
Agetian
2018-11-15 18:48:30 +03:00
parent 68d62b9eb8
commit ea35e04ba8
3 changed files with 24 additions and 6 deletions

View File

@@ -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<String, String> 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) { if (magnetList != null) {
// Look for Heroic triggers // Look for Heroic triggers

View File

@@ -1395,8 +1395,7 @@ public class CardProperty {
return false; return false;
} }
} else if (property.startsWith("power") || property.startsWith("toughness") } else if (property.startsWith("power") || property.startsWith("toughness")
|| property.startsWith("cmc") || property.startsWith("totalPT") || property.startsWith("cmc") || property.startsWith("totalPT")) {
|| property.startsWith("effectiveToughness")) {
int x; int x;
int y = 0; int y = 0;
String rhs = ""; String rhs = "";
@@ -1407,9 +1406,6 @@ public class CardProperty {
} else if (property.startsWith("toughness")) { } else if (property.startsWith("toughness")) {
rhs = property.substring(11); rhs = property.substring(11);
y = card.getNetToughness(); y = card.getNetToughness();
} else if (property.startsWith("effectiveToughness")) {
rhs = property.substring(20);
y = card.getNetToughness() - card.getDamage();
} else if (property.startsWith("cmc")) { } else if (property.startsWith("cmc")) {
rhs = property.substring(5); rhs = property.substring(5);
y = card.getCMC(); y = card.getCMC();

View File

@@ -2,7 +2,7 @@ Name:Tilonalli's Crown
ManaCost:1 R ManaCost:1 R
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature 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. 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 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. S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddPower$ 3 | AddKeyword$ Trample | Description$ Enchanted creature gets +3/+0 and has trample.