mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Added a little more safety code to prevent AI freezing.
This commit is contained in:
@@ -88,12 +88,8 @@ public class ComputerUtil {
|
|||||||
}
|
}
|
||||||
sa.setActivatingPlayer(AllZone.getComputerPlayer());
|
sa.setActivatingPlayer(AllZone.getComputerPlayer());
|
||||||
|
|
||||||
if (ComputerUtil.canBePlayedAndPayedByAI(sa)) {
|
if (ComputerUtil.canBePlayedAndPayedByAI(sa) && ComputerUtil.handlePlayingSpellAbility(sa)) {
|
||||||
ComputerUtil.handlePlayingSpellAbility(sa);
|
return false;
|
||||||
|
|
||||||
if (!(sa instanceof AbilityStatic)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -124,13 +120,13 @@ public class ComputerUtil {
|
|||||||
* @param sa
|
* @param sa
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static void handlePlayingSpellAbility(final SpellAbility sa) {
|
public static boolean handlePlayingSpellAbility(final SpellAbility sa) {
|
||||||
|
|
||||||
if (sa instanceof AbilityStatic) {
|
if (sa instanceof AbilityStatic) {
|
||||||
if (ComputerUtil.payManaCost(sa, AllZone.getComputerPlayer(), false, 0)) {
|
if (ComputerUtil.payManaCost(sa, AllZone.getComputerPlayer(), false, 0)) {
|
||||||
sa.resolve();
|
sa.resolve();
|
||||||
}
|
}
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AllZone.getStack().freezeStack();
|
AllZone.getStack().freezeStack();
|
||||||
@@ -148,6 +144,7 @@ public class ComputerUtil {
|
|||||||
sa.chooseTargetAI();
|
sa.chooseTargetAI();
|
||||||
sa.getBeforePayManaAI().execute();
|
sa.getBeforePayManaAI().execute();
|
||||||
AllZone.getStack().addAndUnfreeze(sa);
|
AllZone.getStack().addAndUnfreeze(sa);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if ((tgt != null) && tgt.doesTarget()) {
|
if ((tgt != null) && tgt.doesTarget()) {
|
||||||
sa.chooseTargetAI();
|
sa.chooseTargetAI();
|
||||||
@@ -156,10 +153,14 @@ public class ComputerUtil {
|
|||||||
final CostPayment pay = new CostPayment(cost, sa);
|
final CostPayment pay = new CostPayment(cost, sa);
|
||||||
if (pay.payComputerCosts()) {
|
if (pay.payComputerCosts()) {
|
||||||
AllZone.getStack().addAndUnfreeze(sa);
|
AllZone.getStack().addAndUnfreeze(sa);
|
||||||
|
return true;
|
||||||
// TODO: solve problems with TapsForMana triggers by adding
|
// TODO: solve problems with TapsForMana triggers by adding
|
||||||
// sources tapped here if possible (ArsenalNut)
|
// sources tapped here if possible (ArsenalNut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Should not arrive here
|
||||||
|
System.out.println("AI failed to play " + sa.getSourceCard());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user