InputPayMana now executes only updateMessage in EDT when it's not paid

This commit is contained in:
Maxmtg
2013-05-27 18:22:25 +00:00
parent 9cdd447729
commit f6ee680937
5 changed files with 48 additions and 31 deletions

View File

@@ -20,6 +20,7 @@ import forge.game.player.HumanPlay;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
import forge.view.ButtonUtil;
/**
* TODO: Write javadoc for this type.
@@ -188,7 +189,8 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
if( isAlredyPaid() ) {
done();
stopNonEdt();
}
} else
FThreads.invokeInEdtLater(new Runnable() { @Override public void run(){ updateMessage(); }});
}
};
game.getInputQueue().invokeGameAction(proc);
@@ -248,8 +250,23 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
return bPaid;
}
/** {@inheritDoc} */
@Override
public void showMessage() {
if ( isFinished() ) return;
ButtonUtil.enableOnlyCancel();
if( isAlredyPaid() ) {
done();
stop();
} else
updateMessage();
}
protected void onManaAbilityPaid() {} // some inputs overload it
protected abstract void done();
protected abstract void updateMessage();
@Override
public String toString() {

View File

@@ -22,7 +22,6 @@ import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostBeingPaid;
import forge.card.spellability.SpellAbility;
import forge.game.player.Player;
import forge.view.ButtonUtil;
//if cost is paid, Command.execute() is called
@@ -109,12 +108,11 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
this.stop();
}
/** {@inheritDoc} */
/* (non-Javadoc)
* @see forge.control.input.InputPayManaBase#updateMessage()
*/
@Override
public final void showMessage() {
if ( isFinished() ) return;
ButtonUtil.enableOnlyCancel();
protected void updateMessage() {
final StringBuilder msg = new StringBuilder(this.message + "Pay Mana Cost: " + this.manaCost);
if (this.phyLifeToLose > 0) {
msg.append(" (");
@@ -125,11 +123,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
if (this.manaCost.containsPhyrexianMana()) {
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());
}
}

View File

@@ -4,7 +4,6 @@ import forge.Card;
import forge.card.mana.ManaCostBeingPaid;
import forge.card.spellability.SpellAbility;
import forge.game.player.Player;
import forge.view.ButtonUtil;
public class InputPayManaOfCostPayment extends InputPayManaBase {
@@ -48,11 +47,7 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
stop();
}
@Override
public void showMessage() {
if ( isFinished() ) return; //
ButtonUtil.enableOnlyCancel();
protected void updateMessage() {
final String displayMana = manaCost.toString().replace("X", "").trim();
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + displayMana);
@@ -65,11 +60,7 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
if (manaCost.containsPhyrexianMana()) {
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());
}
}

View File

@@ -77,6 +77,9 @@ public class InputPayManaSimple extends InputPayManaBase {
*/
@Override
protected void done() {
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
if (this.phyLifeToLose > 0) {
player.payLife(this.phyLifeToLose, this.originalCard);
}
@@ -109,6 +112,20 @@ public class InputPayManaSimple extends InputPayManaBase {
ButtonUtil.enableOnlyCancel();
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
this.done();
this.stop();
} else
updateMessage();
}
/* (non-Javadoc)
* @see forge.control.input.InputPayManaBase#updateMessage()
*/
@Override
protected void updateMessage() {
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + this.manaCost.toString());
if (this.phyLifeToLose > 0) {
msg.append(" (");
@@ -122,11 +139,6 @@ public class InputPayManaSimple extends InputPayManaBase {
// has its own variant of checkIfPaid
showMessage(msg.toString());
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
this.done();
this.stop();
}
}
}

View File

@@ -65,7 +65,11 @@ public class InputPayManaX extends InputPayManaBase {
} else {
ButtonUtil.enableAllFocusOk();
}
updateMessage();
}
@Override
protected void updateMessage() {
StringBuilder msg = new StringBuilder("Pay X Mana Cost for ");
msg.append(saPaidFor.getSourceCard().getName()).append("\n").append(this.xPaid);
msg.append(" Paid so far.");