- Fixed AI not always playing Shivan Meteor from suspend.

This commit is contained in:
Sloth
2015-07-18 11:47:03 +00:00
parent 2c487a89a2
commit 4213b537ab
3 changed files with 16 additions and 18 deletions

View File

@@ -110,10 +110,6 @@ public abstract class SpellAbilityAi {
return false; return false;
} }
if (sa.isTrigger()) {
return true;
}
if (ComputerUtil.playImmediately(ai, sa)) { if (ComputerUtil.playImmediately(ai, sa)) {
return true; return true;
} }

View File

@@ -37,7 +37,7 @@ public class DamageDealAi extends DamageAiBase {
dmg = ComputerUtilMana.determineLeftoverMana(sa, ai); dmg = ComputerUtilMana.determineLeftoverMana(sa, ai);
source.setSVar("PayX", Integer.toString(dmg)); source.setSVar("PayX", Integer.toString(dmg));
} }
if (!this.damageTargetAI(ai, sa, dmg)) { if (!this.damageTargetAI(ai, sa, dmg, true)) {
return false; return false;
} }
return true; return true;
@@ -96,7 +96,7 @@ public class DamageDealAi extends DamageAiBase {
return false; return false;
} }
if (!this.damageTargetAI(ai, sa, dmg)) { if (!this.damageTargetAI(ai, sa, dmg, false)) {
return false; return false;
} }
@@ -211,7 +211,7 @@ public class DamageDealAi extends DamageAiBase {
* a int. * a int.
* @return a boolean. * @return a boolean.
*/ */
private boolean damageTargetAI(final Player ai, final SpellAbility saMe, final int dmg) { private boolean damageTargetAI(final Player ai, final SpellAbility saMe, final int dmg, final boolean immediately) {
final TargetRestrictions tgt = saMe.getTargetRestrictions(); final TargetRestrictions tgt = saMe.getTargetRestrictions();
if (tgt == null) { if (tgt == null) {
@@ -222,7 +222,7 @@ public class DamageDealAi extends DamageAiBase {
return false; return false;
} }
return this.damageChoosingTargets(ai, saMe, tgt, dmg, false, false); return this.damageChoosingTargets(ai, saMe, tgt, dmg, false, immediately);
} }
/** /**
@@ -241,7 +241,7 @@ public class DamageDealAi extends DamageAiBase {
* @return a boolean. * @return a boolean.
*/ */
private boolean damageChoosingTargets(final Player ai, final SpellAbility sa, final TargetRestrictions tgt, int dmg, private boolean damageChoosingTargets(final Player ai, final SpellAbility sa, final TargetRestrictions tgt, int dmg,
final boolean isTrigger, final boolean mandatory) { final boolean mandatory, boolean immediately) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final boolean noPrevention = sa.hasParam("NoPrevention"); final boolean noPrevention = sa.hasParam("NoPrevention");
final Game game = source.getGame(); final Game game = source.getGame();
@@ -268,6 +268,8 @@ public class DamageDealAi extends DamageAiBase {
return false; return false;
} }
immediately |= ComputerUtil.playImmediately(ai, sa);
if ("ChoiceBurn".equals(sa.getParam("AILogic"))) { if ("ChoiceBurn".equals(sa.getParam("AILogic"))) {
// do not waste burns on player if other choices are present // do not waste burns on player if other choices are present
if (this.shouldTgtP(ai, sa, dmg, noPrevention)) { if (this.shouldTgtP(ai, sa, dmg, noPrevention)) {
@@ -341,7 +343,7 @@ public class DamageDealAi extends DamageAiBase {
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, false); final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, false);
if (c != null) { if (c != null) {
//option to hold removal instead only applies for single targeted removal //option to hold removal instead only applies for single targeted removal
if (sa.isSpell() && tgt.getMaxTargets(sa.getHostCard(), sa) == 1 && !divided && !isTrigger) { if (sa.isSpell() && !divided && !immediately && tgt.getMaxTargets(sa.getHostCard(), sa) == 1) {
if (!ComputerUtilCard.useRemovalNow(sa, c, dmg, ZoneType.Graveyard)) { if (!ComputerUtilCard.useRemovalNow(sa, c, dmg, ZoneType.Graveyard)) {
return false; return false;
} }
@@ -368,9 +370,8 @@ public class DamageDealAi extends DamageAiBase {
// on the stack // on the stack
// or from taking combat damage // or from taking combat damage
boolean freePing = isTrigger || sa.getPayCosts() == null boolean freePing = immediately || sa.getPayCosts() == null
|| sa.getTargets().getNumTargeted() > 0 || sa.getTargets().getNumTargeted() > 0;
|| ComputerUtil.playImmediately(ai, sa);
if (!source.isSpell()) { if (!source.isSpell()) {
if (phase.is(PhaseType.END_OF_TURN) && sa.isAbility()) { if (phase.is(PhaseType.END_OF_TURN) && sa.isAbility()) {
@@ -397,7 +398,7 @@ public class DamageDealAi extends DamageAiBase {
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, mandatory); final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, mandatory);
if (c != null) { if (c != null) {
//option to hold removal instead only applies for single targeted removal //option to hold removal instead only applies for single targeted removal
if (!sa.isTrigger() && tgt.getMaxTargets(sa.getHostCard(), sa) == 1 && !divided) { if (!immediately && tgt.getMaxTargets(sa.getHostCard(), sa) == 1 && !divided) {
if (!ComputerUtilCard.useRemovalNow(sa, c, dmg, ZoneType.Graveyard)) { if (!ComputerUtilCard.useRemovalNow(sa, c, dmg, ZoneType.Graveyard)) {
return false; return false;
} }
@@ -429,7 +430,7 @@ public class DamageDealAi extends DamageAiBase {
else if (sa.canTarget(enemy)) { else if (sa.canTarget(enemy)) {
if ((phase.is(PhaseType.END_OF_TURN) && phase.getNextTurn().equals(ai)) if ((phase.is(PhaseType.END_OF_TURN) && phase.getNextTurn().equals(ai))
|| (SpellAbilityAi.isSorcerySpeed(sa) && phase.is(PhaseType.MAIN2)) || (SpellAbilityAi.isSorcerySpeed(sa) && phase.is(PhaseType.MAIN2))
|| sa.getPayCosts() == null || isTrigger || sa.getPayCosts() == null || immediately
|| this.shouldTgtP(ai, sa, dmg, noPrevention)) { || this.shouldTgtP(ai, sa, dmg, noPrevention)) {
sa.getTargets().add(enemy); sa.getTargets().add(enemy);
if (divided) { if (divided) {
@@ -589,7 +590,7 @@ public class DamageDealAi extends DamageAiBase {
return false; return false;
} }
} else { } else {
if (!this.damageChoosingTargets(ai, sa, tgt, dmg, true, mandatory) && !mandatory) { if (!this.damageChoosingTargets(ai, sa, tgt, dmg, mandatory, true) && !mandatory) {
return false; return false;
} }

View File

@@ -14,9 +14,10 @@ public class ManaEffectAi extends SpellAbilityAi {
if (ai.getGame().getPhaseHandler().is(PhaseType.MAIN2) && ComputerUtil.activateForCost(sa, ai)) { if (ai.getGame().getPhaseHandler().is(PhaseType.MAIN2) && ComputerUtil.activateForCost(sa, ai)) {
return true; return true;
} }
if (ComputerUtil.playImmediately(ai, sa) && sa.getPayCosts() != null && sa.getPayCosts().hasNoManaCost() if (sa.getPayCosts() != null && sa.getPayCosts().hasNoManaCost()
&& sa.getPayCosts().isReusuableResource() && sa.getPayCosts().isReusuableResource()
&& sa.getSubAbility() == null) { && sa.getSubAbility() == null
&& ComputerUtil.playImmediately(ai, sa)) {
return true; return true;
} }
return false; return false;