CardProperty: hasXCost, it should check ManaCost

This commit is contained in:
Hans Mackowiak
2021-02-23 16:58:55 +01:00
parent 848635d8e0
commit 96532309ce
4 changed files with 6 additions and 12 deletions

View File

@@ -2880,7 +2880,7 @@ public class ComputerUtil {
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
Card targetSpellCard = null;
for (Card c : options) {
if (withoutPayingManaCost && c.getManaCost() != null && c.getManaCost().getShardCount(ManaCostShard.X) > 0) {
if (withoutPayingManaCost && c.getManaCost() != null && c.getManaCost().countX() > 0) {
// The AI will otherwise cheat with the mana payment, announcing X > 0 for spells like Heat Ray when replaying them
// without paying their mana cost.
continue;

View File

@@ -345,13 +345,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
* @return
*/
public int countX() {
int iX = 0;
for (ManaCostShard shard : shards) {
if (shard == ManaCostShard.X) {
iX++;
}
}
return iX;
return getShardCount(ManaCostShard.X);
}
/**

View File

@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostShard;
import forge.game.Direction;
import forge.game.EvenOdd;
@@ -1389,8 +1390,8 @@ public class CardProperty {
return false;
}
} else if (property.startsWith("hasXCost")) {
SpellAbility sa1 = card.getFirstSpellAbility();
if (sa1 != null && !sa1.costHasManaX()) {
ManaCost cost = card.getManaCost();
if (cost == null || cost.countX() <= 0) {
return false;
}
} else if (property.startsWith("suspended")) {

View File

@@ -18,7 +18,6 @@
package forge.game.cost;
import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostShard;
import forge.game.mana.ManaConversionMatrix;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
@@ -77,7 +76,7 @@ public class CostPartMana extends CostPart {
}
public final int getAmountOfX() {
return this.cost.getShardCount(ManaCostShard.X);
return this.cost.countX();
}
/**