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

@@ -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 {

View File

@@ -806,18 +806,20 @@ 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) {
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) && p.canLoseLife()) {
if (p.isOpponentOf(ai)) {
positive = true;
if (p.getLife() + 3 <= restDamage) {
if (p.getLife() - 3 <= restDamage) {
urgent = true;
}
}
}
}
}
if (!positive && !(saMe instanceof AbilitySub)) {
return false;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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.