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.

View File

@@ -0,0 +1,11 @@
Name:Draugr Necromancer
ManaCost:3 B
Types:Snow Creature Zombie Cleric
PT:4/4
R:Event$ Moved | ActiveZones$ Battlefield | Origin$ Battlefield | Destination$ Graveyard | ValidLKI$ Creature.nonToken+OppCtrl | ReplaceWith$ Exile | CheckSelfLKIZone$ True | Description$ If a nontoken creature an opponent controls would die, exile that card with an ice counter on it instead.
SVar:Exile:DB$ ChangeZone | Origin$ Battlefield | Destination$ Exile | Defined$ ReplacedCard | SubAbility$ DBPutCounter
SVar:DBPutCounter:DB$ PutCounter | Defined$ ReplacedCard | CounterType$ ICE | CounterNum$ 1
S:Mode$ Continuous | Affected$ Card.OppOwn+counters_GE1_ICE+nonLand | AffectedZone$ Exile | MayPlay$ True | MayPlaySnowIgnoreColor$ True | Description$ You may cast spells from among cards in exile your opponents own with ice counters on them, and you may spend mana from snow sources as though it were mana of any color to cast those spells.
DeckNeeds:Type$Snow
DeckHas:Ability$Counters
Oracle:If a nontoken creature an opponent controls would die, exile that card with an ice counter on it instead.\nYou may cast spells from among cards in exile your opponents own with ice counters on them, and you may spend mana from snow sources as though it were mana of any color to cast those spells.

View File

@@ -119,6 +119,10 @@ public class HumanPlaySpellAbility {
human.incNumManaConversion();
}
if (option != null && option.isIgnoreSnowSourceManaCostColor()) {
payment.setSnowForColor(true);
}
if (ability.isAbility() && ability.isActivatedAbility()) {
final Map<String, String> params = Maps.newHashMap();
params.put("ManaColorConversion", "Additive");