reformat & code cleanup
parent
6bb38066d6
commit
ea30ec2b6b
10
build.gradle
10
build.gradle
|
|
@ -10,13 +10,13 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.2'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
|
||||
implementation 'org.jgrapht:jgrapht-io:1.5.1'
|
||||
implementation 'guru.nidi:graphviz-java:0.18.1'
|
||||
implementation 'org.graalvm.js:js:20.0.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.13.0'
|
||||
implementation 'org.graalvm.js:js:22.1.0.1'
|
||||
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.2'
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class Database {
|
|||
Water.setPreference(water);
|
||||
|
||||
// gases
|
||||
NitrogenGas.add(new Recipe(1,"pressure thingy", false, ResourceWellExtractor.class));
|
||||
NitrogenGas.add(new Recipe(1, "pressure thingy", false, ResourceWellExtractor.class));
|
||||
}
|
||||
{
|
||||
// Steel Ingot
|
||||
|
|
@ -496,72 +496,72 @@ public class Database {
|
|||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(6, Refinery.class);
|
||||
recipe.addInput(Sulfur,5);
|
||||
recipe.addInput(Water,5);
|
||||
recipe.addInput(Sulfur, 5);
|
||||
recipe.addInput(Water, 5);
|
||||
recipe.addOutput(SulfuricAcid, 5);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(150,Manufacturer.class);
|
||||
Recipe recipe = new Recipe(150, Manufacturer.class);
|
||||
recipe.addInput(EncasedUraniumCell, 50);
|
||||
recipe.addInput(EncasedIndustrialBeam,3);
|
||||
recipe.addInput(EncasedIndustrialBeam, 3);
|
||||
recipe.addInput(ElectromagneticControlRod, 5);
|
||||
recipe.addOutput(UraniumFuelRod,1);
|
||||
recipe.addOutput(UraniumFuelRod, 1);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(12, Blender.class);
|
||||
recipe.addInput(Uranium, 10);
|
||||
recipe.addInput(Concrete,3);
|
||||
recipe.addInput(Concrete, 3);
|
||||
recipe.addInput(SulfuricAcid, 8);
|
||||
recipe.addOutput(EncasedUraniumCell, 5);
|
||||
recipe.addOutput(SulfuricAcid, 2);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(120,Manufacturer.class);
|
||||
recipe.addInput(VersatileFrameWork,5);
|
||||
Recipe recipe = new Recipe(120, Manufacturer.class);
|
||||
recipe.addInput(VersatileFrameWork, 5);
|
||||
recipe.addInput(ElectromagneticControlRod, 5);
|
||||
recipe.addInput(Battery, 10);
|
||||
recipe.addOutput(MagneticFieldGenerator,2);
|
||||
recipe.addOutput(MagneticFieldGenerator, 2);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(3, Blender.class);
|
||||
recipe.addInput(SulfuricAcid,2.5);
|
||||
recipe.addInput(AluminaSolution,2);
|
||||
recipe.addInput(AluminumCasing,1);
|
||||
recipe.addInput(SulfuricAcid, 2.5);
|
||||
recipe.addInput(AluminaSolution, 2);
|
||||
recipe.addInput(AluminumCasing, 1);
|
||||
recipe.addOutput(Battery, 1);
|
||||
recipe.addOutput(Water, 1.5);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(8, Assembler.class);
|
||||
recipe.addInput(AlcladAluminumSheet,5);
|
||||
recipe.addInput(CopperSheet,3);
|
||||
recipe.addInput(AlcladAluminumSheet, 5);
|
||||
recipe.addInput(CopperSheet, 3);
|
||||
recipe.addOutput(HeatSink, 1);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(80, Assembler.class);
|
||||
recipe.addInput(AdaptiveControlUnit,2);
|
||||
recipe.addInput(SuperComputer,1);
|
||||
recipe.addOutput(AssemblyDirectorSystem,1);
|
||||
recipe.addInput(AdaptiveControlUnit, 2);
|
||||
recipe.addInput(SuperComputer, 1);
|
||||
recipe.addOutput(AssemblyDirectorSystem, 1);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(30,Assembler.class);
|
||||
recipe.addInput(Stator,3);
|
||||
recipe.addInput(AILimiter,2);
|
||||
recipe.addOutput(ElectromagneticControlRod,2);
|
||||
Recipe recipe = new Recipe(30, Assembler.class);
|
||||
recipe.addInput(Stator, 3);
|
||||
recipe.addInput(AILimiter, 2);
|
||||
recipe.addOutput(ElectromagneticControlRod, 2);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(10, Blender.class);
|
||||
recipe.addInput(HeatSink,2);
|
||||
recipe.addInput(Rubber,2);
|
||||
recipe.addInput(Water,5);
|
||||
recipe.addInput(NitrogenGas,25);
|
||||
recipe.addOutput(CoolingSystem,1);
|
||||
recipe.addInput(HeatSink, 2);
|
||||
recipe.addInput(Rubber, 2);
|
||||
recipe.addInput(Water, 5);
|
||||
recipe.addInput(NitrogenGas, 25);
|
||||
recipe.addOutput(CoolingSystem, 1);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(40, Blender.class);
|
||||
recipe.addInput(HeavyModularFrame,1);
|
||||
recipe.addInput(AluminumCasing,50);
|
||||
recipe.addInput(NitrogenGas,25);
|
||||
recipe.addOutput(FusedModularFrame,1);
|
||||
recipe.addInput(HeavyModularFrame, 1);
|
||||
recipe.addInput(AluminumCasing, 50);
|
||||
recipe.addInput(NitrogenGas, 25);
|
||||
recipe.addOutput(FusedModularFrame, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package satisfactory;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import guru.nidi.graphviz.engine.Format;
|
||||
import guru.nidi.graphviz.engine.Graphviz;
|
||||
import guru.nidi.graphviz.engine.GraphvizCmdLineEngine;
|
||||
import guru.nidi.graphviz.engine.GraphvizJdkEngine;
|
||||
import guru.nidi.graphviz.model.MutableGraph;
|
||||
import guru.nidi.graphviz.parse.Parser;
|
||||
import org.jgrapht.Graph;
|
||||
|
|
@ -141,9 +139,7 @@ public class Test {
|
|||
});
|
||||
de.exportGraph(screws, new File(PLOTS + name + ".dot"));
|
||||
System.out.println(name);
|
||||
Item.production(screws).forEach((item, rate) -> {
|
||||
System.out.println("\t" + item.getName() + "\t" + rate);
|
||||
});
|
||||
Item.production(screws).forEach((item, rate) -> System.out.println("\t" + item.getName() + "\t" + rate));
|
||||
}
|
||||
|
||||
private static void javaPlot(String name) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import org.jgrapht.event.ConnectedComponentTraversalEvent;
|
|||
import org.jgrapht.event.EdgeTraversalEvent;
|
||||
import org.jgrapht.event.TraversalListener;
|
||||
import org.jgrapht.event.VertexTraversalEvent;
|
||||
import org.jgrapht.graph.DefaultDirectedWeightedGraph;
|
||||
import org.jgrapht.graph.DefaultWeightedEdge;
|
||||
import org.jgrapht.graph.EdgeReversedGraph;
|
||||
import org.jgrapht.nio.Attribute;
|
||||
|
|
@ -15,11 +14,9 @@ import org.jgrapht.traverse.DepthFirstIterator;
|
|||
import org.jgrapht.traverse.GraphIterator;
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.ProductionEdge;
|
||||
import satisfactory.items.SumResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -29,7 +26,7 @@ public class Utils {
|
|||
|
||||
public static Map<Item, Integer> getRawOnly(Map<Item, Integer> totals) {
|
||||
Map<Item, Integer> raws = new HashMap<>();
|
||||
for (Item item : totals.keySet().stream().filter(Item::isRaw).collect(Collectors.toList())) {
|
||||
for (Item item : totals.keySet().stream().filter(Item::isRaw).toList()) {
|
||||
raws.put(item, totals.get(item));
|
||||
}
|
||||
return raws;
|
||||
|
|
@ -52,7 +49,7 @@ public class Utils {
|
|||
EdgeReversedGraph<Item, DefaultWeightedEdge> inverse = new EdgeReversedGraph<>(graph);
|
||||
|
||||
GraphIterator<Item, DefaultWeightedEdge> iterator = new DepthFirstIterator<>(inverse, target);
|
||||
iterator.addTraversalListener(new TraversalListener<Item, DefaultWeightedEdge>() {
|
||||
iterator.addTraversalListener(new TraversalListener<>() {
|
||||
@Override
|
||||
public void connectedComponentFinished(ConnectedComponentTraversalEvent e) {
|
||||
System.out.println("\tconnectedComponentFinished: " + e);
|
||||
|
|
@ -105,7 +102,7 @@ public class Utils {
|
|||
m.put("label", DefaultAttribute.createAttribute(label));
|
||||
return m;
|
||||
});
|
||||
de.exportGraph(sum, new File(PLOTS +filename + ".dot"));
|
||||
de.exportGraph(sum, new File(PLOTS + filename + ".dot"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import java.util.*;
|
|||
|
||||
public abstract class Item {
|
||||
protected boolean isRaw = false;
|
||||
private String name;
|
||||
private Set<Recipe> recipes;
|
||||
private final String name;
|
||||
private final Set<Recipe> recipes;
|
||||
private Recipe preference = null;
|
||||
public int sum = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import org.jgrapht.Graphs;
|
|||
import org.jgrapht.graph.DefaultDirectedWeightedGraph;
|
||||
import org.jgrapht.graph.DefaultWeightedEdge;
|
||||
import satisfactory.buildings.Building;
|
||||
import satisfactory.buildings.production.Assembler;
|
||||
import satisfactory.items.requirements.RateAccumulator;
|
||||
import satisfactory.items.requirements.TotalAccumulator;
|
||||
|
||||
|
|
@ -124,18 +123,19 @@ public class Recipe {
|
|||
return inputs;
|
||||
}
|
||||
|
||||
public Map<Item,Double> getByProducts(Item reference){
|
||||
if (!outputs.containsKey(reference)){
|
||||
public Map<Item, Double> getByProducts(Item reference) {
|
||||
if (!outputs.containsKey(reference)) {
|
||||
return null;
|
||||
}
|
||||
return outputs.entrySet().stream().filter(itemIntegerEntry -> isByProduct(reference, itemIntegerEntry.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
public boolean isByProduct(Item reference, Item test){
|
||||
|
||||
public boolean isByProduct(Item reference, Item test) {
|
||||
return !reference.equals(test) && outputs.containsKey(reference) && outputs.containsKey(test);
|
||||
}
|
||||
|
||||
public Graph<Item, DefaultWeightedEdge> buildGraph(Item target) {
|
||||
System.out.println("buildGraph(" + target.getName() + ") @ "+ name);
|
||||
System.out.println("buildGraph(" + target.getName() + ") @ " + name);
|
||||
Graph<Item, DefaultWeightedEdge> graph = new DefaultDirectedWeightedGraph<>(DefaultWeightedEdge.class);
|
||||
graph.addVertex(target);
|
||||
target.sum += 1;
|
||||
|
|
@ -171,7 +171,7 @@ public class Recipe {
|
|||
return productWantedPerMinute / productPerProcess;
|
||||
}
|
||||
|
||||
private double getByproductRate(Item main, Item product, double production){
|
||||
private double getByproductRate(Item main, Item product, double production) {
|
||||
double runs = getRequiredProcessRuns(main, production);
|
||||
return product.getRecipe().outputs.get(product) * runs;
|
||||
}
|
||||
|
|
@ -182,14 +182,14 @@ public class Recipe {
|
|||
Map<Item, Double> map = new HashMap<>();
|
||||
Queue<Item> queue = new LinkedList<>();
|
||||
queue.add(target);
|
||||
map.put(target, (double) prodPerMinute);
|
||||
map.put(target, prodPerMinute);
|
||||
production.addVertex(target);
|
||||
production.addEdge(target, target, new ProductionEdge(target, target, prodPerMinute, processesNeeded(target, prodPerMinute)));
|
||||
Set<Item> visited = new HashSet<>();
|
||||
while (!queue.isEmpty()) {
|
||||
Item item = queue.remove();
|
||||
if (visited.contains(item)){
|
||||
System.out.println("hint: already processed " + item.getName()+ "! Skip!");
|
||||
if (visited.contains(item)) {
|
||||
System.out.println("hint: already processed " + item.getName() + "! Skip!");
|
||||
//continue;
|
||||
} else {
|
||||
// next items
|
||||
|
|
@ -207,7 +207,7 @@ public class Recipe {
|
|||
System.out.println(item.getName());
|
||||
if (item.getRecipe().outputs.containsKey(product)) { // TODO: method isByProduct
|
||||
// product is by-product, no forward dependency
|
||||
System.out.println("BY-PRODUCT " + item.getName() + " -> " + product.getName() + "... "+ queue);
|
||||
System.out.println("BY-PRODUCT " + item.getName() + " -> " + product.getName() + "... " + queue);
|
||||
byProducts.add(product);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -237,9 +237,7 @@ public class Recipe {
|
|||
}
|
||||
visited.add(item);
|
||||
}
|
||||
map.forEach((item, aDouble) -> {
|
||||
System.out.println(item.getName() + ": " + aDouble);
|
||||
});
|
||||
map.forEach((item, aDouble) -> System.out.println(item.getName() + ": " + aDouble));
|
||||
return new SumResult(production, map);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ public class SumResult {
|
|||
return map;
|
||||
}
|
||||
|
||||
public SumResult merge(SumResult other){
|
||||
public SumResult merge(SumResult other) {
|
||||
HashMap<Item, Double> map = new HashMap<>();
|
||||
this.map.forEach(map::put);
|
||||
other.map.forEach((item, aDouble) -> map.merge(item,aDouble,Double::sum));
|
||||
map.putAll(this.map);
|
||||
other.map.forEach((item, aDouble) -> map.merge(item, aDouble, Double::sum));
|
||||
return new SumResult(merge(production, other.getProduction()), map);
|
||||
}
|
||||
|
||||
|
|
@ -58,8 +58,7 @@ public class SumResult {
|
|||
graph1.vertexSet().forEach(result::addVertex);
|
||||
graph1.edgeSet().forEach(productionEdge -> {
|
||||
List<ProductionEdge> collect = result.edgeSet().stream()
|
||||
.filter(productionEdge1 -> productionEdge1.hasSource(productionEdge.getSource()))
|
||||
.collect(Collectors.toList());
|
||||
.filter(productionEdge1 -> productionEdge1.hasSource(productionEdge.getSource())).toList();
|
||||
collect.forEach(edge -> {
|
||||
Item src = result.getEdgeSource(edge);
|
||||
Item target = result.getEdgeTarget(edge);
|
||||
|
|
|
|||
|
|
@ -6,43 +6,43 @@ import satisfactory.items.Recipe;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class Accumulator<E extends Number> implements RequirementAccumulator<E>{
|
||||
protected Map<Item, E> inputs;
|
||||
public abstract class Accumulator<E extends Number> implements RequirementAccumulator<E> {
|
||||
protected Map<Item, E> inputs;
|
||||
|
||||
public Accumulator(Map<Item, E> inputs) {
|
||||
this.inputs = inputs;
|
||||
}
|
||||
public Accumulator(Map<Item, E> inputs) {
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
protected abstract E calculate(Item i, E subAmount, E amount, Map<Item, E> total);
|
||||
protected abstract E calculate(Item i, E subAmount, E amount, Map<Item, E> total);
|
||||
|
||||
protected abstract E dequeue(Item item, E amount, Map<Item, E> totals);
|
||||
protected abstract E dequeue(Item item, E amount, Map<Item, E> totals);
|
||||
|
||||
@Override
|
||||
public Map<Item, E> accumulate() {
|
||||
Map<Item, E> total = new HashMap<>();
|
||||
Map<Item, E> queue = new HashMap<>();
|
||||
for (Item i : inputs.keySet()) {
|
||||
queue.put(i, inputs.get(i));
|
||||
}
|
||||
while (!queue.isEmpty()) {
|
||||
Item i = queue.keySet().iterator().next();
|
||||
E amount = queue.remove(i);
|
||||
E newTotal = dequeue(i, amount, total);
|
||||
total.put(i,newTotal);
|
||||
if (i.getRecipes().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Recipe r = i.getRecipes().iterator().next();
|
||||
Map<Item, E> subRequirements = getRequirements(r, i);
|
||||
for (Item subItem : subRequirements.keySet()) {
|
||||
E subAmount = subRequirements.get(subItem);
|
||||
E newSubTotal = calculate(subItem, subAmount, amount, total);
|
||||
total.put(subItem, newSubTotal);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@Override
|
||||
public Map<Item, E> accumulate() {
|
||||
Map<Item, E> total = new HashMap<>();
|
||||
Map<Item, E> queue = new HashMap<>();
|
||||
for (Item i : inputs.keySet()) {
|
||||
queue.put(i, inputs.get(i));
|
||||
}
|
||||
while (!queue.isEmpty()) {
|
||||
Item i = queue.keySet().iterator().next();
|
||||
E amount = queue.remove(i);
|
||||
E newTotal = dequeue(i, amount, total);
|
||||
total.put(i, newTotal);
|
||||
if (i.getRecipes().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Recipe r = i.getRecipes().iterator().next();
|
||||
Map<Item, E> subRequirements = getRequirements(r, i);
|
||||
for (Item subItem : subRequirements.keySet()) {
|
||||
E subAmount = subRequirements.get(subItem);
|
||||
E newSubTotal = calculate(subItem, subAmount, amount, total);
|
||||
total.put(subItem, newSubTotal);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
protected abstract Map<Item,E> getRequirements(Recipe r, Item i);// r.getTotalRequirements()
|
||||
protected abstract Map<Item, E> getRequirements(Recipe r, Item i);// r.getTotalRequirements()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,28 +7,28 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class RateAccumulator extends Accumulator<Double> {
|
||||
private Item item;
|
||||
private final Item item;
|
||||
|
||||
public RateAccumulator(Recipe recipe, Item item) {
|
||||
super(new HashMap<>());
|
||||
recipe.getInputs().forEach((item1, integer) -> inputs.put(item1, integer));
|
||||
this.item = item;
|
||||
}
|
||||
public RateAccumulator(Recipe recipe, Item item) {
|
||||
super(new HashMap<>());
|
||||
inputs.putAll(recipe.getInputs());
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Double calculate(Item i, Double subAmount, Double amount, Map<Item, Double> total) {
|
||||
Double base = total.getOrDefault(i, 0.0);
|
||||
double additional = subAmount * amount * i.getProductionRate();
|
||||
return base + additional;
|
||||
}
|
||||
@Override
|
||||
protected Double calculate(Item i, Double subAmount, Double amount, Map<Item, Double> total) {
|
||||
Double base = total.getOrDefault(i, 0.0);
|
||||
double additional = subAmount * amount * i.getProductionRate();
|
||||
return base + additional;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Double dequeue(Item item, Double amount, Map<Item, Double> totals) {
|
||||
return totals.getOrDefault(item, 0.0) + amount;
|
||||
}
|
||||
@Override
|
||||
protected Double dequeue(Item item, Double amount, Map<Item, Double> totals) {
|
||||
return totals.getOrDefault(item, 0.0) + amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<Item, Double> getRequirements(Recipe r, Item i) {
|
||||
return r.getRequirementRates(i);
|
||||
}
|
||||
@Override
|
||||
protected Map<Item, Double> getRequirements(Recipe r, Item i) {
|
||||
return r.getRequirementRates(i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ import satisfactory.items.Item;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public interface RequirementAccumulator<E extends Number> {
|
||||
Map<Item, E> accumulate();
|
||||
public interface RequirementAccumulator<E extends Number> {
|
||||
Map<Item, E> accumulate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@ import satisfactory.items.Recipe;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public class TotalAccumulator extends Accumulator<Double>{
|
||||
public class TotalAccumulator extends Accumulator<Double> {
|
||||
|
||||
public TotalAccumulator(Map<Item, Double> inputs) {
|
||||
super(inputs);
|
||||
}
|
||||
public TotalAccumulator(Map<Item, Double> inputs) {
|
||||
super(inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Double calculate(Item i, Double subAmount, Double amount, Map<Item, Double> total) {
|
||||
return total.getOrDefault(i, 0.0) + subAmount * amount;
|
||||
}
|
||||
@Override
|
||||
protected Double calculate(Item i, Double subAmount, Double amount, Map<Item, Double> total) {
|
||||
return total.getOrDefault(i, 0.0) + subAmount * amount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Double dequeue(Item item, Double amount, Map<Item, Double> totals) {
|
||||
return totals.getOrDefault(item, 0.0) + amount;
|
||||
}
|
||||
@Override
|
||||
protected Double dequeue(Item item, Double amount, Map<Item, Double> totals) {
|
||||
return totals.getOrDefault(item, 0.0) + amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<Item, Double> getRequirements(Recipe r, Item i) {
|
||||
return r.getTotalRequirements();
|
||||
}
|
||||
@Override
|
||||
protected Map<Item, Double> getRequirements(Recipe r, Item i) {
|
||||
return r.getTotalRequirements();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public abstract class Fluid extends Item {
|
||||
|
||||
public Fluid(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
public Fluid(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
|
||||
public Fluid(String name) {
|
||||
super(name);
|
||||
}
|
||||
public Fluid(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class Gas extends Item {
|
||||
|
||||
public Gas(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
public Gas(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
|
||||
public Gas(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
public Gas(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class Ingot extends Item {
|
||||
|
||||
public Ingot(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
public Ingot(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
|
||||
public Ingot(String name) {
|
||||
super(name);
|
||||
}
|
||||
public Ingot(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class Ore extends Item {
|
||||
|
||||
public Ore(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
public Ore(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
|
||||
public Ore(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
public Ore(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class Part extends Item {
|
||||
|
||||
public Part(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
public Part(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
|
||||
public Part(String name) {
|
||||
super(name);
|
||||
}
|
||||
public Part(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class Pickup extends Item {
|
||||
|
||||
public Pickup(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
public Pickup(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
|
||||
public Pickup(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
public Pickup(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class ProcessedFluid extends Fluid {
|
||||
|
||||
public ProcessedFluid(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
public ProcessedFluid(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
|
||||
public ProcessedFluid(String name) {
|
||||
super(name);
|
||||
}
|
||||
public ProcessedFluid(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class RawFluid extends Fluid {
|
||||
|
||||
public RawFluid(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
public RawFluid(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
setIsRaw();
|
||||
}
|
||||
|
||||
public RawFluid(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
public RawFluid(String name) {
|
||||
super(name);
|
||||
setIsRaw();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import satisfactory.items.Recipe;
|
|||
|
||||
public class Tool extends Item {
|
||||
|
||||
public Tool(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
public Tool(String name, Recipe... recipes) {
|
||||
super(name, recipes);
|
||||
}
|
||||
|
||||
public Tool(String name) {
|
||||
super(name);
|
||||
}
|
||||
public Tool(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package satisfactory.items;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import satisfactory.Database;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class DatabaseTest {
|
||||
|
|
@ -9,7 +10,7 @@ public class DatabaseTest {
|
|||
void testWaterPreference() {
|
||||
Item i = Database.Water;
|
||||
assertSame(i.getPreference(), i.getRecipe());
|
||||
assertTrue(i.getPreference() == i.getRecipe());
|
||||
assertSame(i.getPreference(), i.getRecipe());
|
||||
assertTrue(i.getRecipe().toString().contains("water pump thingy"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue