HJSON conversion cleanup

- Altered format and set definition files to be true hjson files.
- Altered the loading of set and format definitions to conform with existing POJO-based deserialization
- Replaced a lot of stupid "has flag" string-based field lookup that could just be a field on the set definition
- Seems to compile and run, but there's a possibility I missed something and changes here depend on as-yet unchecked-in code to soon follow
This commit is contained in:
Christian 'ketura' McCarty
2023-07-06 03:04:32 -05:00
parent 0537ac7703
commit 0d3d9b568f
14 changed files with 1168 additions and 954 deletions

View File

@@ -43,7 +43,7 @@ public class CreateCardStubs {
Map<String, Map<String, LotroCardBlueprint>> cardsByFileName = new HashMap<>();
SetDefinition setDefinition = library.getSetDefinitions().get("" + set);
if (setDefinition.hasFlag("needsLoading")) {
if (setDefinition.NeedsLoading()) {
final Set<String> allCards = setDefinition.getAllCards();
for (String blueprintId : allCards) {
blueprintId = stripBlueprintModifiers(blueprintId);

File diff suppressed because it is too large Load Diff

View File

@@ -1,553 +1,553 @@
[
{
setId: "0",
setName: "Promotional",
rarityFile: "/set0-rarity.txt",
setId: 0
setName: Promotional
rarityFile: /set0-rarity.txt
needsLoading: false
}
{
setId: "1",
setName: "The Fellowship of the Ring",
rarityFile: "/set1-rarity.txt",
setId: 1
setName: The Fellowship of the Ring
rarityFile: /set1-rarity.txt
needsLoading: false
}
{
setId: "2",
setName: "Mines of Moria",
rarityFile: "/set2-rarity.txt"
setId: 2
setName: Mines of Moria
rarityFile: /set2-rarity.txt
}
{
setId: "3",
setName: "Realms of the Elf-lords",
rarityFile: "/set3-rarity.txt"
setId: 3
setName: Realms of the Elf-lords
rarityFile: /set3-rarity.txt
}
{
setId: "4",
setName: "The Two Towers",
rarityFile: "/set4-rarity.txt"
setId: 4
setName: The Two Towers
rarityFile: /set4-rarity.txt
}
{
setId: "5",
setName: "Battle of Helm's Deep",
rarityFile: "/set5-rarity.txt"
setId: 5
setName: Battle of Helm's Deep
rarityFile: /set5-rarity.txt
}
{
setId: "6",
setName: "Ents of Fangorn",
rarityFile: "/set6-rarity.txt"
setId: 6
setName: Ents of Fangorn
rarityFile: /set6-rarity.txt
}
{
setId: "7",
setName: "The Return of the King",
rarityFile: "/set7-rarity.txt"
setId: 7
setName: The Return of the King
rarityFile: /set7-rarity.txt
}
{
setId: "8",
setName: "Siege of Gondor",
rarityFile: "/set8-rarity.txt"
setId: 8
setName: Siege of Gondor
rarityFile: /set8-rarity.txt
}
{
setId: "9",
setName: "Reflections",
rarityFile: "/set9-rarity.txt",
setId: 9
setName: Reflections
rarityFile: /set9-rarity.txt
needsLoading: false
}
{
setId: "10",
setName: "Mount Doom",
rarityFile: "/set10-rarity.txt"
setId: 10
setName: Mount Doom
rarityFile: /set10-rarity.txt
}
{
setId: "11",
setName: "Shadows",
rarityFile: "/set11-rarity.txt"
setId: 11
setName: Shadows
rarityFile: /set11-rarity.txt
}
{
setId: "12",
setName: "Black Rider",
rarityFile: "/set12-rarity.txt"
setId: 12
setName: Black Rider
rarityFile: /set12-rarity.txt
}
{
setId: "13",
setName: "Bloodlines",
rarityFile: "/set13-rarity.txt"
setId: 13
setName: Bloodlines
rarityFile: /set13-rarity.txt
}
{
setId: "14",
setName: "Expanded Middle-earth",
rarityFile: "/set14-rarity.txt",
setId: 14
setName: Expanded Middle-earth
rarityFile: /set14-rarity.txt
needsLoading: false
}
{
setId: "15",
setName: "The Hunters",
rarityFile: "/set15-rarity.txt"
setId: 15
setName: The Hunters
rarityFile: /set15-rarity.txt
}
{
setId: "16",
setName: "The Wraith Collection",
rarityFile: "/set16-rarity.txt",
setId: 16
setName: The Wraith Collection
rarityFile: /set16-rarity.txt
needsLoading: false
}
{
setId: "17",
setName: "Rise of Saruman",
rarityFile: "/set17-rarity.txt"
setId: 17
setName: Rise of Saruman
rarityFile: /set17-rarity.txt
}
{
setId: "18",
setName: "Treachery & Deceit",
rarityFile: "/set18-rarity.txt"
setId: 18
setName: Treachery & Deceit
rarityFile: /set18-rarity.txt
}
{
setId: "19",
setName: "Ages End",
rarityFile: "/set19-rarity.txt",
setId: 19
setName: Ages End
rarityFile: /set19-rarity.txt
needsLoading: false
}
{
setId: "30",
setName: "Main Deck",
rarityFile: "/set30-rarity.txt",
originalSet: false,
merchantable: false,
setId: 30
setName: Main Deck
rarityFile: /set30-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
}
{
setId: "31",
setName: "The Short Rest",
rarityFile: "/set31-rarity.txt",
originalSet: false,
merchantable: false,
setId: 31
setName: The Short Rest
rarityFile: /set31-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
}
{
setId: "32",
setName: "The Clouds Burst",
rarityFile: "/set32-rarity.txt",
originalSet: false,
merchantable: false,
setId: 32
setName: The Clouds Burst
rarityFile: /set32-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
}
{
setId: "33",
setName: "Fire and Water",
rarityFile: "/set33-rarity.txt",
originalSet: false,
merchantable: false,
setId: 33
setName: Fire and Water
rarityFile: /set33-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
}
{
setId: "40",
setName: "Second Edition",
rarityFile: "/set40-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 40
setName: Second Edition
rarityFile: /set40-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: false
}
{
setId: "50",
setName: "PC Promo Errata",
rarityFile: "/errata/set50-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 50
setName: PC Promo Errata
rarityFile: /errata/set50-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "51",
setName: "PC FotR Errata",
rarityFile: "/errata/set51-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 51
setName: PC FotR Errata
rarityFile: /errata/set51-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "52",
setName: "PC MoM Errata",
rarityFile: "/errata/set52-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 52
setName: PC MoM Errata
rarityFile: /errata/set52-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "53",
setName: "PC RotEL Errata",
rarityFile: "/errata/set53-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 53
setName: PC RotEL Errata
rarityFile: /errata/set53-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "54",
setName: "PC TTT Errata",
rarityFile: "/errata/set54-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 54
setName: PC TTT Errata
rarityFile: /errata/set54-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "55",
setName: "PC BoHD Errata",
rarityFile: "/errata/set55-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 55
setName: PC BoHD Errata
rarityFile: /errata/set55-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "56",
setName: "PC EoF Errata",
rarityFile: "/errata/set56-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 56
setName: PC EoF Errata
rarityFile: /errata/set56-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "57",
setName: "PC RotK Errata",
rarityFile: "/errata/set57-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 57
setName: PC RotK Errata
rarityFile: /errata/set57-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "58",
setName: "PC SoG Errata",
rarityFile: "/errata/set58-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 58
setName: PC SoG Errata
rarityFile: /errata/set58-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "59",
setName: "PC Reflections Errata",
rarityFile: "/errata/set59-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 59
setName: PC Reflections Errata
rarityFile: /errata/set59-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "80",
setName: "PC MD Errata",
rarityFile: "/errata/set80-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 80
setName: PC MD Errata
rarityFile: /errata/set80-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "81",
setName: "PC Shadows Errata",
rarityFile: "/errata/set81-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 81
setName: PC Shadows Errata
rarityFile: /errata/set81-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "82",
setName: "PC BR Errata",
rarityFile: "/errata/set82-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 82
setName: PC BR Errata
rarityFile: /errata/set82-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "83",
setName: "PC Bloodlines Errata",
rarityFile: "/errata/set83-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 83
setName: PC Bloodlines Errata
rarityFile: /errata/set83-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "84",
setName: "PC EMM Errata",
rarityFile: "/errata/set84-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 84
setName: PC EMM Errata
rarityFile: /errata/set84-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "85",
setName: "PC Hunters Errata",
rarityFile: "/errata/set85-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 85
setName: PC Hunters Errata
rarityFile: /errata/set85-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "86",
setName: "PC TWC Errata",
rarityFile: "/errata/set86-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 86
setName: PC TWC Errata
rarityFile: /errata/set86-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "87",
setName: "PC RoS Errata",
rarityFile: "/errata/set87-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 87
setName: PC RoS Errata
rarityFile: /errata/set87-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "88",
setName: "PC T&D Errata",
rarityFile: "/errata/set88-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 88
setName: PC T&D Errata
rarityFile: /errata/set88-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "89",
setName: "PC AE Errata",
rarityFile: "/errata/set89-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 89
setName: PC AE Errata
rarityFile: /errata/set89-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "70",
setName: "TEST-PC Promo Errata",
rarityFile: "/errata/set70-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 70
setName: TEST-PC Promo Errata
rarityFile: /errata/set70-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "71",
setName: "TEST-PC FotR Errata",
rarityFile: "/errata/set71-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 71
setName: TEST-PC FotR Errata
rarityFile: /errata/set71-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "72",
setName: "TEST-PC MoM Errata",
rarityFile: "/errata/set72-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 72
setName: TEST-PC MoM Errata
rarityFile: /errata/set72-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "73",
setName: "TEST-PC RotEL Errata",
rarityFile: "/errata/set73-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 73
setName: TEST-PC RotEL Errata
rarityFile: /errata/set73-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "74",
setName: "TEST-PC TTT Errata",
rarityFile: "/errata/set74-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 74
setName: TEST-PC TTT Errata
rarityFile: /errata/set74-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "75",
setName: "TEST-PC BoHD Errata",
rarityFile: "/errata/set75-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 75
setName: TEST-PC BoHD Errata
rarityFile: /errata/set75-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "76",
setName: "TEST-PC EoF Errata",
rarityFile: "/errata/set76-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 76
setName: TEST-PC EoF Errata
rarityFile: /errata/set76-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "77",
setName: "TEST-PC RotK Errata",
rarityFile: "/errata/set77-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 77
setName: TEST-PC RotK Errata
rarityFile: /errata/set77-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "78",
setName: "TEST-PC SoG Errata",
rarityFile: "/errata/set78-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 78
setName: TEST-PC SoG Errata
rarityFile: /errata/set78-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "79",
setName: "TEST-PC Reflections Errata",
rarityFile: "/errata/set79-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 79
setName: TEST-PC Reflections Errata
rarityFile: /errata/set79-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "80",
setName: "TEST-PC MD Errata",
rarityFile: "/errata/set80-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 80
setName: TEST-PC MD Errata
rarityFile: /errata/set80-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "81",
setName: "TEST-PC Shadows Errata",
rarityFile: "/errata/set81-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 81
setName: TEST-PC Shadows Errata
rarityFile: /errata/set81-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "82",
setName: "TEST-PC BR Errata",
rarityFile: "/errata/set82-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 82
setName: TEST-PC BR Errata
rarityFile: /errata/set82-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "83",
setName: "TEST-PC Bloodlines Errata",
rarityFile: "/errata/set83-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 83
setName: TEST-PC Bloodlines Errata
rarityFile: /errata/set83-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "84",
setName: "TEST-PC EMM Errata",
rarityFile: "/errata/set84-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 84
setName: TEST-PC EMM Errata
rarityFile: /errata/set84-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "85",
setName: "TEST-PC Hunters Errata",
rarityFile: "/errata/set85-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 85
setName: TEST-PC Hunters Errata
rarityFile: /errata/set85-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "86",
setName: "TEST-PC TWC Errata",
rarityFile: "/errata/set86-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 86
setName: TEST-PC TWC Errata
rarityFile: /errata/set86-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "87",
setName: "TEST-PC RoS Errata",
rarityFile: "/errata/set87-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 87
setName: TEST-PC RoS Errata
rarityFile: /errata/set87-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "88",
setName: "TEST-PC T&D Errata",
rarityFile: "/errata/set88-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 88
setName: TEST-PC T&D Errata
rarityFile: /errata/set88-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "89",
setName: "TEST-PC AE Errata",
rarityFile: "/errata/set89-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 89
setName: TEST-PC AE Errata
rarityFile: /errata/set89-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "100",
setName: "PC Supplements",
rarityFile: "/set100-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 100
setName: PC Supplements
rarityFile: /set100-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "101",
setName: "Shadow of the Past",
rarityFile: "/set101-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 101
setName: Shadow of the Past
rarityFile: /set101-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "150",
setName: "TEST-PC Supplements",
rarityFile: "/set150-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 150
setName: TEST-PC Supplements
rarityFile: /set150-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}
{
setId: "151",
setName: "TEST-Shadow of the Past",
rarityFile: "/set151-rarity.txt",
originalSet: false,
merchantable: false,
needsLoading: false,
setId: 151
setName: TEST-Shadow of the Past
rarityFile: /set151-rarity.txt
originalSet: false
merchantable: false
needsLoading: false
playable: true
}

View File

@@ -61,6 +61,16 @@ public class JSONDefs {
}
public static class Set {
public int setId;
public String setName;
public String rarityFile;
public boolean originalSet = true;
public boolean merchantable = true;
public boolean needsLoading = true;
public boolean playable = true;
}
public static class FullFormatReadout {
public Map<String, Format> Formats;
public Map<String, SealedTemplate> SealedTemplates;

View File

@@ -11,7 +11,6 @@ import com.gempukku.util.JsonUtils;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.hjson.JsonValue;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
@@ -135,34 +134,24 @@ public class LotroCardBlueprintLibrary {
try {
final InputStreamReader reader = new InputStreamReader(new FileInputStream(_setDefsPath), StandardCharsets.UTF_8);
try {
String json = JsonValue.readHjson(reader).toString();
JSONParser parser = new JSONParser();
JSONArray object = (JSONArray) parser.parse(json);
for (Object setDefinitionObj : object) {
JSONObject setDefinition = (JSONObject) setDefinitionObj;
var setDefs = JsonUtils.ConvertArray(reader, JSONDefs.Set.class);
String setId = (String) setDefinition.get("setId");
String setName = (String) setDefinition.get("setName");
String rarityFile = (String) setDefinition.get("rarityFile");
for (JSONDefs.Set def : setDefs) {
if (def == null)
continue;
Set<String> flags = new HashSet<>();
determineOriginalSetFlag(setDefinition, flags);
determineMerchantableFlag(setDefinition, flags);
determineNeedsLoadingFlag(setDefinition, flags);
DefaultSetDefinition rarity = new DefaultSetDefinition(setId, setName, flags);
readSetRarityFile(rarity, setId, rarityFile);
_allSets.put(setId, rarity);
var set = new DefaultSetDefinition(def);
readSetRarityFile(set, set.getSetId(), def.rarityFile);
_allSets.put(set.getSetId(), set);
}
} finally {
IOUtils.closeQuietly(reader);
}
} catch (ParseException e) {
throw new RuntimeException("Unable to parse setConfig.json file");
} catch (IOException exp) {
throw new RuntimeException("Unable to read card rarities: " + exp);
} catch (Exception exp) {
throw new RuntimeException("Unable to parse setConfig.hjson file: " + exp);
}
}
@@ -235,20 +224,21 @@ public class LotroCardBlueprintLibrary {
}
private void cacheAllJavaBlueprints() {
for (SetDefinition setDefinition : _allSets.values()) {
if (setDefinition.hasFlag("needsLoading")) {
logger.debug("Loading Java cards for set " + setDefinition.getSetId());
final Set<String> allCards = setDefinition.getAllCards();
for (String blueprintId : allCards) {
if (getBaseBlueprintId(blueprintId).equals(blueprintId)) {
if (!_blueprints.containsKey(blueprintId)) {
try {
// Ensure it's loaded
LotroCardBlueprint blueprint = findJavaBlueprint(blueprintId);
_blueprints.put(blueprintId, blueprint);
} catch (CardNotFoundException exp) {
throw new RuntimeException("Unable to start the server, due to invalid (missing) card definition - " + blueprintId);
}
for (var setDef : _allSets.values()) {
if(!setDef.NeedsLoading())
continue;
logger.debug("Loading Java cards for set " + setDef.getSetId());
final Set<String> allCards = setDef.getAllCards();
for (String blueprintId : allCards) {
if (getBaseBlueprintId(blueprintId).equals(blueprintId)) {
if (!_blueprints.containsKey(blueprintId)) {
try {
// Ensure it's loaded
LotroCardBlueprint blueprint = findJavaBlueprint(blueprintId);
_blueprints.put(blueprintId, blueprint);
} catch (CardNotFoundException exp) {
throw new RuntimeException("Unable to start the server, due to invalid (missing) card definition - " + blueprintId);
}
}
}

View File

@@ -1,24 +1,31 @@
package com.gempukku.lotro.game.packs;
import com.gempukku.lotro.common.JSONDefs;
import java.util.*;
public class DefaultSetDefinition implements SetDefinition {
private final List<String> _tengwarCards = new LinkedList<>();
private final Map<String, List<String>> _rarityList = new HashMap<>();
private final Map<String, String> _cardsRarity = new LinkedHashMap<>();
private final String _setId;
private final String _setName;
private final Set<String> _flags;
public DefaultSetDefinition(String setId, String setName, Set<String> flags) {
_setId = setId;
_setName = setName;
_flags = flags;
public final String ID;
public final String Name;
public final boolean IsDecipherSet;
public final boolean Merchantable;
public final boolean NeedsLoading;
public DefaultSetDefinition(JSONDefs.Set setdef) {
ID = String.valueOf(setdef.setId);
Name = setdef.setName;
IsDecipherSet = setdef.originalSet;
Merchantable = setdef.merchantable;;
NeedsLoading = setdef.needsLoading;;
}
public void addCard(String blueprintId, String rarity) {
_cardsRarity.put(blueprintId, rarity);
List<String> cardsOfRarity = _rarityList.get(rarity);
var cardsOfRarity = _rarityList.get(rarity);
if (cardsOfRarity == null) {
cardsOfRarity = new LinkedList<>();
_rarityList.put(rarity, cardsOfRarity);
@@ -32,18 +39,20 @@ public class DefaultSetDefinition implements SetDefinition {
@Override
public String getSetName() {
return _setName;
return Name;
}
@Override
public String getSetId() {
return _setId;
return ID;
}
@Override
public boolean hasFlag(String flag) {
return _flags.contains(flag);
}
public boolean IsDecipherSet() { return IsDecipherSet; };
@Override
public boolean Merchantable() { return Merchantable; };
@Override
public boolean NeedsLoading() { return NeedsLoading; };
@Override
public List<String> getCardsOfRarity(String rarity) {

View File

@@ -8,8 +8,9 @@ public interface SetDefinition {
public String getSetId();
public boolean hasFlag(String flag);
public boolean IsDecipherSet();
public boolean Merchantable();
public boolean NeedsLoading();
public List<String> getCardsOfRarity(String rarity);
public List<String> getTengwarCards();

View File

@@ -1,6 +1,5 @@
package com.gempukku.lotro.game.formats;
import com.alibaba.fastjson.JSON;
import com.gempukku.lotro.common.AppConfig;
import com.gempukku.lotro.common.JSONDefs;
import com.gempukku.lotro.game.AdventureLibrary;
@@ -8,8 +7,6 @@ import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.league.SealedLeagueDefinition;
import com.gempukku.util.JsonUtils;
import org.hjson.JsonValue;
import org.json.simple.parser.JSONParser;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -72,7 +69,6 @@ public class LotroFormatLibrary {
private void loadTemplateFromFile(File file) {
if (!JsonUtils.IsValidHjsonFile(file))
return;
JSONParser parser = new JSONParser();
try (Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
var defs = JsonUtils.ConvertArray(reader, JSONDefs.SealedTemplate.class);
@@ -108,9 +104,7 @@ public class LotroFormatLibrary {
public void ReloadFormats() {
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(_formatPath), StandardCharsets.UTF_8)) {
collectionReady.acquire();
String json = JsonValue.readHjson(reader).toString();
JSONDefs.Format[] formatDefs = JSON.parseObject(json, JSONDefs.Format[].class);
var formatDefs = JsonUtils.ConvertArray(reader, JSONDefs.Format.class);
_allFormats.clear();
_hallFormats.clear();
@@ -119,7 +113,7 @@ public class LotroFormatLibrary {
if (def == null)
continue;
DefaultLotroFormat format = new DefaultLotroFormat(_adventureLibrary, _cardLibrary, def);
var format = new DefaultLotroFormat(_adventureLibrary, _cardLibrary, def);
_allFormats.put(format.getCode(), format);
if (format.hallVisible()) {

View File

@@ -19,7 +19,7 @@ public class FixedLeaguePrizes implements LeaguePrizes {
public FixedLeaguePrizes(LotroCardBlueprintLibrary library) {
for (SetDefinition setDefinition : library.getSetDefinitions().values()) {
if (setDefinition.hasFlag("originalSet")) {
if (setDefinition.IsDecipherSet()) {
_commons.addAll(setDefinition.getCardsOfRarity("C"));
_uncommons.addAll(setDefinition.getCardsOfRarity("U"));
_rares.addAll(setDefinition.getCardsOfRarity("R"));

View File

@@ -33,7 +33,7 @@ public class MerchantService {
_merchant = new RarityBasedMerchant(library);
for (SetDefinition setDefinition : library.getSetDefinitions().values()) {
if (setDefinition.hasFlag("merchantable")) {
if (setDefinition.Merchantable()) {
for (String blueprintId : setDefinition.getAllCards()) {
String baseBlueprintId = library.getBaseBlueprintId(blueprintId);
_merchantableItems.add(new BasicCardItem(baseBlueprintId));

View File

@@ -12,7 +12,7 @@ public class RarityBasedMerchant implements Merchant {
public RarityBasedMerchant(LotroCardBlueprintLibrary library) {
for (SetDefinition setDefinition : library.getSetDefinitions().values()) {
if (setDefinition.hasFlag("merchantable"))
if (setDefinition.Merchantable())
_rarity.put(setDefinition.getSetId(), setDefinition);
}
}

View File

@@ -38,7 +38,7 @@ public class StorageBasedMerchant implements Merchant {
_merchantDao = merchantDao;
_merchantSetupDate = merchantSetupDate;
for (SetDefinition setDefinition : _library.getSetDefinitions().values()) {
if (setDefinition.hasFlag("merchantable"))
if (setDefinition.Merchantable())
_rarity.put(setDefinition.getSetId(), setDefinition);
}
}

View File

@@ -17,7 +17,7 @@ public class DailyTournamentPrizes implements TournamentPrizes {
public DailyTournamentPrizes(LotroCardBlueprintLibrary library, String registryRepresentation) {
_registryRepresentation = registryRepresentation;
for (SetDefinition setDefinition : library.getSetDefinitions().values()) {
if (setDefinition.hasFlag("originalSet"))
if (setDefinition.IsDecipherSet())
_promos.addAll(setDefinition.getCardsOfRarity("P"));
}
}

View File

@@ -17,7 +17,7 @@ public class SingleEliminationOnDemandPrizes implements TournamentPrizes{
public SingleEliminationOnDemandPrizes(LotroCardBlueprintLibrary library, String registryRepresentation) {
_registryRepresentation = registryRepresentation;
for (SetDefinition setDefinition : library.getSetDefinitions().values()) {
if (setDefinition.hasFlag("originalSet"))
if (setDefinition.IsDecipherSet())
_promos.addAll(setDefinition.getCardsOfRarity("P"));
}
}