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;
|
package forge.control.input;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -8,9 +13,8 @@ import forge.view.ButtonUtil;
|
|||||||
public class InputPayManaX extends InputPayManaBase {
|
public class InputPayManaX extends InputPayManaBase {
|
||||||
private static final long serialVersionUID = -6900234444347364050L;
|
private static final long serialVersionUID = -6900234444347364050L;
|
||||||
private int xPaid = 0;
|
private int xPaid = 0;
|
||||||
private final String colorX;
|
|
||||||
private final String strX;
|
|
||||||
private String colorsPaid;
|
private String colorsPaid;
|
||||||
|
private final String manaCostStr;
|
||||||
private final boolean xCanBe0;
|
private final boolean xCanBe0;
|
||||||
private boolean canceled = false;
|
private boolean canceled = false;
|
||||||
|
|
||||||
@@ -18,14 +22,25 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
public InputPayManaX(final SpellAbility sa0, final int amountX, final boolean xCanBe0)
|
public InputPayManaX(final SpellAbility sa0, final int amountX, final boolean xCanBe0)
|
||||||
{
|
{
|
||||||
super(sa0);
|
super(sa0);
|
||||||
|
|
||||||
xPaid = 0;
|
xPaid = 0;
|
||||||
colorX = saPaidFor.hasParam("XColor") ? saPaidFor.getParam("XColor") : "";
|
if (saPaidFor.hasParam("XColor") )
|
||||||
colorsPaid = saPaidFor.getSourceCard().getColorsPaid();
|
{
|
||||||
|
String xColor = saPaidFor.getParam("XColor");
|
||||||
strX = Integer.toString(amountX);
|
if( amountX == 1 )
|
||||||
manaCost = new ManaCostBeingPaid(strX);
|
manaCostStr = xColor;
|
||||||
this.xCanBe0 = xCanBe0;
|
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);
|
||||||
|
|
||||||
|
this.xCanBe0 = xCanBe0;
|
||||||
|
colorsPaid = saPaidFor.getSourceCard().getColorsPaid(); // for effects like sunburst
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -35,7 +50,7 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
public boolean isPaid() {
|
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 !( 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
|
@Override
|
||||||
@@ -63,7 +78,7 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCardSelected(Card card) {
|
protected void onCardSelected(Card card) {
|
||||||
// don't allow here the cards that produce only wrong colors
|
// 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())) {
|
if (!this.colorsPaid.contains(this.manaCost.getColorsPaid())) {
|
||||||
this.colorsPaid += this.manaCost.getColorsPaid();
|
this.colorsPaid += this.manaCost.getColorsPaid();
|
||||||
}
|
}
|
||||||
this.manaCost = new ManaCostBeingPaid(strX);
|
this.manaCost = new ManaCostBeingPaid(manaCostStr);
|
||||||
this.xPaid++;
|
this.xPaid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +107,7 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectManaPool(byte colorCode) {
|
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