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() {
|
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
|
||||||
|
|||||||
@@ -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.)");
|
||||||
}
|
}
|
||||||
|
|
||||||
showMessage(msg.toString());
|
if( isAlredyPaid() ) {
|
||||||
checkIfAlredyPaid();
|
done();
|
||||||
|
stop();
|
||||||
|
} else
|
||||||
|
showMessage(msg.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.)");
|
||||||
}
|
}
|
||||||
|
|
||||||
showMessage(msg.toString());
|
if( isAlredyPaid() ) {
|
||||||
checkIfAlredyPaid();
|
done();
|
||||||
|
stop();
|
||||||
|
} else
|
||||||
|
showMessage(msg.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -38,6 +39,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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user