mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Simplify foil chance calculations, use double to represent chance.
This commit is contained in:
@@ -61,7 +61,7 @@ public class BoosterGenerator {
|
|||||||
List<PrintSheet> sheetsUsed = new ArrayList<PrintSheet>();
|
List<PrintSheet> sheetsUsed = new ArrayList<PrintSheet>();
|
||||||
|
|
||||||
CardEdition edition = StaticData.instance().getEditions().get(template.getEdition());
|
CardEdition edition = StaticData.instance().getEditions().get(template.getEdition());
|
||||||
boolean hasFoil = edition != null && MyRandom.getRandom().nextInt(10000) <= edition.getFoilChanceInBooster() && edition.getFoilType() != FoilType.NOT_SUPPORTED; // FoilChanceInBooster is given with 1/10000th precision for a closer 21.43% approximation.
|
boolean hasFoil = edition != null && MyRandom.getRandom().nextDouble() < edition.getFoilChanceInBooster() && edition.getFoilType() != FoilType.NOT_SUPPORTED;
|
||||||
boolean commonSlotFoil = !hasFoil ? false : edition.getFoilAlwaysInCommonSlot();
|
boolean commonSlotFoil = !hasFoil ? false : edition.getFoilAlwaysInCommonSlot();
|
||||||
String foilSlot = !hasFoil ? null : edition.getFoilAlwaysInCommonSlot() ? BoosterSlots.COMMON : Aggregates.random(template.getSlots()).getKey();
|
String foilSlot = !hasFoil ? null : edition.getFoilAlwaysInCommonSlot() ? BoosterSlots.COMMON : Aggregates.random(template.getSlots()).getKey();
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
private String alias = null;
|
private String alias = null;
|
||||||
private boolean whiteBorder = false;
|
private boolean whiteBorder = false;
|
||||||
private FoilType foilType = FoilType.NOT_SUPPORTED;
|
private FoilType foilType = FoilType.NOT_SUPPORTED;
|
||||||
private int foilChanceInBooster = 0;
|
private double foilChanceInBooster = 0;
|
||||||
private boolean foilAlwaysInCommonSlot = false;
|
private boolean foilAlwaysInCommonSlot = false;
|
||||||
private final CardInSet[] cards;
|
private final CardInSet[] cards;
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
public String getAlias() { return alias; }
|
public String getAlias() { return alias; }
|
||||||
public FoilType getFoilType() { return foilType; }
|
public FoilType getFoilType() { return foilType; }
|
||||||
public int getFoilChanceInBooster() { return foilChanceInBooster; }
|
public double getFoilChanceInBooster() { return foilChanceInBooster; }
|
||||||
public boolean getFoilAlwaysInCommonSlot() { return foilAlwaysInCommonSlot; }
|
public boolean getFoilAlwaysInCommonSlot() { return foilAlwaysInCommonSlot; }
|
||||||
public CardInSet[] getCards() { return cards; }
|
public CardInSet[] getCards() { return cards; }
|
||||||
|
|
||||||
@@ -286,7 +286,8 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
res.foilType = FoilType.NOT_SUPPORTED;
|
res.foilType = FoilType.NOT_SUPPORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res.foilChanceInBooster = section.getInt("FoilChanceInBooster", 2143); // uses 1:10000 precision, 21.43% is roughly every 70th card foiled
|
res.foilChanceInBooster = section.getInt("FoilChanceInBooster", 2143) / 10000.0F;
|
||||||
|
System.out.println("chance = " + res.foilChanceInBooster);
|
||||||
res.foilAlwaysInCommonSlot = section.getBoolean("FoilAlwaysInCommonSlot", false);
|
res.foilAlwaysInCommonSlot = section.getBoolean("FoilAlwaysInCommonSlot", false);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user