Merge branch 'aifix' into 'master'

Fix DamageDealAi math for untargeted players

See merge request core-developers/forge!5125
This commit is contained in:
Michael Kamensky
2021-07-28 07:18:10 +00:00
7 changed files with 21 additions and 17 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

@@ -162,6 +162,12 @@ public class DamageDealAi extends DamageAiBase {
String logic = sa.getParamOrDefault("AILogic", ""); String logic = sa.getParamOrDefault("AILogic", "");
if ("DiscardLands".equals(logic)) { if ("DiscardLands".equals(logic)) {
dmg = 2; dmg = 2;
} else if ("OpponentHasCreatures".equals(logic)) {
for (Player opp : ai.getOpponents()) {
if (!opp.getCreaturesInPlay().isEmpty()){
return true;
}
}
} else if (logic.startsWith("ProcRaid.")) { } else if (logic.startsWith("ProcRaid.")) {
if (ai.getGame().getPhaseHandler().isPlayerTurn(ai) && ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) { if (ai.getGame().getPhaseHandler().isPlayerTurn(ai) && ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
for (Card potentialAtkr : ai.getCreaturesInPlay()) { for (Card potentialAtkr : ai.getCreaturesInPlay()) {
@@ -806,14 +812,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

@@ -47,7 +47,6 @@ public class DamageEachAi extends DamageAiBase {
*/ */
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
return mandatory || canPlayAI(ai, sa); return mandatory || canPlayAI(ai, sa);
} }

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 | AILogic$ OpponentHasCreatures | 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.