Fix DamageDealAi math for untargeted players

This commit is contained in:
tool4EvEr
2021-07-27 22:57:21 +02:00
parent 3f30f45972
commit ef7ff4dd66
6 changed files with 15 additions and 16 deletions

View File

@@ -324,7 +324,7 @@ public class CountersPutAi extends SpellAbilityAi {
return false; 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()); CardCollection prot = ProtectAi.getProtectCreatures(ai, sa.getSubAbility());
if (!prot.isEmpty()) { if (!prot.isEmpty()) {
sa.getTargets().add(prot.get(0)); sa.getTargets().add(prot.get(0));
@@ -707,8 +707,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((!sa.isTargetNumberValid()) if ((!sa.isTargetNumberValid()) || (sa.getTargets().size() == 0)) {
|| (sa.getTargets().size() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} else { } else {

View File

@@ -806,14 +806,16 @@ public class DamageDealAi extends DamageAiBase {
} else if (o instanceof Player) { } else if (o instanceof Player) {
final Player p = (Player) o; final Player p = (Player) o;
final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getHostCard(), false); final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getHostCard(), false);
if (!p.isOpponentOf(ai) && p.canLoseLife() && restDamage + 3 >= p.getLife() && restDamage > 0) { if (restDamage > 0 && p.canLoseLife()) {
// from this spell will kill me if (!p.isOpponentOf(ai) && restDamage + 3 >= p.getLife()) {
return false; // from this spell will kill me
} return false;
if (p.isOpponentOf(ai) && p.canLoseLife()) { }
positive = true; if (p.isOpponentOf(ai)) {
if (p.getLife() + 3 <= restDamage) { positive = true;
urgent = true; if (p.getLife() - 3 <= restDamage) {
urgent = true;
}
} }
} }
} }

View File

@@ -50,7 +50,7 @@ public class RepeatEachAi extends SpellAbilityAi {
return false; return false;
} }
} }
} else if ("OpponentHasCreatures".equals(logic)) { } else if ("OpponentHasCreatures".equals(logic)) { //TODO convert this to NeedsToPlayVar
for (Player opp : aiPlayer.getOpponents()) { for (Player opp : aiPlayer.getOpponents()) {
if (!opp.getCreaturesInPlay().isEmpty()){ if (!opp.getCreaturesInPlay().isEmpty()){
return true; return true;

View File

@@ -235,7 +235,6 @@ public class ImageCache {
final BufferedImage cached = _CACHE.getIfPresent(resizedKey); final BufferedImage cached = _CACHE.getIfPresent(resizedKey);
if (null != cached) { if (null != cached) {
//System.out.println("found cached image: " + resizedKey);
return cached; return cached;
} }
@@ -275,7 +274,6 @@ public class ImageCache {
result = resampler.filter(original, null); result = resampler.filter(original, null);
} }
//System.out.println("caching image: " + resizedKey);
_CACHE.put(resizedKey, result); _CACHE.put(resizedKey, result);
return result; return result;
} }

View File

@@ -3,7 +3,7 @@ ManaCost:1
Types:Artifact 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 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. 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:X:Count$CardCounters.CHARGE
SVar:Picture:http://www.wizards.com/global/images/magic/general/aether_vial.jpg 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. 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.

View File

@@ -1,7 +1,7 @@
Name:Crackling Doom Name:Crackling Doom
ManaCost:R W B ManaCost:R W B
Types:Instant 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: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: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. SVar:DBSac:DB$ SacrificeAll | ValidCards$ Card.IsRemembered | SubAbility$ DBCleanup | StackDescription$ Each opponent sacrifices a creature with the greatest power among creatures they control.