add MayPlaySnowIgnoreColor for Draugr Necromancer

This commit is contained in:
Hans Mackowiak
2021-02-03 09:28:16 +01:00
parent 79319aa10d
commit d47bd3daf6
6 changed files with 50 additions and 14 deletions

View File

@@ -54,11 +54,15 @@ public final class CardPlayOption {
public boolean isIgnoreManaCostColor() {
return sta.hasParam("MayPlayIgnoreColor");
}
public boolean isIgnoreManaCostType() {
return sta.hasParam("MayPlayIgnoreType");
}
public boolean isIgnoreSnowSourceManaCostColor() {
return sta.hasParam("MayPlaySnowIgnoreColor");
}
public boolean isWithFlash() {
return withFlash;
}

View File

@@ -7,8 +7,28 @@ public class ManaConversionMatrix {
// Conversion matrix ORs byte values to make mana more payable
// Restrictive matrix ANDs byte values to make mana less payable
byte[] colorConversionMatrix = new byte[ManaAtom.MANATYPES.length];
byte[] colorRestrictionMatrix = new byte[ManaAtom.MANATYPES.length];
protected byte[] colorConversionMatrix = new byte[ManaAtom.MANATYPES.length];
protected byte[] colorRestrictionMatrix = new byte[ManaAtom.MANATYPES.length];
protected boolean snowForColor = false;
public boolean isSnowForColor() {
return snowForColor;
}
public void setSnowForColor(boolean value) {
snowForColor = value;
}
public byte getPossibleColorUses(byte color) {
// Take the current conversion value, AND with restrictions to get mana usage
int rowIdx = ManaAtom.getIndexOfFirstManaType(color);
int matrixIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
byte colorUse = colorConversionMatrix[matrixIdx];
colorUse &= colorRestrictionMatrix[matrixIdx];
return colorUse;
}
public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) {
// Fix the index without hardcodes
@@ -30,6 +50,7 @@ public class ManaConversionMatrix {
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
colorRestrictionMatrix[i] &= extraMatrix.colorRestrictionMatrix[i];
}
setSnowForColor(extraMatrix.isSnowForColor());
}
public void restoreColorReplacements() {
@@ -41,5 +62,6 @@ public class ManaConversionMatrix {
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
colorRestrictionMatrix[i] = ManaAtom.ALL_MANA_TYPES;
}
snowForColor = false;
}
}

View File

@@ -547,6 +547,11 @@ public class ManaCostBeingPaid {
return false;
}
// snow can be paid for any color
if (shard.getColorMask() != 0 && mana.isSnow() && pool.isSnowForColor()) {
return true;
}
byte color = mana.getColor();
return pool.canPayForShardWithColor(shard, color);
}

View File

@@ -298,16 +298,6 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
p.getGame().fireEvent(new GameEventZone(ZoneType.Battlefield, p, EventValueChangeType.ComplexUpdate, null));
}
public byte getPossibleColorUses(byte color) {
// Take the current conversion value, AND with restrictions to get mana usage
int rowIdx = ManaAtom.getIndexOfFirstManaType(color);
int matrixIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
byte colorUse = colorConversionMatrix[matrixIdx];
colorUse &= colorRestrictionMatrix[matrixIdx];
return colorUse;
}
public boolean canPayForShardWithColor(ManaCostShard shard, byte color) {
if (shard.isOfKind(ManaAtom.COLORLESS) && color == ManaAtom.GENERIC) {
return false; // FIXME: testing Colorless against Generic is a recipe for disaster, but probably there should be a better fix.