From a8fa17603ace14252f5e96196af20ca89f17ef8f Mon Sep 17 00:00:00 2001 From: Pahimar Date: Fri, 13 May 2016 23:49:12 -0400 Subject: [PATCH] Documenting stuff so I don't forget what things do --- .../ee3/exchange/NewEnergyValueRegistry.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/pahimar/ee3/exchange/NewEnergyValueRegistry.java b/src/main/java/com/pahimar/ee3/exchange/NewEnergyValueRegistry.java index 12156509..cab9bcbe 100644 --- a/src/main/java/com/pahimar/ee3/exchange/NewEnergyValueRegistry.java +++ b/src/main/java/com/pahimar/ee3/exchange/NewEnergyValueRegistry.java @@ -16,15 +16,20 @@ import org.apache.logging.log4j.MarkerManager; import java.io.File; import java.io.FileNotFoundException; import java.util.Map; +import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; public class NewEnergyValueRegistry { public static final NewEnergyValueRegistry INSTANCE = new NewEnergyValueRegistry(); private ImmutableSortedMap energyValueMap; + + // TODO Should we have API values and files loaded from file as separate maps (runtime vs file) private final Map preCalculationValueMap; private final Map postCalculationValueMap; + private transient SortedSet uncomputedStacks; public static File energyValuesDirectory; public static File energyValuesFile; @@ -117,6 +122,33 @@ public class NewEnergyValueRegistry { } } + public void compute() { + + // TODO Should we load in values from file? + + // Initialize the "working copy" energy value map + TreeMap stackValueMap = new TreeMap<>(); + uncomputedStacks = new TreeSet<>(); + + // Add in all pre-calculation energy value mappings + // TODO Should we be extra vigilant about possible nulls here? + stackValueMap.putAll(preCalculationValueMap); + + // Calculate values from the known methods to create items, and the pre-calculation value mappings + // TODO Re-implement DynEMC here + + // Add in all post-calculation energy value mappings + // TODO Should we be extra vigilant about possible nulls here? + stackValueMap.putAll(postCalculationValueMap); + + // Bake the final calculated energy value map + ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); + stackMappingsBuilder.putAll(stackValueMap); + energyValueMap = stackMappingsBuilder.build(); + + // TODO Should we save the results to file now? + } + /** * Saves the pre-calculation, post-calculation, and calculated energy value maps to disk */ @@ -135,14 +167,12 @@ public class NewEnergyValueRegistry { public void load() { try { - preCalculationValueMap.clear(); preCalculationValueMap.putAll(SerializationHelper.readFromJsonFile(preCalculationValuesFile)); } catch (FileNotFoundException e) { // TODO Log that no pre-calculation values were loaded from file because file wasn't found } try { - postCalculationValueMap.clear(); postCalculationValueMap.putAll(SerializationHelper.readFromJsonFile(postCalculationValuesFile)); } catch (FileNotFoundException e) { // TODO Log that no pre-calculation values were loaded from file because file wasn't found