mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +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()) {
|
if (!toPay.isPaid()) {
|
||||||
inpPayment = new InputPayManaOfCostPayment(toPay, ability);
|
inpPayment = new InputPayManaOfCostPayment(toPay, ability);
|
||||||
Singletons.getControl().getInputQueue().setInputAndWait(inpPayment);
|
Singletons.getControl().getInputQueue().setInputAndWait(inpPayment);
|
||||||
if(!inpPayment.isPaid())
|
if (!inpPayment.isPaid()) {
|
||||||
return false;
|
return handleOfferingAndConvoke(ability, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
source.setColorsPaid(toPay.getColorsPaid());
|
source.setColorsPaid(toPay.getColorsPaid());
|
||||||
source.setSunburstValue(toPay.getSunburst());
|
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) {
|
if (ability.isOffering() && ability.getSacrificedAsOffering() != null) {
|
||||||
System.out.println("Finishing up Offering");
|
System.out.println("Finishing up Offering");
|
||||||
final Card offering = ability.getSacrificedAsOffering();
|
final Card offering = ability.getSacrificedAsOffering();
|
||||||
@@ -171,7 +172,7 @@ public class CostPartMana extends CostPart {
|
|||||||
}
|
}
|
||||||
ability.clearTappedForConvoke();
|
ability.clearTappedForConvoke();
|
||||||
}
|
}
|
||||||
return true;
|
return handleOfferingAndConvoke(ability, false, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,4 +201,26 @@ public class CostPartMana extends CostPart {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return restriction;
|
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) {
|
if (this.phyLifeToLose > 0) {
|
||||||
player.payLife(this.phyLifeToLose, source);
|
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
|
@Override
|
||||||
protected void onCancel() {
|
protected void onCancel() {
|
||||||
handleConvokedCards(true);
|
|
||||||
|
|
||||||
if (saPaidFor.isOffering()) {
|
|
||||||
handleOfferings(true);
|
|
||||||
}
|
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ public class InputPayManaSimple extends InputPayMana {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
|
|
||||||
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
|
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
|
||||||
|
|
||||||
if (this.phyLifeToLose > 0) {
|
if (this.phyLifeToLose > 0) {
|
||||||
player.payLife(this.phyLifeToLose, this.originalCard);
|
player.payLife(this.phyLifeToLose, this.originalCard);
|
||||||
}
|
}
|
||||||
@@ -89,22 +89,12 @@ public class InputPayManaSimple extends InputPayMana {
|
|||||||
if (this.saPaidFor.isSpell()) {
|
if (this.saPaidFor.isSpell()) {
|
||||||
this.saPaidFor.setSourceCard(game.getAction().moveToStack(this.originalCard));
|
this.saPaidFor.setSourceCard(game.getAction().moveToStack(this.originalCard));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleConvokedCards(false);
|
|
||||||
}
|
|
||||||
if (!this.saPaidFor.isOffering()) {
|
|
||||||
handleOfferings(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected final void onCancel() {
|
protected final void onCancel() {
|
||||||
handleConvokedCards(true);
|
|
||||||
if (!this.saPaidFor.isOffering()) {
|
|
||||||
handleOfferings(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getManaPool().refundManaPaid(this.saPaidFor, true);
|
player.getManaPool().refundManaPaid(this.saPaidFor, true);
|
||||||
player.getZone(ZoneType.Battlefield).updateObservers(); // DO
|
player.getZone(ZoneType.Battlefield).updateObservers(); // DO
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user