diff --git a/forge-core/src/main/java/forge/CardStorageReader.java b/forge-core/src/main/java/forge/CardStorageReader.java index 0f99bf6b87d..72c47d78a65 100644 --- a/forge-core/src/main/java/forge/CardStorageReader.java +++ b/forge-core/src/main/java/forge/CardStorageReader.java @@ -413,6 +413,8 @@ public class CardStorageReader { return reader.readCard(lines, Files.getNameWithoutExtension(file.getName())); } catch (final FileNotFoundException ex) { throw new RuntimeException("CardReader : run error -- file not found: " + file.getPath(), ex); + } catch (final Exception ex) { + throw ex; } finally { try { assert fileInputStream != null; diff --git a/forge-core/src/main/java/forge/card/CardFace.java b/forge-core/src/main/java/forge/card/CardFace.java index 041e9251378..cfb3205c44b 100644 --- a/forge-core/src/main/java/forge/card/CardFace.java +++ b/forge-core/src/main/java/forge/card/CardFace.java @@ -87,21 +87,27 @@ final class CardFace implements ICardFace { void setInitialLoyalty(int value) { this.initialLoyalty = value; } void setPtText(String value) { - final int slashPos = value.indexOf('/'); - if (slashPos == -1) { + final String k[] = value.split("/"); + + if (k.length != 2) { throw new RuntimeException("Creature '" + this.getName() + "' has bad p/t stats"); } - boolean negPower = value.charAt(0) == '-'; - boolean negToughness = value.charAt(slashPos + 1) == '-'; - this.power = negPower ? value.substring(1, slashPos) : value.substring(0, slashPos); - this.toughness = negToughness ? value.substring(slashPos + 2) : value.substring(slashPos + 1); + this.power = k[0]; + this.toughness = k[1]; - this.iPower = StringUtils.isNumeric(this.power) ? Integer.parseInt(this.power) : 0; - this.iToughness = StringUtils.isNumeric(this.toughness) ? Integer.parseInt(this.toughness) : 0; + this.iPower = parsePT(k[0]); + this.iToughness = parsePT(k[1]); + } - if (negPower) { this.iPower *= -1; } - if (negToughness) { this.iToughness *= -1; } + static int parsePT(String val) { + // normalize PT value + if (val.contains("*")) { + val = val.replace("+*", ""); + val = val.replace("-*", ""); + val = val.replace("*", "0"); + } + return Integer.parseInt(val); } // Raw fields used for Card creation diff --git a/forge-game/src/main/java/forge/game/StaticEffect.java b/forge-game/src/main/java/forge/game/StaticEffect.java index f01c811b022..b2c925c748e 100644 --- a/forge-game/src/main/java/forge/game/StaticEffect.java +++ b/forge-game/src/main/java/forge/game/StaticEffect.java @@ -58,9 +58,6 @@ public class StaticEffect { private String chosenType; private Map mapParams = Maps.newTreeMap(); - // for P/T - private final Map originalPT = Maps.newTreeMap(); - // for types private boolean overwriteTypes = false; private boolean keepSupertype = false; @@ -101,7 +98,6 @@ public class StaticEffect { copy.xValueMap = this.xValueMap; copy.chosenType = this.chosenType; copy.mapParams = this.mapParams; - map.fillKeyedMap(copy.originalPT, this.originalPT); copy.overwriteTypes = this.overwriteTypes; copy.keepSupertype = this.keepSupertype; copy.removeSubTypes = this.removeSubTypes; @@ -345,68 +341,6 @@ public class StaticEffect { this.originalKeywords.clear(); } - // original power/toughness - /** - *

- * addOriginalPT. - *

- * - * @param c - * a {@link forge.game.card.Card} object. - * @param power - * a int. - * @param toughness - * a int. - */ - public final void addOriginalPT(final Card c, final int power, final int toughness) { - final String pt = power + "/" + toughness; - if (!this.originalPT.containsKey(c)) { - this.originalPT.put(c, pt); - } - } - - /** - *

- * getOriginalPower. - *

- * - * @param c - * a {@link forge.game.card.Card} object. - * @return a int. - */ - public final int getOriginalPower(final Card c) { - int power = -1; - if (this.originalPT.containsKey(c)) { - power = Integer.parseInt(this.originalPT.get(c).split("/")[0]); - } - return power; - } - - /** - *

- * getOriginalToughness. - *

- * - * @param c - * a {@link forge.game.card.Card} object. - * @return a int. - */ - public final int getOriginalToughness(final Card c) { - int tough = -1; - if (this.originalPT.containsKey(c)) { - tough = Integer.parseInt(this.originalPT.get(c).split("/")[1]); - } - return tough; - } - - /** - *

- * clearAllOriginalPTs. - *

- */ - public final void clearAllOriginalPTs() { - this.originalPT.clear(); - } // should we overwrite types? /** @@ -995,7 +929,7 @@ public class StaticEffect { } // remove set P/T - if (!params.containsKey("CharacteristicDefining") && setPT) { + if (setPT) { affectedCard.removeNewPT(getTimestamp()); } 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 112f22376cf..2a641dbb669 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -582,14 +582,7 @@ public final class StaticAbilityContinuous { // set P/T if (layer == StaticAbilityLayer.SETPT) { - if (params.containsKey("CharacteristicDefining")) { - if (setPower != Integer.MAX_VALUE) { - affectedCard.setBasePower(setPower); - } - if (setToughness != Integer.MAX_VALUE) { - affectedCard.setBaseToughness(setToughness); - } - } else if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) { + if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) { // non CharacteristicDefining if (setP.startsWith("AffectedX")) { setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP));