mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Move Booster Box to Editions File
This commit is contained in:
@@ -149,6 +149,7 @@ public class StaticData {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Remove these in favor of them being associated to the Edition
|
||||
/** @return {@link forge.util.storage.IStorage}<{@link forge.item.SealedProduct.Template}> */
|
||||
public IStorage<FatPack.Template> getFatPacks() {
|
||||
if (fatPacks == null)
|
||||
@@ -156,12 +157,6 @@ public class StaticData {
|
||||
return fatPacks;
|
||||
}
|
||||
|
||||
public IStorage<BoosterBox.Template> getBoosterBoxes() {
|
||||
if (boosterBoxes == null)
|
||||
boosterBoxes = new StorageBase<>("Booster boxes", new BoosterBox.Template.Reader(blockDataFolder + "boosterboxes.txt"));
|
||||
return boosterBoxes;
|
||||
}
|
||||
|
||||
/** @return {@link forge.util.storage.IStorage}<{@link forge.item.SealedProduct.Template}> */
|
||||
public final IStorage<SealedProduct.Template> getTournamentPacks() {
|
||||
if (tournaments == null)
|
||||
|
||||
@@ -143,20 +143,26 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
private Type type;
|
||||
private String name;
|
||||
private String alias = null;
|
||||
private String prerelease = null;
|
||||
private boolean whiteBorder = false;
|
||||
|
||||
// SealedProduct
|
||||
private String prerelease = null;
|
||||
private int boosterBoxCount = 36;
|
||||
|
||||
// Booster/draft info
|
||||
private boolean smallSetOverride = false;
|
||||
private boolean foilAlwaysInCommonSlot = false;
|
||||
private FoilType foilType = FoilType.NOT_SUPPORTED;
|
||||
private double foilChanceInBooster = 0;
|
||||
private boolean foilAlwaysInCommonSlot = false;
|
||||
private double chanceReplaceCommonWith = 0;
|
||||
private String slotReplaceCommonWith = "Common";
|
||||
private String additionalSheetForFoils = "";
|
||||
private String additionalUnlockSet = "";
|
||||
private boolean smallSetOverride = false;
|
||||
private String boosterMustContain = "";
|
||||
private String boosterReplaceSlotFromPrintSheet = "";
|
||||
private String[] chaosDraftThemes = new String[0];
|
||||
private String doublePickDuringDraft = "";
|
||||
private String[] chaosDraftThemes = new String[0];
|
||||
|
||||
private final ListMultimap<String, CardInSet> cardMap;
|
||||
private final Map<String, Integer> tokenNormalized;
|
||||
// custom print sheets that will be loaded lazily
|
||||
@@ -220,7 +226,10 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
public Type getType() { return type; }
|
||||
public String getName() { return name; }
|
||||
public String getAlias() { return alias; }
|
||||
|
||||
public String getPrerelease() { return prerelease; }
|
||||
public int getBoosterBoxCount() { return boosterBoxCount; }
|
||||
|
||||
public FoilType getFoilType() { return foilType; }
|
||||
public double getFoilChanceInBooster() { return foilChanceInBooster; }
|
||||
public boolean getFoilAlwaysInCommonSlot() { return foilAlwaysInCommonSlot; }
|
||||
@@ -448,6 +457,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
}
|
||||
res.type = enumType;
|
||||
res.prerelease = section.get("Prerelease", null);
|
||||
res.boosterBoxCount = Integer.parseInt(section.get("BoosterBox", "36"));
|
||||
|
||||
switch(section.get("foil", "newstyle").toLowerCase()) {
|
||||
case "notsupported":
|
||||
@@ -671,7 +681,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
private static class CanMakeBoosterBox implements Predicate<CardEdition> {
|
||||
@Override
|
||||
public boolean apply(final CardEdition subject) {
|
||||
return StaticData.instance().getBoosterBoxes().contains(subject.getCode());
|
||||
return subject.getBoosterBoxCount() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@ public class BoosterBox extends BoxedProduct {
|
||||
public static final Function<CardEdition, BoosterBox> FN_FROM_SET = new Function<CardEdition, BoosterBox>() {
|
||||
@Override
|
||||
public BoosterBox apply(final CardEdition arg1) {
|
||||
BoosterBox.Template d = StaticData.instance().getBoosterBoxes().get(arg1.getCode());
|
||||
if (arg1.getBoosterBoxCount() <= 0) {
|
||||
return null;
|
||||
}
|
||||
BoosterBox.Template d = new Template(arg1);
|
||||
if (d == null) { return null; }
|
||||
return new BoosterBox(arg1.getName(), d, d.cntBoosters);
|
||||
}
|
||||
@@ -72,40 +75,13 @@ public class BoosterBox extends BoxedProduct {
|
||||
public static class Template extends SealedProduct.Template {
|
||||
private final int cntBoosters;
|
||||
|
||||
|
||||
public int getCntBoosters() { return cntBoosters; }
|
||||
|
||||
private Template(String edition, int boosters, Iterable<Pair<String, Integer>> itrSlots)
|
||||
{
|
||||
super(edition, itrSlots);
|
||||
cntBoosters = boosters;
|
||||
private Template(CardEdition edition) {
|
||||
super(edition.getCode(), new ArrayList<>());
|
||||
cntBoosters = edition.getBoosterBoxCount();
|
||||
}
|
||||
|
||||
public static final class Reader extends StorageReaderFile<Template> {
|
||||
public Reader(String pathname) {
|
||||
super(pathname, FN_GET_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Template read(String line, int i) {
|
||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||
final String edition = headAndData[0];
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
int nBoosters = 6;
|
||||
|
||||
List<Pair<String, Integer>> slots = new ArrayList<>();
|
||||
for(String slotDesc : data) {
|
||||
String[] kv = TextUtil.split(slotDesc, ' ', 2);
|
||||
if (kv[1].startsWith("Booster"))
|
||||
nBoosters = Integer.parseInt(kv[0]);
|
||||
else
|
||||
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||
}
|
||||
|
||||
return new BoosterBox.Template(edition, nBoosters, slots);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (0 >= cntBoosters) {
|
||||
|
||||
Reference in New Issue
Block a user