mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
properly implement WaterbendXCost
This commit is contained in:
parent
f007ebb289
commit
4480dbdf4d
9 changed files with 90 additions and 72 deletions
|
|
@ -8,6 +8,7 @@ import mage.abilities.condition.Condition;
|
|||
import mage.abilities.costs.*;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.costs.common.WaterbendCost;
|
||||
import mage.abilities.costs.common.WaterbendXCost;
|
||||
import mage.abilities.costs.mana.*;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
|
@ -814,54 +815,59 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (variableManaCost != null) {
|
||||
if (!variableManaCost.isPaid()) { // should only happen for human players
|
||||
int xValue;
|
||||
if (!noMana || variableManaCost.getCostType().canUseAnnounceOnFreeCast()) {
|
||||
if (variableManaCost.wasAnnounced()) {
|
||||
// announce by rules
|
||||
xValue = variableManaCost.getAmount();
|
||||
} else {
|
||||
// announce by player
|
||||
xValue = controller.announceX(variableManaCost.getMinX(), variableManaCost.getMaxX(),
|
||||
"Announce the value for " + variableManaCost.getText(), game, this, true);
|
||||
}
|
||||
|
||||
int amountMana = xValue * variableManaCost.getXInstancesCount();
|
||||
StringBuilder manaString = threadLocalBuilder.get();
|
||||
if (variableManaCost.getFilter() == null || variableManaCost.getFilter().isGeneric()) {
|
||||
manaString.append('{').append(amountMana).append('}');
|
||||
} else {
|
||||
String manaSymbol = null;
|
||||
if (variableManaCost.getFilter().isBlack()) {
|
||||
if (variableManaCost.getFilter().isRed()) {
|
||||
manaSymbol = "B/R";
|
||||
} else {
|
||||
manaSymbol = "B";
|
||||
}
|
||||
} else if (variableManaCost.getFilter().isRed()) {
|
||||
manaSymbol = "R";
|
||||
} else if (variableManaCost.getFilter().isBlue()) {
|
||||
manaSymbol = "U";
|
||||
} else if (variableManaCost.getFilter().isGreen()) {
|
||||
manaSymbol = "G";
|
||||
} else if (variableManaCost.getFilter().isWhite()) {
|
||||
manaSymbol = "W";
|
||||
}
|
||||
if (manaSymbol == null) {
|
||||
throw new UnsupportedOperationException("ManaFilter is not supported: " + this);
|
||||
}
|
||||
for (int i = 0; i < amountMana; i++) {
|
||||
manaString.append('{').append(manaSymbol).append('}');
|
||||
}
|
||||
}
|
||||
addManaCostsToPay(new ManaCostsImpl<>(manaString.toString()));
|
||||
getManaCostsToPay().setX(xValue, amountMana);
|
||||
setCostsTag("X", xValue);
|
||||
}
|
||||
variableManaCost.setPaid();
|
||||
}
|
||||
if (variableManaCost == null) {
|
||||
return variableManaCost;
|
||||
}
|
||||
if (variableManaCost.isPaid()) {
|
||||
return variableManaCost;
|
||||
} // should only happen for human players
|
||||
int xValue;
|
||||
if (!noMana || variableManaCost.getCostType().canUseAnnounceOnFreeCast()) {
|
||||
if (variableManaCost.wasAnnounced()) {
|
||||
// announce by rules
|
||||
xValue = variableManaCost.getAmount();
|
||||
} else {
|
||||
// announce by player
|
||||
xValue = controller.announceX(variableManaCost.getMinX(), variableManaCost.getMaxX(),
|
||||
"Announce the value for " + variableManaCost.getText(), game, this, true);
|
||||
}
|
||||
|
||||
int amountMana = xValue * variableManaCost.getXInstancesCount();
|
||||
StringBuilder manaString = threadLocalBuilder.get();
|
||||
if (!(variableManaCost instanceof WaterbendXCost)) {
|
||||
if (variableManaCost.getFilter() == null || variableManaCost.getFilter().isGeneric()) {
|
||||
manaString.append('{').append(amountMana).append('}');
|
||||
} else {
|
||||
String manaSymbol;
|
||||
if (variableManaCost.getFilter().isBlack()) {
|
||||
if (variableManaCost.getFilter().isRed()) {
|
||||
manaSymbol = "B/R";
|
||||
} else {
|
||||
manaSymbol = "B";
|
||||
}
|
||||
} else if (variableManaCost.getFilter().isRed()) {
|
||||
manaSymbol = "R";
|
||||
} else if (variableManaCost.getFilter().isBlue()) {
|
||||
manaSymbol = "U";
|
||||
} else if (variableManaCost.getFilter().isGreen()) {
|
||||
manaSymbol = "G";
|
||||
} else if (variableManaCost.getFilter().isWhite()) {
|
||||
manaSymbol = "W";
|
||||
} else {
|
||||
throw new UnsupportedOperationException("ManaFilter is not supported: " + this);
|
||||
}
|
||||
for (int i = 0; i < amountMana; i++) {
|
||||
manaString.append('{').append(manaSymbol).append('}');
|
||||
}
|
||||
}
|
||||
addManaCostsToPay(new ManaCostsImpl<>(manaString.toString()));
|
||||
} else {
|
||||
addManaCostsToPay(new WaterbendCost(amountMana));
|
||||
}
|
||||
getManaCostsToPay().setX(xValue, amountMana);
|
||||
setCostsTag("X", xValue);
|
||||
}
|
||||
variableManaCost.setPaid();
|
||||
|
||||
return variableManaCost;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import mage.abilities.costs.mana.GenericManaCost;
|
|||
* (usually because the waterbend cost itself is an additional cost), the alternate method to pay for mana
|
||||
* described in rule 701.67a may be used only to pay for the amount of generic mana in the waterbend cost,
|
||||
* even if the total cost to cast that spell or activate that ability includes other generic mana components.
|
||||
* <p>
|
||||
* If you need Waterbend {X} then use {@link WaterbendXCost}
|
||||
* If using as an additional cost for a spell, add an ability with an InfoEffect for proper text generation (see WaterWhip)
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
package mage.abilities.costs.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.VariableCostType;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
|
||||
/**
|
||||
* TODO: Implement properly
|
||||
* Used for Waterbend {X} costs, otherwise use {@link WaterbendCost}
|
||||
* If using as an additional cost for a spell, add an ability with an InfoEffect for proper text generation (see WaterbendersRestoration)
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class WaterbendXCost extends CostImpl {
|
||||
public class WaterbendXCost extends VariableManaCost {
|
||||
|
||||
public WaterbendXCost() {
|
||||
super();
|
||||
this.text = "waterbend {X}";
|
||||
this(0);
|
||||
}
|
||||
|
||||
public WaterbendXCost(int minX) {
|
||||
super(VariableCostType.NORMAL);
|
||||
this.setMinX(minX);
|
||||
}
|
||||
|
||||
private WaterbendXCost(final WaterbendXCost cost) {
|
||||
|
|
@ -29,12 +30,7 @@ public class WaterbendXCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
return false;
|
||||
public String getText() {
|
||||
return "waterbend {X}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue