Fix so Auto payment occurs in Game thread

This commit is contained in:
drdev
2013-12-12 11:49:50 +00:00
parent 1c391a7c7e
commit 849655cb2f
2 changed files with 38 additions and 11 deletions

View File

@@ -25,6 +25,7 @@ import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.SpellAbility;
import forge.gui.GuiChoose;
import forge.util.Evaluator;
import forge.util.ThreadUtil;
import forge.view.ButtonUtil;
/**
@@ -288,13 +289,19 @@ public abstract class InputPayMana extends InputSyncronizedBase {
protected void onOk() {
if (supportAutoPay()) {
//use AI utility to automatically pay mana cost if possible
Runnable proc = new Runnable() {
final Runnable proc = new Runnable() {
@Override
public void run() {
ComputerUtilMana.payManaCost(manaCost, saPaidFor, player);
}
};
runAsAi(proc);
//must run in game thread as certain payment actions can only be automated there
ThreadUtil.invokeInGameThreadAndWait(new Runnable() {
@Override
public void run() {
runAsAi(proc);
}
});
this.showMessage();
}
}