diff --git a/src/main/java/forge/card/cost/CostPartMana.java b/src/main/java/forge/card/cost/CostPartMana.java index fac1b8fb8cb..8d1c1f763e6 100644 --- a/src/main/java/forge/card/cost/CostPartMana.java +++ b/src/main/java/forge/card/cost/CostPartMana.java @@ -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; + } } diff --git a/src/main/java/forge/gui/input/InputPayManaOfCostPayment.java b/src/main/java/forge/gui/input/InputPayManaOfCostPayment.java index 4779bf185a0..f49efe69d48 100644 --- a/src/main/java/forge/gui/input/InputPayManaOfCostPayment.java +++ b/src/main/java/forge/gui/input/InputPayManaOfCostPayment.java @@ -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(); } diff --git a/src/main/java/forge/gui/input/InputPayManaSimple.java b/src/main/java/forge/gui/input/InputPayManaSimple.java index ef60a4fd9a5..d923289d4d4 100644 --- a/src/main/java/forge/gui/input/InputPayManaSimple.java +++ b/src/main/java/forge/gui/input/InputPayManaSimple.java @@ -77,9 +77,9 @@ public class InputPayManaSimple extends InputPayMana { */ @Override protected void done() { - + this.originalCard.setSunburstValue(this.manaCost.getSunburst()); - + if (this.phyLifeToLose > 0) { player.payLife(this.phyLifeToLose, this.originalCard); } @@ -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