mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Removed 'YChoice' from game. - Tetravus may use the same variable X (it's cleared after resolve) no other cards used it
Fixed NPE in announce code for costs that do announce but have no manacost (ab of simic manipulator)
This commit is contained in:
@@ -226,7 +226,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private final List<Command> untapCommandList = new ArrayList<Command>();
|
||||
private final List<Command> changeControllerCommandList = new ArrayList<Command>();
|
||||
|
||||
private final static ImmutableList<String> storableSVars = ImmutableList.of("ChosenX", "ChosenY" );
|
||||
private final static ImmutableList<String> storableSVars = ImmutableList.of("ChosenX" );
|
||||
|
||||
private final List<Card> hauntedBy = new ArrayList<Card>();
|
||||
private Card haunting = null;
|
||||
|
||||
@@ -318,7 +318,7 @@ public class AbilityUtils {
|
||||
if (StringUtils.isBlank(svarval)) {
|
||||
// Some variables may be not chosen yet at this moment
|
||||
// So return 0 and don't issue an error.
|
||||
if (amount.equals("ChosenX") || amount.equals("ChosenY")) {
|
||||
if (amount.equals("ChosenX")) {
|
||||
// isn't made yet
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ public class CleanUpEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("ClearChosenX")) {
|
||||
source.setSVar("ChosenX", "");
|
||||
}
|
||||
if (sa.hasParam("ClearChosenY")) {
|
||||
source.setSVar("ChosenY", "");
|
||||
}
|
||||
if (sa.hasParam("ClearTriggered")) {
|
||||
Singletons.getModel().getGame().getTriggerHandler().clearDelayedTrigger(source);
|
||||
}
|
||||
|
||||
@@ -542,8 +542,6 @@ public class CostExile extends CostPartWithList {
|
||||
// Generalize this
|
||||
if (sVar.equals("XChoice")) {
|
||||
c = CostUtil.chooseXValue(source, ability, list.size());
|
||||
} else if (sVar.equals("YChoice")) {
|
||||
c = CostUtil.chooseYValue(source, ability, list.size());
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
@@ -652,7 +650,7 @@ public class CostExile extends CostPartWithList {
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(this.getAmount());
|
||||
// Generalize this
|
||||
if (sVar.equals("XChoice") || sVar.equals("YChoice")) {
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
|
||||
|
||||
@@ -122,21 +122,23 @@ public class CostRemoveCounter extends CostPartWithList {
|
||||
final String amount = this.getAmount();
|
||||
final Card source = ability.getSourceCard();
|
||||
Integer c = this.convertAmount();
|
||||
int maxCounters = 0;
|
||||
|
||||
String sVarAmount = ability.getSVar(amount);
|
||||
cntRemoved = 1;
|
||||
if (amount.equals("All"))
|
||||
cntRemoved = -1;
|
||||
else if (c != null) {
|
||||
if (c != null)
|
||||
cntRemoved = c.intValue();
|
||||
} else {
|
||||
cntRemoved = "XChoice".equals(ability.getSVar(amount))
|
||||
? CostUtil.chooseXValue(source, ability, maxCounters)
|
||||
: AbilityUtils.calculateAmount(source, amount, ability);
|
||||
else if (!"XChoice".equals(sVarAmount)) {
|
||||
cntRemoved = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
|
||||
|
||||
if (this.payCostFromSource()) {
|
||||
maxCounters = source.getCounters(this.counter);
|
||||
int maxCounters = source.getCounters(this.counter);
|
||||
if (amount.equals("All"))
|
||||
cntRemoved = maxCounters;
|
||||
else if ( c == null && "XChoice".equals(sVarAmount)) {
|
||||
cntRemoved = CostUtil.chooseXValue(source, ability, maxCounters);
|
||||
}
|
||||
|
||||
if (maxCounters < cntRemoved)
|
||||
return false;
|
||||
cntRemoved = cntRemoved >= 0 ? cntRemoved : maxCounters;
|
||||
|
||||
@@ -97,33 +97,6 @@ public class CostUtil {
|
||||
return chosenX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose x value (for ChosenY).
|
||||
*
|
||||
* @param card
|
||||
* the card
|
||||
* @param sa
|
||||
* the SpellAbility
|
||||
* @param maxValue
|
||||
* the max value
|
||||
* @return the int
|
||||
*/
|
||||
public static int chooseYValue(final Card card, final SpellAbility sa, final int maxValue) {
|
||||
/*final String chosen = sa.getSVar("ChosenY");
|
||||
if (chosen.length() > 0) {
|
||||
return AbilityFactory.calculateAmount(card, "ChosenY", null);
|
||||
}*/
|
||||
|
||||
final Integer[] choiceArray = new Integer[maxValue + 1];
|
||||
for (int i = 0; i < choiceArray.length; i++) {
|
||||
choiceArray[i] = Integer.valueOf(i);
|
||||
}
|
||||
final Integer chosenY = GuiChoose.one(card.toString() + " - Choose a Value for Y", choiceArray);
|
||||
sa.setSVar("ChosenY", Integer.toString(chosenY));
|
||||
card.setSVar("ChosenY", Integer.toString(chosenY));
|
||||
|
||||
return chosenY;
|
||||
}
|
||||
|
||||
public static Cost combineCosts(Cost cost1, Cost cost2) {
|
||||
if (cost1 == null) return cost2;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cost.CostPartMana;
|
||||
import forge.card.cost.CostPayment;
|
||||
import forge.game.GameState;
|
||||
import forge.game.zone.Zone;
|
||||
@@ -157,7 +158,9 @@ public class HumanPlaySpellAbility {
|
||||
for(String aVar : announce.split(",")) {
|
||||
String varName = aVar.trim();
|
||||
|
||||
boolean allowZero = !("X".equalsIgnoreCase(varName)) || ability.getPayCosts().getCostMana().canXbe0();
|
||||
boolean isX = "X".equalsIgnoreCase(varName);
|
||||
CostPartMana manaCost = ability.getPayCosts().getCostMana();
|
||||
boolean allowZero = !isX || manaCost == null || manaCost.canXbe0();
|
||||
|
||||
Integer value = ability.getActivatingPlayer().getController().announceRequirements(ability, varName, allowZero);
|
||||
if ( null == value )
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.FThreads;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
|
||||
Reference in New Issue
Block a user