InputPayManaBase will execute input queue unlock from the same thread that was used to activate mana ability. No showMessage() will be called.

This commit is contained in:
Maxmtg
2013-05-27 17:50:40 +00:00
parent 99de2d6543
commit 8ccfad27cc
6 changed files with 32 additions and 12 deletions

View File

@@ -185,7 +185,10 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
public void run() { public void run() {
HumanPlay.playSpellAbility(chosen.getActivatingPlayer(), chosen); HumanPlay.playSpellAbility(chosen.getActivatingPlayer(), chosen);
onManaAbilityPlayed(chosen); onManaAbilityPlayed(chosen);
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { showMessage(); } }); if( isAlredyPaid() ) {
done();
stopNonEdt();
}
} }
}; };
game.getInputQueue().invokeGameAction(proc); game.getInputQueue().invokeGameAction(proc);
@@ -238,11 +241,11 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
player.getZone(ZoneType.Battlefield).updateObservers(); player.getZone(ZoneType.Battlefield).updateObservers();
} }
protected final void checkIfAlredyPaid() { protected boolean isAlredyPaid() {
if (manaCost.isPaid()) { if (manaCost.isPaid()) {
bPaid = true; bPaid = true;
done();
} }
return bPaid;
} }
protected void onManaAbilityPaid() {} // some inputs overload it protected void onManaAbilityPaid() {} // some inputs overload it

View File

@@ -85,6 +85,7 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
if (this.manaCost.isPaid()) { if (this.manaCost.isPaid()) {
this.done(); this.done();
this.stop();
} else { } else {
this.showMessage(); this.showMessage();
} }
@@ -98,7 +99,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
} }
player.getManaPool().clearManaPaid(this.saPaidFor, false); player.getManaPool().clearManaPaid(this.saPaidFor, false);
bPaid = true; bPaid = true;
this.stop();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -126,7 +126,10 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)"); msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
} }
if( isAlredyPaid() ) {
done();
stop();
} else
showMessage(msg.toString()); showMessage(msg.toString());
checkIfAlredyPaid();
} }
} }

View File

@@ -40,7 +40,6 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
// any mana tapabilities can't be used in payment as well as being tapped for convoke) // any mana tapabilities can't be used in payment as well as being tapped for convoke)
handleConvokedCards(false); handleConvokedCards(false);
stop();
} }
@Override @Override
@@ -67,7 +66,10 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)"); msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
} }
if( isAlredyPaid() ) {
done();
stop();
} else
showMessage(msg.toString()); showMessage(msg.toString());
checkIfAlredyPaid();
} }
} }

View File

@@ -89,8 +89,6 @@ public class InputPayManaSimple extends InputPayManaBase {
handleConvokedCards(false); handleConvokedCards(false);
} }
stop();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -127,6 +125,7 @@ public class InputPayManaSimple extends InputPayManaBase {
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) { if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
this.originalCard.setSunburstValue(this.manaCost.getSunburst()); this.originalCard.setSunburstValue(this.manaCost.getSunburst());
this.done(); this.done();
this.stop();
} }
} }

View File

@@ -102,6 +102,7 @@ public class InputPayManaX extends InputPayManaBase {
@Override @Override
protected final void onOk() { protected final void onOk() {
done(); done();
this.stop();
} }
@Override @Override
@@ -116,6 +117,5 @@ public class InputPayManaX extends InputPayManaBase {
card.setXManaCostPaid(this.xPaid); card.setXManaCostPaid(this.xPaid);
card.setColorsPaid(this.colorsPaid); card.setColorsPaid(this.colorsPaid);
card.setSunburstValue(ColorSet.fromMask(this.colorsPaid).countColors()); card.setSunburstValue(ColorSet.fromMask(this.colorsPaid).countColors());
this.stop();
} }
} }

View File

@@ -28,6 +28,7 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
protected final void stop() { protected final void stop() {
setFinished(); setFinished();
FThreads.invokeInNewThread(new Runnable() { FThreads.invokeInNewThread(new Runnable() {
@Override @Override
@@ -39,6 +40,18 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
}); });
} }
// This version does not need to be ran from EDT.
protected final void stopNonEdt() {
FThreads.assertExecutedByEdt(false);
// ensure no clicks from EDT will be accepted
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { setFinished(); } });
// this will update input proxy, so there might be anything happening in the thread
getQueue().removeInput(InputSyncronizedBase.this);
cdlDone.countDown();
}
@Override @Override
public final void selectButtonCancel() { public final void selectButtonCancel() {
if( isFinished() ) return; if( isFinished() ) return;