From bda9baa4fcbbd83cd03f149f9de09a1722a4cce6 Mon Sep 17 00:00:00 2001 From: Agetian Date: Sat, 1 Oct 2016 06:08:20 +0000 Subject: [PATCH] - Trying to fix cards like Back from the Brink and Merseine resulting from incorrect copying of mana costs with \EnchantedCost or \Exiled restrictions. - This is a hack, not sure if it works well enough and doesn't break anything, there's probably a better and more elegant way to fix this, please review. --- forge-game/src/main/java/forge/game/cost/Cost.java | 2 +- .../src/main/java/forge/game/cost/CostPartMana.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/forge-game/src/main/java/forge/game/cost/Cost.java b/forge-game/src/main/java/forge/game/cost/Cost.java index 76ea5a80f5d..6b9f58b717b 100644 --- a/forge-game/src/main/java/forge/game/cost/Cost.java +++ b/forge-game/src/main/java/forge/game/cost/Cost.java @@ -764,7 +764,7 @@ public class Cost { String r1 = ((CostPartMana) part).getRestiction(); String r = r1 == null ? r2 : ( r2 == null ? r1 : r1 + "." + r2); costParts.remove(costPart2); - costParts.add(0, new CostPartMana(oldManaCost.toManaCost(), r)); + costParts.add(0, new CostPartMana(oldManaCost.toManaCost(), r, ((CostPartMana)part).isExiledCreatureCost(), ((CostPartMana)part).isEnchantedCreatureCost())); } else if (part instanceof CostDiscard || part instanceof CostTapType) { boolean alreadyAdded = false; for (final CostPart other : costParts) { diff --git a/forge-game/src/main/java/forge/game/cost/CostPartMana.java b/forge-game/src/main/java/forge/game/cost/CostPartMana.java index d0e6281b0c0..63803399826 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPartMana.java +++ b/forge-game/src/main/java/forge/game/cost/CostPartMana.java @@ -49,6 +49,15 @@ public class CostPartMana extends CostPart { this.restriction = xCantBe0 || isExiledCreatureCost || isEnchantedCreatureCost? null : restriction; } + // This version of the constructor allows to explicitly set exiledCreatureCost/enchantedCreatureCost, used only when copying costs + public CostPartMana(final ManaCost cost, String restriction, boolean exiledCreatureCost, boolean enchantedCreatureCost) { + this.cost = cost; + this.xCantBe0 = "XCantBe0".equals(restriction); + this.isExiledCreatureCost = exiledCreatureCost; + this.isEnchantedCreatureCost = enchantedCreatureCost; + this.restriction = xCantBe0 || isExiledCreatureCost || isEnchantedCreatureCost? null : restriction; + } + /** * Gets the mana. *