mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
- moved handleConvokedCards and handleOfferings out of main inputs (no longer changes game state from EDT thread)
This commit is contained in:
@@ -136,8 +136,9 @@ public class CostPartMana extends CostPart {
|
||||
if (!toPay.isPaid()) {
|
||||
inpPayment = new InputPayManaOfCostPayment(toPay, ability);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inpPayment);
|
||||
if(!inpPayment.isPaid())
|
||||
return false;
|
||||
if (!inpPayment.isPaid()) {
|
||||
return handleOfferingAndConvoke(ability, true, false);
|
||||
}
|
||||
|
||||
source.setColorsPaid(toPay.getColorsPaid());
|
||||
source.setSunburstValue(toPay.getSunburst());
|
||||
@@ -156,7 +157,7 @@ public class CostPartMana extends CostPart {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle convoke and offerings if InputPayManaOfCostPayment was skipped because cost was reduced to 0
|
||||
// Handle convoke and offerings
|
||||
if (ability.isOffering() && ability.getSacrificedAsOffering() != null) {
|
||||
System.out.println("Finishing up Offering");
|
||||
final Card offering = ability.getSacrificedAsOffering();
|
||||
@@ -171,7 +172,7 @@ public class CostPartMana extends CostPart {
|
||||
}
|
||||
ability.clearTappedForConvoke();
|
||||
}
|
||||
return true;
|
||||
return handleOfferingAndConvoke(ability, false, true);
|
||||
|
||||
}
|
||||
|
||||
@@ -200,4 +201,26 @@ public class CostPartMana extends CostPart {
|
||||
// TODO Auto-generated method stub
|
||||
return restriction;
|
||||
}
|
||||
|
||||
private boolean handleOfferingAndConvoke(final SpellAbility ability, boolean manaInputCancelled, boolean isPaid) {
|
||||
boolean done = !manaInputCancelled && isPaid;
|
||||
if (ability.isOffering() && ability.getSacrificedAsOffering() != null) {
|
||||
final Card offering = ability.getSacrificedAsOffering();
|
||||
offering.setUsedToPay(false);
|
||||
if (done) {
|
||||
ability.getSourceCard().getGame().getAction().sacrifice(offering, ability);
|
||||
}
|
||||
ability.resetSacrificedAsOffering();
|
||||
}
|
||||
if (ability.getTappedForConvoke() != null) {
|
||||
for (final Card c : ability.getTappedForConvoke()) {
|
||||
c.setTapped(false);
|
||||
if (done) {
|
||||
c.tap();
|
||||
}
|
||||
}
|
||||
ability.clearTappedForConvoke();
|
||||
}
|
||||
return done;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,26 +32,10 @@ public class InputPayManaOfCostPayment extends InputPayMana {
|
||||
if (this.phyLifeToLose > 0) {
|
||||
player.payLife(this.phyLifeToLose, source);
|
||||
}
|
||||
|
||||
// If this is a spell with convoke, re-tap all creatures used for it.
|
||||
// This is done to make sure Taps triggers go off at the right time
|
||||
// (i.e. AFTER cost payment, they are tapped previously as well so that
|
||||
// any mana tapabilities can't be used in payment as well as being tapped for convoke)
|
||||
|
||||
handleConvokedCards(false);
|
||||
|
||||
if (saPaidFor.isOffering()) {
|
||||
handleOfferings(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
handleConvokedCards(true);
|
||||
|
||||
if (saPaidFor.isOffering()) {
|
||||
handleOfferings(true);
|
||||
}
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,22 +89,12 @@ public class InputPayManaSimple extends InputPayMana {
|
||||
if (this.saPaidFor.isSpell()) {
|
||||
this.saPaidFor.setSourceCard(game.getAction().moveToStack(this.originalCard));
|
||||
}
|
||||
|
||||
handleConvokedCards(false);
|
||||
}
|
||||
if (!this.saPaidFor.isOffering()) {
|
||||
handleOfferings(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void onCancel() {
|
||||
handleConvokedCards(true);
|
||||
if (!this.saPaidFor.isOffering()) {
|
||||
handleOfferings(true);
|
||||
}
|
||||
|
||||
player.getManaPool().refundManaPaid(this.saPaidFor, true);
|
||||
player.getZone(ZoneType.Battlefield).updateObservers(); // DO
|
||||
|
||||
|
||||
Reference in New Issue
Block a user