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. */ /** The Basic lands. */
public static final ImmutableList<String> BASIC_LANDS = ImmutableList.of("Plains", "Island", "Swamp", "Mountain", "Forest"); 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 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("ManaColorConversion", "Additive")
.put("WhiteConversion", "All") .put("WhiteConversion", "All")
.put("BlueConversion", "All") .put("BlueConversion", "All")
.put("BlackConversion", "All") .put("BlackConversion", "All")
.put("RedConversion", "All") .put("RedConversion", "All")
.put("GreenConversion", "All") .put("GreenConversion", "All")
.put("ColorlessConversion", "All")
.build(); .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. * Private constructor to prevent instantiation.
*/ */

View File

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

View File

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

View File

@@ -140,7 +140,7 @@ public final class StaticAbilityContinuous {
List<Player> mayLookAt = null; List<Player> mayLookAt = null;
boolean controllerMayPlay = false, mayPlayWithoutManaCost = false, mayPlayIgnoreColor = false, mayPlayWithFlash = false; boolean controllerMayPlay = false, mayPlayWithoutManaCost = false, mayPlayWithFlash = false;
Integer mayPlayLimit = null; Integer mayPlayLimit = null;
//Global rules changes //Global rules changes
@@ -387,8 +387,6 @@ public final class StaticAbilityContinuous {
controllerMayPlay = true; controllerMayPlay = true;
if (params.containsKey("MayPlayWithoutManaCost")) { if (params.containsKey("MayPlayWithoutManaCost")) {
mayPlayWithoutManaCost = true; mayPlayWithoutManaCost = true;
} else if (params.containsKey("MayPlayIgnoreColor")) {
mayPlayIgnoreColor = true;
} }
if (params.containsKey("MayPlayWithFlash")) { if (params.containsKey("MayPlayWithFlash")) {
mayPlayWithFlash = true; mayPlayWithFlash = true;
@@ -643,7 +641,7 @@ public final class StaticAbilityContinuous {
} }
if (controllerMayPlay && (mayPlayLimit == null || hostCard.getMayPlayTurn() < mayPlayLimit)) { if (controllerMayPlay && (mayPlayLimit == null || hostCard.getMayPlayTurn() < mayPlayLimit)) {
Player mayPlayController = params.containsKey("MayPlayCardOwner") ? affectedCard.getOwner() : controller; 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. //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 Card c = ability.getHostCard();
final CardPlayOption option = c.mayPlay(ability.getMayPlay()); 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") boolean manaTypeConversion = false;
|| (option != null && option.isIgnoreManaCostColor()))); 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() 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?"); && 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(); ability.resetPaidHash();
if (manaConversion) { if (manaTypeConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_MANA_CONVERSION); AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_TYPE_CONVERSION);
} else if (manaColorConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_COLOR_CONVERSION);
} }
if (playerManaConversion) { if (playerManaConversion) {
AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_MANA_CONVERSION); AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_COLOR_CONVERSION);
human.incNumManaConversion(); human.incNumManaConversion();
} }
@@ -151,7 +163,7 @@ public class HumanPlaySpellAbility {
ability.getHostCard().unanimateBestow(); ability.getHostCard().unanimateBestow();
} }
} }
if (manaConversion || keywordColor) { if (manaTypeConversion || manaColorConversion || keywordColor) {
manapool.restoreColorReplacements(); manapool.restoreColorReplacements();
} }
if (playerManaConversion) { if (playerManaConversion) {
@@ -177,7 +189,7 @@ public class HumanPlaySpellAbility {
if (mayChooseTargets) { if (mayChooseTargets) {
clearTargets(ability); clearTargets(ability);
} }
if (manaConversion || keywordColor) { if (manaTypeConversion || manaColorConversion || keywordColor) {
manapool.restoreColorReplacements(); manapool.restoreColorReplacements();
} }
} }