diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index db19a4a59fb..26d3b02da14 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -286,7 +286,7 @@ public final class CardEdition implements Comparable { // immutable res.foilType = FoilType.NOT_SUPPORTED; break; } - res.foilChanceInBooster = section.getInt("FoilChanceInBooster", 2143) / 10000.0F; + res.foilChanceInBooster = section.getDouble("FoilChanceInBooster", 21.43F) / 100.0F; System.out.println("chance = " + res.foilChanceInBooster); res.foilAlwaysInCommonSlot = section.getBoolean("FoilAlwaysInCommonSlot", false); diff --git a/forge-core/src/main/java/forge/util/FileSection.java b/forge-core/src/main/java/forge/util/FileSection.java index 6e3aa46337d..fba88026928 100644 --- a/forge-core/src/main/java/forge/util/FileSection.java +++ b/forge-core/src/main/java/forge/util/FileSection.java @@ -17,10 +17,15 @@ */ package forge.util; +import java.text.NumberFormat; +import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Pattern; /** @@ -113,6 +118,38 @@ public class FileSection { return lines.containsKey(keyName); } + /** + * Gets the double. + * + * @param fieldName the field name + * @return the int + */ + public double getDouble(final String fieldName) { + return this.getDouble(fieldName, 0.0F); + } + + /** + * Gets the double. + * + * @param fieldName the field name + * @param defaultValue the default value + * @return the int + */ + public double getDouble(final String fieldName, final double defaultValue) { + try { + if (this.get(fieldName) == null) { + return defaultValue; + } + + NumberFormat format = NumberFormat.getInstance(Locale.US); + Number number = format.parse(this.get(fieldName)); + + return number.doubleValue(); + } catch (final NumberFormatException | ParseException ex) { + return defaultValue; + } + } + /** * Gets the int. *