From ef7ff4dd66c5d3010b3eb324266e57fb494cc6d4 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Tue, 27 Jul 2021 22:57:21 +0200 Subject: [PATCH] Fix DamageDealAi math for untargeted players --- .../java/forge/ai/ability/CountersPutAi.java | 5 ++--- .../java/forge/ai/ability/DamageDealAi.java | 18 ++++++++++-------- .../java/forge/ai/ability/RepeatEachAi.java | 2 +- .../src/main/java/forge/ImageCache.java | 2 -- forge-gui/res/cardsfolder/a/aether_vial.txt | 2 +- forge-gui/res/cardsfolder/c/crackling_doom.txt | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index a7639d5b81e..cbedc0356ed 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -324,7 +324,7 @@ public class CountersPutAi extends SpellAbilityAi { return false; } - if (sourceName.equals("Feat of Resistance")) { // sub-ability should take precedence + if (sourceName.equals("Feat of Resistance")) { // sub-ability should take precedence CardCollection prot = ProtectAi.getProtectCreatures(ai, sa.getSubAbility()); if (!prot.isEmpty()) { sa.getTargets().add(prot.get(0)); @@ -707,8 +707,7 @@ public class CountersPutAi extends SpellAbilityAi { } if (choice == null) { // can't find anything left - if ((!sa.isTargetNumberValid()) - || (sa.getTargets().size() == 0)) { + if ((!sa.isTargetNumberValid()) || (sa.getTargets().size() == 0)) { sa.resetTargets(); return false; } else { diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index fc08cab9ceb..20782b9f154 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -806,14 +806,16 @@ public class DamageDealAi extends DamageAiBase { } else if (o instanceof Player) { final Player p = (Player) o; final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getHostCard(), false); - if (!p.isOpponentOf(ai) && p.canLoseLife() && restDamage + 3 >= p.getLife() && restDamage > 0) { - // from this spell will kill me - return false; - } - if (p.isOpponentOf(ai) && p.canLoseLife()) { - positive = true; - if (p.getLife() + 3 <= restDamage) { - urgent = true; + if (restDamage > 0 && p.canLoseLife()) { + if (!p.isOpponentOf(ai) && restDamage + 3 >= p.getLife()) { + // from this spell will kill me + return false; + } + if (p.isOpponentOf(ai)) { + positive = true; + if (p.getLife() - 3 <= restDamage) { + urgent = true; + } } } } diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java index afcd0879fbd..1cb7766e11f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java @@ -50,7 +50,7 @@ public class RepeatEachAi extends SpellAbilityAi { return false; } } - } else if ("OpponentHasCreatures".equals(logic)) { + } else if ("OpponentHasCreatures".equals(logic)) { //TODO convert this to NeedsToPlayVar for (Player opp : aiPlayer.getOpponents()) { if (!opp.getCreaturesInPlay().isEmpty()){ return true; diff --git a/forge-gui-desktop/src/main/java/forge/ImageCache.java b/forge-gui-desktop/src/main/java/forge/ImageCache.java index 3530e7ce09d..581b3578b12 100644 --- a/forge-gui-desktop/src/main/java/forge/ImageCache.java +++ b/forge-gui-desktop/src/main/java/forge/ImageCache.java @@ -235,7 +235,6 @@ public class ImageCache { final BufferedImage cached = _CACHE.getIfPresent(resizedKey); if (null != cached) { - //System.out.println("found cached image: " + resizedKey); return cached; } @@ -275,7 +274,6 @@ public class ImageCache { result = resampler.filter(original, null); } - //System.out.println("caching image: " + resizedKey); _CACHE.put(resizedKey, result); return result; } diff --git a/forge-gui/res/cardsfolder/a/aether_vial.txt b/forge-gui/res/cardsfolder/a/aether_vial.txt index 035444dd74d..7e534daf627 100644 --- a/forge-gui/res/cardsfolder/a/aether_vial.txt +++ b/forge-gui/res/cardsfolder/a/aether_vial.txt @@ -3,7 +3,7 @@ ManaCost:1 Types:Artifact A:AB$ ChangeZone | Cost$ T | Origin$ Hand | Destination$ Battlefield | ChangeType$ Creature.cmcEQX+YouCtrl | ChangeNum$ 1 | Optional$ You | SpellDescription$ You may put a creature card with mana value equal to the number of charge counters on CARDNAME from your hand onto the battlefield. | StackDescription$ SpellDescription T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigPutCounter | TriggerDescription$ At the beginning of your upkeep, you may put a charge counter on CARDNAME. -SVar:TrigPutCounter:DB$PutCounter | Defined$ Self | CounterType$ CHARGE | CounterNum$ 1 +SVar:TrigPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ CHARGE | CounterNum$ 1 SVar:X:Count$CardCounters.CHARGE SVar:Picture:http://www.wizards.com/global/images/magic/general/aether_vial.jpg Oracle:At the beginning of your upkeep, you may put a charge counter on Aether Vial.\n{T}: You may put a creature card with mana value equal to the number of charge counters on Aether Vial from your hand onto the battlefield. diff --git a/forge-gui/res/cardsfolder/c/crackling_doom.txt b/forge-gui/res/cardsfolder/c/crackling_doom.txt index 0fd733efdcd..a67d51f64be 100644 --- a/forge-gui/res/cardsfolder/c/crackling_doom.txt +++ b/forge-gui/res/cardsfolder/c/crackling_doom.txt @@ -1,7 +1,7 @@ Name:Crackling Doom ManaCost:R W B Types:Instant -A:SP$ DealDamage | Cost$ R B W | Defined$ Player.Opponent | NumDmg$ 2 | AILogic$ OpponentHasCreatures | SubAbility$ DBRepeat | SpellDescription$ CARDNAME deals 2 damage to each opponent. Each opponent sacrifices a creature with the greatest power among creatures that player controls. +A:SP$ DealDamage | Cost$ R B W | Defined$ Player.Opponent | NumDmg$ 2 | SubAbility$ DBRepeat | SpellDescription$ CARDNAME deals 2 damage to each opponent. Each opponent sacrifices a creature with the greatest power among creatures that player controls. SVar:DBRepeat:DB$ RepeatEach | RepeatPlayers$ Player.Opponent | RepeatSubAbility$ DBChooseCard | SubAbility$ DBSac SVar:DBChooseCard:DB$ ChooseCard | Defined$ Player.IsRemembered | Choices$ Creature.greatestPowerControlledByRemembered | ChoiceTitle$ Choose a creature you control with the greatest power | Mandatory$ True | RememberChosen$ True SVar:DBSac:DB$ SacrificeAll | ValidCards$ Card.IsRemembered | SubAbility$ DBCleanup | StackDescription$ Each opponent sacrifices a creature with the greatest power among creatures they control.