add MayPlayIgnoreType in addition to MayPlayIgnoreColor, fixed the ignore Color part, it should not work with {C}

This commit is contained in:
Hanmac
2017-04-16 19:30:45 +00:00
parent 5e56d327ab
commit ea91d23bc2
5 changed files with 46 additions and 28 deletions

View File

@@ -144,16 +144,19 @@ public final class MagicColor {
/** The Basic lands. */
public static final ImmutableList<String> BASIC_LANDS = ImmutableList.of("Plains", "Island", "Swamp", "Mountain", "Forest");
public static final ImmutableList<String> SNOW_LANDS = ImmutableList.of("Snow-Covered Plains", "Snow-Covered Island", "Snow-Covered Swamp", "Snow-Covered Mountain", "Snow-Covered Forest");
public static final ImmutableMap<String, String> ANY_MANA_CONVERSION = new ImmutableMap.Builder<String, String>()
public static final ImmutableMap<String, String> ANY_COLOR_CONVERSION = new ImmutableMap.Builder<String, String>()
.put("ManaColorConversion", "Additive")
.put("WhiteConversion", "All")
.put("BlueConversion", "All")
.put("BlackConversion", "All")
.put("RedConversion", "All")
.put("GreenConversion", "All")
.put("ColorlessConversion", "All")
.build();
public static final ImmutableMap<String, String> ANY_TYPE_CONVERSION = new ImmutableMap.Builder<String, String>()
.putAll(ANY_COLOR_CONVERSION)
.put("ColorlessConversion", "All")
.build();
/**
* Private constructor to prevent instantiation.
*/

View File

@@ -1018,7 +1018,7 @@ public class Card extends GameEntity implements Comparable<Card> {
addAmount = 0;
}
if (addAmount == 0) {
if (addAmount <= 0) {
return;
}
setTotalCountersToAdd(addAmount);
@@ -2378,6 +2378,7 @@ public class Card extends GameEntity implements Comparable<Card> {
}
return mayPlay.get(sta);
}
public final List<CardPlayOption> mayPlay(final Player player) {
List<CardPlayOption> result = Lists.newArrayList();
for (CardPlayOption o : mayPlay.values()) {
@@ -2387,8 +2388,8 @@ public class Card extends GameEntity implements Comparable<Card> {
}
return result;
}
public final void setMayPlay(final Player player, final boolean withoutManaCost, final boolean ignoreColor, final boolean withFlash, final StaticAbility sta) {
this.mayPlay.put(sta, new CardPlayOption(player, sta, withoutManaCost, ignoreColor, withFlash));
public final void setMayPlay(final Player player, final boolean withoutManaCost, final boolean withFlash, final StaticAbility sta) {
this.mayPlay.put(sta, new CardPlayOption(player, sta, withoutManaCost, withFlash));
}
public final void removeMayPlay(final StaticAbility sta) {
this.mayPlay.remove(sta);

View File

@@ -16,17 +16,15 @@ public final class CardPlayOption {
private final Player player;
private final StaticAbility sta;
private final PayManaCost payManaCost;
private final boolean ignoreManaCostColor;
private final boolean withFlash;
public CardPlayOption(final Player player, final StaticAbility sta, final boolean withoutManaCost, final boolean ignoreManaCostColor, final boolean withFlash) {
this(player, sta, withoutManaCost ? PayManaCost.NO : PayManaCost.YES, ignoreManaCostColor, withFlash);
public CardPlayOption(final Player player, final StaticAbility sta, final boolean withoutManaCost, final boolean withFlash) {
this(player, sta, withoutManaCost ? PayManaCost.NO : PayManaCost.YES, withFlash);
}
private CardPlayOption(final Player player, final StaticAbility sta, final PayManaCost payManaCost, final boolean ignoreManaCostColor, final boolean withFlash) {
private CardPlayOption(final Player player, final StaticAbility sta, final PayManaCost payManaCost, final boolean withFlash) {
this.player = player;
this.sta = sta;
this.payManaCost = payManaCost;
this.ignoreManaCostColor = ignoreManaCostColor;
this.withFlash = withFlash;
}
@@ -48,7 +46,11 @@ public final class CardPlayOption {
}
public boolean isIgnoreManaCostColor() {
return ignoreManaCostColor;
return sta.hasParam("MayPlayIgnoreColor");
}
public boolean isIgnoreManaCostType() {
return sta.hasParam("MayPlayIgnoreType");
}
public boolean isWithFlash() {
@@ -67,6 +69,8 @@ public final class CardPlayOption {
case YES:
if (isIgnoreManaCostColor()) {
sb.append(" (may spend mana as though it were mana of any color to cast it)");
} else if (isIgnoreManaCostType()) {
sb.append(" (may spend mana as though it were mana of any type to cast it)");
}
break;
case NO:

View File

@@ -140,7 +140,7 @@ public final class StaticAbilityContinuous {
List<Player> mayLookAt = null;
boolean controllerMayPlay = false, mayPlayWithoutManaCost = false, mayPlayIgnoreColor = false, mayPlayWithFlash = false;
boolean controllerMayPlay = false, mayPlayWithoutManaCost = false, mayPlayWithFlash = false;
Integer mayPlayLimit = null;
//Global rules changes
@@ -387,8 +387,6 @@ public final class StaticAbilityContinuous {
controllerMayPlay = true;
if (params.containsKey("MayPlayWithoutManaCost")) {
mayPlayWithoutManaCost = true;
} else if (params.containsKey("MayPlayIgnoreColor")) {
mayPlayIgnoreColor = true;
}
if (params.containsKey("MayPlayWithFlash")) {
mayPlayWithFlash = true;
@@ -643,7 +641,7 @@ public final class StaticAbilityContinuous {
}
if (controllerMayPlay && (mayPlayLimit == null || hostCard.getMayPlayTurn() < mayPlayLimit)) {
Player mayPlayController = params.containsKey("MayPlayCardOwner") ? affectedCard.getOwner() : controller;
affectedCard.setMayPlay(mayPlayController, mayPlayWithoutManaCost, mayPlayIgnoreColor, mayPlayWithFlash, stAb);
affectedCard.setMayPlay(mayPlayController, mayPlayWithoutManaCost, mayPlayWithFlash, stAb);
}
//affectedCard.updateStateForView(); // FIXME: causes intolerable flickering for cards such as Thassa, God of the Sea or Wind Zendikon.

View File

@@ -80,8 +80,18 @@ public class HumanPlaySpellAbility {
final Card c = ability.getHostCard();
final CardPlayOption option = c.mayPlay(ability.getMayPlay());
final boolean manaConversion = (ability.isSpell() && (c.hasKeyword("May spend mana as though it were mana of any color to cast CARDNAME")
|| (option != null && option.isIgnoreManaCostColor())));
boolean manaTypeConversion = false;
boolean manaColorConversion = false;
if (ability.isSpell()) {
if (option != null && option.isIgnoreManaCostType()) {
manaTypeConversion = true;
} else if (c.hasKeyword("May spend mana as though it were mana of any color to cast CARDNAME")
|| (option != null && option.isIgnoreManaCostColor())) {
manaColorConversion = true;
}
}
final boolean playerManaConversion = human.hasManaConversion()
&& human.getController().confirmAction(ability, null, "Do you want to spend mana as though it were mana of any color to pay the cost?");
@@ -108,11 +118,13 @@ public class HumanPlaySpellAbility {
ability.resetPaidHash();
if (manaConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_MANA_CONVERSION);
if (manaTypeConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_TYPE_CONVERSION);
} else if (manaColorConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_COLOR_CONVERSION);
}
if (playerManaConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_MANA_CONVERSION);
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_COLOR_CONVERSION);
human.incNumManaConversion();
}
@@ -151,7 +163,7 @@ public class HumanPlaySpellAbility {
ability.getHostCard().unanimateBestow();
}
}
if (manaConversion || keywordColor) {
if (manaTypeConversion || manaColorConversion || keywordColor) {
manapool.restoreColorReplacements();
}
if (playerManaConversion) {
@@ -177,7 +189,7 @@ public class HumanPlaySpellAbility {
if (mayChooseTargets) {
clearTargets(ability);
}
if (manaConversion || keywordColor) {
if (manaTypeConversion || manaColorConversion || keywordColor) {
manapool.restoreColorReplacements();
}
}