From ea91d23bc22e4b3cb7c5574db4cdf46066b478ee Mon Sep 17 00:00:00 2001 From: Hanmac Date: Sun, 16 Apr 2017 19:30:45 +0000 Subject: [PATCH] add MayPlayIgnoreType in addition to MayPlayIgnoreColor, fixed the ignore Color part, it should not work with {C} --- .../src/main/java/forge/card/MagicColor.java | 7 +++-- .../src/main/java/forge/game/card/Card.java | 19 +++++++------- .../java/forge/game/card/CardPlayOption.java | 16 +++++++----- .../StaticAbilityContinuous.java | 6 ++--- .../forge/player/HumanPlaySpellAbility.java | 26 ++++++++++++++----- 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/forge-core/src/main/java/forge/card/MagicColor.java b/forge-core/src/main/java/forge/card/MagicColor.java index 43693ea1fc0..49e8589355f 100644 --- a/forge-core/src/main/java/forge/card/MagicColor.java +++ b/forge-core/src/main/java/forge/card/MagicColor.java @@ -144,16 +144,19 @@ public final class MagicColor { /** The Basic lands. */ public static final ImmutableList BASIC_LANDS = ImmutableList.of("Plains", "Island", "Swamp", "Mountain", "Forest"); public static final ImmutableList SNOW_LANDS = ImmutableList.of("Snow-Covered Plains", "Snow-Covered Island", "Snow-Covered Swamp", "Snow-Covered Mountain", "Snow-Covered Forest"); - public static final ImmutableMap ANY_MANA_CONVERSION = new ImmutableMap.Builder() + public static final ImmutableMap ANY_COLOR_CONVERSION = new ImmutableMap.Builder() .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 ANY_TYPE_CONVERSION = new ImmutableMap.Builder() + .putAll(ANY_COLOR_CONVERSION) + .put("ColorlessConversion", "All") + .build(); /** * Private constructor to prevent instantiation. */ diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 51a1b80b30a..67a5c011b34 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -1018,7 +1018,7 @@ public class Card extends GameEntity implements Comparable { addAmount = 0; } - if (addAmount == 0) { + if (addAmount <= 0) { return; } setTotalCountersToAdd(addAmount); @@ -2378,17 +2378,18 @@ public class Card extends GameEntity implements Comparable { } return mayPlay.get(sta); } + public final List mayPlay(final Player player) { - List result = Lists.newArrayList(); - for (CardPlayOption o : mayPlay.values()) { - if (o.getPlayer().equals(player)) { - result.add(o); - } - } + List result = Lists.newArrayList(); + for (CardPlayOption o : mayPlay.values()) { + if (o.getPlayer().equals(player)) { + result.add(o); + } + } 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); diff --git a/forge-game/src/main/java/forge/game/card/CardPlayOption.java b/forge-game/src/main/java/forge/game/card/CardPlayOption.java index 597c7c77aaa..b5d229cefaf 100644 --- a/forge-game/src/main/java/forge/game/card/CardPlayOption.java +++ b/forge-game/src/main/java/forge/game/card/CardPlayOption.java @@ -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: diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 7fb554f7a61..38f3b53185b 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -140,7 +140,7 @@ public final class StaticAbilityContinuous { List 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. diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index 8720d2e6a70..cd242886841 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -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(); } }