add building summary
parent
d872dd2b54
commit
e6559760aa
|
|
@ -204,7 +204,6 @@ public class Test {
|
|||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// ref.put(Database.CircuitBoard, 15.0);
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(LISTS + name + "_java.txt"))) {
|
||||
String list = plan.getMap().entrySet().stream().map(item ->
|
||||
"ref.put(Database." + name2(item.getKey().getName()) + ", " + item.getValue() + ");"
|
||||
|
|
@ -213,6 +212,12 @@ public class Test {
|
|||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(LISTS + name + "_buildings.txt"))) {
|
||||
String list = SumResult.format(plan.getBuildings());
|
||||
bw.write(list);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> unlocks(String... unlock) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public class Recipe {
|
|||
private final Map<Item, Double> inputs;
|
||||
private final Map<Item, Double> outputs;
|
||||
private final int duration;
|
||||
private final Class<? extends Building> building;
|
||||
private boolean isHandCraftable = true;
|
||||
private String name;
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ public class Recipe {
|
|||
this.duration = duration;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
this.building = building;
|
||||
}
|
||||
|
||||
public Recipe(int duration, String name, boolean isHandCraftable, Class<? extends Building> building) {
|
||||
|
|
@ -238,4 +240,15 @@ public class Recipe {
|
|||
return new SumResult(production, map);
|
||||
}
|
||||
|
||||
public Class<? extends Building> getBuilding() {
|
||||
return building;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getOutputs() {
|
||||
return outputs.keySet().stream().map(Item::getName).collect(Collectors.joining(" + "));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package satisfactory.items;
|
|||
|
||||
import org.jgrapht.Graph;
|
||||
import org.jgrapht.graph.DefaultDirectedWeightedGraph;
|
||||
import satisfactory.buildings.Building;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -76,4 +77,35 @@ public class SumResult {
|
|||
other.map.forEach((item, aDouble) -> map.merge(item, aDouble, Double::sum));
|
||||
return new SumResult(merge(production, other.getProduction()), map);
|
||||
}
|
||||
|
||||
public Map<Class<? extends Building>, Map<Recipe, Double>> getBuildings() {
|
||||
Map<Class<? extends Building>, Map<Recipe, Double>> buildings = new HashMap<>();
|
||||
for (Item item : production.vertexSet()) {
|
||||
double n = 0.0;
|
||||
for (ProductionEdge edge : production.outgoingEdgesOf(item)) {
|
||||
n += edge.getInstances();
|
||||
}
|
||||
Recipe recipe = item.getRecipe();
|
||||
Class<? extends Building> building = recipe.getBuilding();
|
||||
|
||||
HashMap<Recipe, Double> value = (HashMap<Recipe, Double>) buildings.getOrDefault(building, new HashMap<>());
|
||||
value.put(recipe, value.getOrDefault(recipe, 0.0) + n);
|
||||
buildings.put(building, value);
|
||||
}
|
||||
return buildings;
|
||||
}
|
||||
|
||||
public static String format(Map<Class<? extends Building>, Map<Recipe, Double>> buildings){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<Class<? extends Building>, Map<Recipe, Double>> entry : buildings.entrySet()) {
|
||||
double sum = 0.0;
|
||||
StringBuilder internal = new StringBuilder();
|
||||
for (Map.Entry<Recipe, Double> recipes : entry.getValue().entrySet()) {
|
||||
sum += Math.ceil(recipes.getValue());
|
||||
internal.append("\t").append(recipes.getKey().getName()).append(" (").append(recipes.getKey().getOutputs()).append(")\t").append(recipes.getValue()).append("\n");
|
||||
}
|
||||
sb.append(entry.getKey().getName().replace("satisfactory.buildings.production.","")). append("\t"). append(sum).append("\n").append(internal);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue