setColorsToPay, setSunburst moved from input/InputPayManaOfCostPayment.java to CostPartMana

ManaPool.payManaFromAbility does not return ManaCostBeingPaid - that means it does not create a new instance, but alters the one passed as parameter
a few mana-paying inputs: the player who is shown the input is taken from base class field, not from singletons
This commit is contained in:
Maxmtg
2013-04-25 07:32:46 +00:00
parent e258d30580
commit 46e2ac3c65
7 changed files with 10 additions and 28 deletions

View File

@@ -133,6 +133,9 @@ public class CostPartMana extends CostPart {
FThreads.setInputAndWait(inpPayment); FThreads.setInputAndWait(inpPayment);
if(!inpPayment.isPaid()) if(!inpPayment.isPaid())
return false; return false;
source.setColorsPaid(toPay.getColorsPaid());
source.setSunburstValue(toPay.getSunburst());
} }
if (this.getAmountOfX() > 0) { if (this.getAmountOfX() > 0) {
if( !ability.isAnnouncing("X") && !xWasBilled) { if( !ability.isAnnouncing("X") && !xWasBilled) {

View File

@@ -493,11 +493,7 @@ public class ManaPool {
* a {@link forge.card.spellability.AbilityMana} object. * a {@link forge.card.spellability.AbilityMana} object.
* @return a {@link forge.card.mana.ManaCostBeingPaid} object. * @return a {@link forge.card.mana.ManaCostBeingPaid} object.
*/ */
public final ManaCostBeingPaid payManaFromAbility(final SpellAbility sa, ManaCostBeingPaid manaCost, final SpellAbility ma) { public final void payManaFromAbility(final SpellAbility sa, ManaCostBeingPaid manaCost, final SpellAbility ma) {
if (manaCost.isPaid() || this.isEmpty()) {
return manaCost;
}
// Mana restriction must be checked before this method is called // Mana restriction must be checked before this method is called
final List<SpellAbility> paidAbs = sa.getPayingManaAbilities(); final List<SpellAbility> paidAbs = sa.getPayingManaAbilities();
@@ -522,7 +518,6 @@ public class ManaPool {
} }
} }
} }
return manaCost;
} }
/** /**

View File

@@ -308,7 +308,7 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
public void onManaAbilityPlayed(final SpellAbility saPaymentSrc) { public void onManaAbilityPlayed(final SpellAbility saPaymentSrc) {
if ( saPaymentSrc != null) // null comes when they've paid from pool if ( saPaymentSrc != null) // null comes when they've paid from pool
this.manaCost = player.getManaPool().payManaFromAbility(saPaidFor, manaCost, saPaymentSrc); player.getManaPool().payManaFromAbility(saPaidFor, manaCost, saPaymentSrc);
onManaAbilityPaid(); onManaAbilityPaid();
if ( saPaymentSrc != null ) if ( saPaymentSrc != null )

View File

@@ -17,7 +17,6 @@
*/ */
package forge.control.input; package forge.control.input;
import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostBeingPaid; import forge.card.mana.ManaCostBeingPaid;
@@ -95,9 +94,9 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
@Override @Override
protected void done() { protected void done() {
if (this.phyLifeToLose > 0) { if (this.phyLifeToLose > 0) {
Singletons.getControl().getPlayer().payLife(this.phyLifeToLose, null); player.payLife(this.phyLifeToLose, null);
} }
Singletons.getControl().getPlayer().getManaPool().clearManaPaid(this.saPaidFor, false); player.getManaPool().clearManaPaid(this.saPaidFor, false);
bPaid = true; bPaid = true;
this.stop(); this.stop();
} }
@@ -105,7 +104,7 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected final void onCancel() { protected final void onCancel() {
Singletons.getControl().getPlayer().getManaPool().refundManaPaid(this.saPaidFor, true); player.getManaPool().refundManaPaid(this.saPaidFor, true);
bPaid = false; bPaid = false;
this.stop(); this.stop();
} }

View File

@@ -1,7 +1,6 @@
package forge.control.input; package forge.control.input;
import forge.Card; import forge.Card;
import forge.Singletons;
import forge.card.mana.ManaCostBeingPaid; import forge.card.mana.ManaCostBeingPaid;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.game.player.Player; import forge.game.player.Player;
@@ -32,10 +31,8 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
protected void done() { protected void done() {
final Card source = saPaidFor.getSourceCard(); final Card source = saPaidFor.getSourceCard();
if (this.phyLifeToLose > 0) { if (this.phyLifeToLose > 0) {
Singletons.getControl().getPlayer().payLife(this.phyLifeToLose, source); player.payLife(this.phyLifeToLose, source);
} }
source.setColorsPaid(this.manaCost.getColorsPaid());
source.setSunburstValue(this.manaCost.getSunburst());
// If this is a spell with convoke, re-tap all creatures used for it. // 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 // This is done to make sure Taps triggers go off at the right time

View File

@@ -50,16 +50,6 @@ public class InputPayManaSimple extends InputPayManaBase {
} }
/**
* <p>
* resetManaCost.
* </p>
*/
private void resetManaCost() {
this.manaCost = new ManaCostBeingPaid(this.originalManaCost);
this.phyLifeToLose = 0;
}
protected void onManaAbilityPaid() { protected void onManaAbilityPaid() {
if (this.manaCost.isPaid()) { if (this.manaCost.isPaid()) {
this.originalCard.setSunburstValue(this.manaCost.getSunburst()); this.originalCard.setSunburstValue(this.manaCost.getSunburst());
@@ -92,7 +82,6 @@ public class InputPayManaSimple extends InputPayManaBase {
} }
if (!this.saPaidFor.getSourceCard().isCopiedSpell()) { if (!this.saPaidFor.getSourceCard().isCopiedSpell()) {
player.getManaPool().clearManaPaid(this.saPaidFor, false); player.getManaPool().clearManaPaid(this.saPaidFor, false);
this.resetManaCost();
if (this.saPaidFor.isSpell()) { if (this.saPaidFor.isSpell()) {
this.saPaidFor.setSourceCard(game.getAction().moveToStack(this.originalCard)); this.saPaidFor.setSourceCard(game.getAction().moveToStack(this.originalCard));
@@ -108,7 +97,6 @@ public class InputPayManaSimple extends InputPayManaBase {
@Override @Override
protected final void onCancel() { protected final void onCancel() {
handleConvokedCards(true); handleConvokedCards(true);
this.resetManaCost();
player.getManaPool().refundManaPaid(this.saPaidFor, true); player.getManaPool().refundManaPaid(this.saPaidFor, true);
player.getZone(ZoneType.Battlefield).updateObservers(); // DO player.getZone(ZoneType.Battlefield).updateObservers(); // DO

View File

@@ -216,7 +216,7 @@ public class ComputerUtilMana {
//ma.resolve(); //ma.resolve();
AbilityUtils.resolve(ma, false); AbilityUtils.resolve(ma, false);
// subtract mana from mana pool // subtract mana from mana pool
cost = manapool.payManaFromAbility(sa, cost, ma); manapool.payManaFromAbility(sa, cost, ma);
} else { } else {
cost.payMultipleMana(manaProduced); cost.payMultipleMana(manaProduced);
} }