mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Improved AI predicting some ETB triggers.
This commit is contained in:
@@ -670,8 +670,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean isPreferredTarget(final AIPlayer ai, final SpellAbility sa,
|
private static boolean isPreferredTarget(final AIPlayer ai, final SpellAbility sa, final boolean mandatory) {
|
||||||
final boolean mandatory) {
|
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
|
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
|
||||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||||
@@ -833,7 +832,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mandatory && (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa))) {
|
if (!mandatory && list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -843,8 +842,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
Card choice = null;
|
Card choice = null;
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
final Card mostExpensive = ComputerUtilCard.getMostExpensivePermanentAI(list, sa, false);
|
|
||||||
if (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield)) {
|
if (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield)) {
|
||||||
|
final Card mostExpensive = ComputerUtilCard.getMostExpensivePermanentAI(list, sa, false);
|
||||||
if (mostExpensive.isCreature()) {
|
if (mostExpensive.isCreature()) {
|
||||||
// if a creature is most expensive take the best one
|
// if a creature is most expensive take the best one
|
||||||
if (destination.equals(ZoneType.Exile)) {
|
if (destination.equals(ZoneType.Exile)) {
|
||||||
@@ -887,13 +886,13 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (choice == null) { // can't find anything left
|
if (choice == null) { // can't find anything left
|
||||||
if ((tgt.getNumTargeted() == 0) || (tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))) {
|
if (tgt.getNumTargeted() == 0 || tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||||
if (!mandatory) {
|
if (!mandatory) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!ComputerUtil.shouldCastLessThanMax(ai, source)) {
|
if (!sa.isTrigger() && !ComputerUtil.shouldCastLessThanMax(ai, source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ public class SpellPermanent extends Spell {
|
|||||||
else {
|
else {
|
||||||
throw new InvalidParameterException("Either ai or sa must be not null!");
|
throw new InvalidParameterException("Either ai or sa must be not null!");
|
||||||
}
|
}
|
||||||
|
exSA.setTrigger(true);
|
||||||
|
|
||||||
// Run non-mandatory trigger.
|
// Run non-mandatory trigger.
|
||||||
// These checks only work if the Executing SpellAbility is an
|
// These checks only work if the Executing SpellAbility is an
|
||||||
|
|||||||
Reference in New Issue
Block a user