mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
- Read the foil chance in booster value from edition files as a US locale double.
This commit is contained in:
@@ -286,7 +286,7 @@ public final class CardEdition implements Comparable<CardEdition> { // 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);
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user