mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
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:
@@ -185,7 +185,10 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
||||
public void run() {
|
||||
HumanPlay.playSpellAbility(chosen.getActivatingPlayer(), chosen);
|
||||
onManaAbilityPlayed(chosen);
|
||||
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { showMessage(); } });
|
||||
if( isAlredyPaid() ) {
|
||||
done();
|
||||
stopNonEdt();
|
||||
}
|
||||
}
|
||||
};
|
||||
game.getInputQueue().invokeGameAction(proc);
|
||||
@@ -238,11 +241,11 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
||||
player.getZone(ZoneType.Battlefield).updateObservers();
|
||||
}
|
||||
|
||||
protected final void checkIfAlredyPaid() {
|
||||
protected boolean isAlredyPaid() {
|
||||
if (manaCost.isPaid()) {
|
||||
bPaid = true;
|
||||
done();
|
||||
}
|
||||
return bPaid;
|
||||
}
|
||||
|
||||
protected void onManaAbilityPaid() {} // some inputs overload it
|
||||
|
||||
@@ -85,6 +85,7 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
|
||||
|
||||
if (this.manaCost.isPaid()) {
|
||||
this.done();
|
||||
this.stop();
|
||||
} else {
|
||||
this.showMessage();
|
||||
}
|
||||
@@ -98,7 +99,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
|
||||
}
|
||||
player.getManaPool().clearManaPaid(this.saPaidFor, false);
|
||||
bPaid = true;
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -126,7 +126,10 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
|
||||
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
||||
}
|
||||
|
||||
if( isAlredyPaid() ) {
|
||||
done();
|
||||
stop();
|
||||
} else
|
||||
showMessage(msg.toString());
|
||||
checkIfAlredyPaid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
handleConvokedCards(false);
|
||||
stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +66,10 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
|
||||
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
||||
}
|
||||
|
||||
if( isAlredyPaid() ) {
|
||||
done();
|
||||
stop();
|
||||
} else
|
||||
showMessage(msg.toString());
|
||||
checkIfAlredyPaid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,6 @@ public class InputPayManaSimple extends InputPayManaBase {
|
||||
|
||||
handleConvokedCards(false);
|
||||
}
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -127,6 +125,7 @@ public class InputPayManaSimple extends InputPayManaBase {
|
||||
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
|
||||
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
|
||||
this.done();
|
||||
this.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
@Override
|
||||
protected final void onOk() {
|
||||
done();
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,6 +117,5 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
card.setXManaCostPaid(this.xPaid);
|
||||
card.setColorsPaid(this.colorsPaid);
|
||||
card.setSunburstValue(ColorSet.fromMask(this.colorsPaid).countColors());
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
|
||||
|
||||
protected final void stop() {
|
||||
|
||||
setFinished();
|
||||
FThreads.invokeInNewThread(new Runnable() {
|
||||
@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
|
||||
public final void selectButtonCancel() {
|
||||
if( isFinished() ) return;
|
||||
|
||||
Reference in New Issue
Block a user