mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
InputPayManaX - bugfix + some improved code
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package forge.control.input;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -8,9 +13,8 @@ import forge.view.ButtonUtil;
|
||||
public class InputPayManaX extends InputPayManaBase {
|
||||
private static final long serialVersionUID = -6900234444347364050L;
|
||||
private int xPaid = 0;
|
||||
private final String colorX;
|
||||
private final String strX;
|
||||
private String colorsPaid;
|
||||
private final String manaCostStr;
|
||||
private final boolean xCanBe0;
|
||||
private boolean canceled = false;
|
||||
|
||||
@@ -18,14 +22,25 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
public InputPayManaX(final SpellAbility sa0, final int amountX, final boolean xCanBe0)
|
||||
{
|
||||
super(sa0);
|
||||
|
||||
xPaid = 0;
|
||||
colorX = saPaidFor.hasParam("XColor") ? saPaidFor.getParam("XColor") : "";
|
||||
colorsPaid = saPaidFor.getSourceCard().getColorsPaid();
|
||||
if (saPaidFor.hasParam("XColor") )
|
||||
{
|
||||
String xColor = saPaidFor.getParam("XColor");
|
||||
if( amountX == 1 )
|
||||
manaCostStr = xColor;
|
||||
else {
|
||||
List<String> list = new ArrayList<String>(amountX);
|
||||
for(int i = 0; i < amountX; i++)
|
||||
list.add(xColor);
|
||||
manaCostStr = StringUtils.join(list, ' ');
|
||||
}
|
||||
} else {
|
||||
manaCostStr = Integer.toString(amountX);
|
||||
}
|
||||
manaCost = new ManaCostBeingPaid(manaCostStr);
|
||||
|
||||
strX = Integer.toString(amountX);
|
||||
manaCost = new ManaCostBeingPaid(strX);
|
||||
this.xCanBe0 = xCanBe0;
|
||||
colorsPaid = saPaidFor.getSourceCard().getColorsPaid(); // for effects like sunburst
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -35,7 +50,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
public boolean isPaid() {
|
||||
//return !( xPaid == 0 && !costMana.canXbe0() || this.colorX.equals("") && !this.manaCost.toString().equals(strX) );
|
||||
// return !( xPaid == 0 && !costMana.canXbe0()) && !(this.colorX.equals("") && !this.manaCost.toString().equals(strX));
|
||||
return ( !canceled && (xPaid > 0 || xCanBe0) && (!this.colorX.equals("") || this.manaCost.toString().equals(strX)));
|
||||
return !canceled && (xPaid > 0 || xCanBe0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +78,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
@Override
|
||||
protected void onCardSelected(Card card) {
|
||||
// don't allow here the cards that produce only wrong colors
|
||||
activateManaAbility(card, this.colorX.isEmpty() ? this.manaCost : new ManaCostBeingPaid(this.colorX));
|
||||
activateManaAbility(card, this.manaCost);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +88,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
if (!this.colorsPaid.contains(this.manaCost.getColorsPaid())) {
|
||||
this.colorsPaid += this.manaCost.getColorsPaid();
|
||||
}
|
||||
this.manaCost = new ManaCostBeingPaid(strX);
|
||||
this.manaCost = new ManaCostBeingPaid(manaCostStr);
|
||||
this.xPaid++;
|
||||
}
|
||||
}
|
||||
@@ -92,7 +107,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
|
||||
@Override
|
||||
public void selectManaPool(byte colorCode) {
|
||||
useManaFromPool(colorCode, this.colorX.isEmpty() ? this.manaCost : new ManaCostBeingPaid(this.colorX));
|
||||
useManaFromPool(colorCode, this.manaCost);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user