Compare commits
2 Commits
ee35fcf49b
...
6d778d16aa
| Author | SHA1 | Date |
|---|---|---|
|
|
6d778d16aa | |
|
|
1e1fcba3cb |
|
|
@ -10,6 +10,7 @@ import satisfactory.items.type.*;
|
|||
import java.util.*;
|
||||
|
||||
public class Database {
|
||||
public static final Item TODO_ITEM = new Ore("TODO ITEM");
|
||||
// BUILDINGS
|
||||
public static final class Buildings {
|
||||
public static final Building ASSEMBLER = new ProductionBuilding("Assembler", 15, assembler());
|
||||
|
|
@ -40,7 +41,7 @@ public class Database {
|
|||
|
||||
private static Map<Item, Integer> blender() {
|
||||
Map<Item, Integer> cost = new HashMap<>();
|
||||
cost.put(null, null); //FIXME values
|
||||
cost.put(TODO_ITEM, 1); //FIXME values
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ public class Database {
|
|||
private static Map<Item, Integer> minerMk3() {
|
||||
Map<Item, Integer> cost = new HashMap<>();
|
||||
cost.put(Database.PortableMiner, 2);
|
||||
cost.put(null, null); //FIXME values
|
||||
cost.put(TODO_ITEM, 1); //FIXME values
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +146,7 @@ public class Database {
|
|||
|
||||
private static Map<Item, Integer> resourceWellExtractor() {
|
||||
Map<Item, Integer> cost = new HashMap<>();
|
||||
cost.put(null, null); // FIXME values
|
||||
cost.put(TODO_ITEM, 1); // FIXME values
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
|
@ -731,7 +732,7 @@ public class Database {
|
|||
// TODO: duration=60/130
|
||||
polymerResin.addInput(CrudeOil, 6);
|
||||
polymerResin.addOutput(PolymerResin, 13);
|
||||
polymerResin.addOutput(HeavyOilResidue, 2);
|
||||
polymerResin.addOutput(HeavyOilResidue, 2, true);
|
||||
PolymerResin.add(polymerResin);
|
||||
}
|
||||
{
|
||||
|
|
@ -744,7 +745,7 @@ public class Database {
|
|||
Recipe unpack = new Recipe(2, Buildings.PACKAGER);
|
||||
recipe.addInput(PackagedLiquidBiofuel, 2);
|
||||
recipe.addOutput(LiquidBiofuel, 2);
|
||||
recipe.addOutput(EmptyCanister, 2);
|
||||
recipe.addOutput(EmptyCanister, 2,true);
|
||||
LiquidBiofuel.add(unpack);
|
||||
}
|
||||
{
|
||||
|
|
@ -755,7 +756,7 @@ public class Database {
|
|||
// Plastic
|
||||
Recipe recipe = new Recipe(6, false, Buildings.REFINERY);
|
||||
recipe.addInput(CrudeOil, 3);
|
||||
recipe.addOutput(HeavyOilResidue, 1);
|
||||
recipe.addOutput(HeavyOilResidue, 1, true);
|
||||
Plastic.add(recipe, 2);
|
||||
Recipe residualPlastic = new Recipe(6, "Residual Plastic", false, Buildings.REFINERY);
|
||||
residualPlastic.addInput(PolymerResin, 6);
|
||||
|
|
@ -768,7 +769,7 @@ public class Database {
|
|||
// Rubber
|
||||
Recipe recipe = new Recipe(6, false, Buildings.REFINERY);
|
||||
recipe.addInput(CrudeOil, 3);
|
||||
recipe.addOutput(HeavyOilResidue, 2);
|
||||
recipe.addOutput(HeavyOilResidue, 2, true);
|
||||
Rubber.add(recipe, 2);
|
||||
Recipe residualRubber = new Recipe(6, "Residual Rubber", false, Buildings.REFINERY);
|
||||
residualRubber.addInput(PolymerResin, 6);
|
||||
|
|
@ -825,14 +826,14 @@ public class Database {
|
|||
recipe.addInput(Bauxite, 12);
|
||||
recipe.addInput(Water, 18);
|
||||
recipe.addOutput(Silica, 5);
|
||||
recipe.addOutput(AluminaSolution, 12);
|
||||
recipe.addOutput(AluminaSolution, 12,true);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(1, Buildings.REFINERY);
|
||||
recipe.addInput(AluminaSolution, 4);
|
||||
recipe.addInput(Coal, 2);
|
||||
recipe.addOutput(AluminumScrap, 6);
|
||||
recipe.addOutput(Water, 2);
|
||||
recipe.addOutput(Water, 2,true);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(6, Buildings.REFINERY);
|
||||
|
|
@ -853,7 +854,7 @@ public class Database {
|
|||
recipe.addInput(Concrete, 3);
|
||||
recipe.addInput(SulfuricAcid, 8);
|
||||
recipe.addOutput(EncasedUraniumCell, 5);
|
||||
recipe.addOutput(SulfuricAcid, 2);
|
||||
recipe.addOutput(SulfuricAcid, 2,true);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(120, Buildings.MANUFACTURER);
|
||||
|
|
@ -868,7 +869,7 @@ public class Database {
|
|||
recipe.addInput(AluminaSolution, 2);
|
||||
recipe.addInput(AluminumCasing, 1);
|
||||
recipe.addOutput(Battery, 1);
|
||||
recipe.addOutput(Water, 1.5);
|
||||
recipe.addOutput(Water, 1.5,true);
|
||||
}
|
||||
{
|
||||
Recipe recipe = new Recipe(8, Buildings.ASSEMBLER);
|
||||
|
|
@ -920,7 +921,7 @@ public class Database {
|
|||
Recipe packaged = new Recipe(3, Buildings.PACKAGER);
|
||||
recipe.addInput(PackagedTurboFuel, 2);
|
||||
recipe.addOutput(Turbofuel, 2);
|
||||
recipe.addOutput(EmptyCanister, 2);
|
||||
recipe.addOutput(EmptyCanister, 2, true);
|
||||
Turbofuel.add(packaged);
|
||||
}
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,13 +14,14 @@ import java.util.stream.Collectors;
|
|||
public class Recipe {
|
||||
private final Map<Item, Double> inputs;
|
||||
private final Map<Item, Double> outputs;
|
||||
private final Set<Item> byProducts;
|
||||
private final int duration;
|
||||
private final Building building;
|
||||
private boolean isHandCraftable = true;
|
||||
private String name;
|
||||
|
||||
public Recipe(int duration, Building building) {
|
||||
this(duration, new HashMap<>(), new HashMap<>(), building);
|
||||
this(duration, new HashMap<>(), new HashMap<>(), new HashSet<>(), building);
|
||||
}
|
||||
|
||||
public Recipe(int duration, boolean isHandCraftable, Building building) {
|
||||
|
|
@ -33,10 +34,11 @@ public class Recipe {
|
|||
addInput(item, input);
|
||||
}
|
||||
|
||||
public Recipe(int duration, Map<Item, Double> inputs, Map<Item, Double> outputs, Building building) {
|
||||
public Recipe(int duration, Map<Item, Double> inputs, Map<Item, Double> outputs, Set<Item> byProducts, Building building) {
|
||||
this.duration = duration;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
this.byProducts = byProducts;
|
||||
this.building = building;
|
||||
}
|
||||
|
||||
|
|
@ -77,11 +79,22 @@ public class Recipe {
|
|||
addInput(input, 1);
|
||||
}
|
||||
|
||||
public void addOutput(Item item, int amount, boolean isByProduct) {
|
||||
addOutput(item, (double) amount, isByProduct);
|
||||
}
|
||||
|
||||
public void addOutput(Item item, int amount) {
|
||||
this.outputs.put(item, (double) amount);
|
||||
item.add(this, amount);
|
||||
}
|
||||
|
||||
public void addOutput(Item item, double amount, boolean isByProduct) {
|
||||
addOutput(item, amount);
|
||||
if (isByProduct) {
|
||||
byProducts.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void addOutput(Item item, double amount) {
|
||||
this.outputs.put(item, amount);
|
||||
item.add(this, amount);
|
||||
|
|
@ -123,15 +136,8 @@ public class Recipe {
|
|||
return inputs;
|
||||
}
|
||||
|
||||
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) {
|
||||
return !reference.equals(test) && outputs.containsKey(reference) && outputs.containsKey(test);
|
||||
public boolean isByProduct(Item test) {
|
||||
return byProducts.contains(test);
|
||||
}
|
||||
|
||||
public Graph<Item, DefaultWeightedEdge> buildGraph(Item target) {
|
||||
|
|
@ -201,7 +207,7 @@ public class Recipe {
|
|||
for (DefaultWeightedEdge edge : buildGraph.outgoingEdgesOf(item)) {
|
||||
Item product = buildGraph.getEdgeTarget(edge);
|
||||
Double productWantedPerMinute = map.get(product);
|
||||
if (item.getRecipe().outputs.containsKey(product)) { // TODO: method isByProduct
|
||||
if (item.getRecipe().isByProduct(product)) { // TODO: method isByProduct
|
||||
// product is by-product, no forward dependency
|
||||
System.out.println("BY-PRODUCT " + item.getName() + " -> " + product.getName() + "... " + queue);
|
||||
byProducts.add(product);
|
||||
|
|
@ -247,6 +253,7 @@ public class Recipe {
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
if (name == null) {
|
||||
return formatOutputs();
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ class ItemTest {
|
|||
|
||||
@Test
|
||||
void productionUraniumFuelRod(){
|
||||
//test(Database.UraniumFuelRod, "uranium_fuel_rod");
|
||||
fail();
|
||||
test(Database.UraniumFuelRod, "uranium_fuel_rod");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,13 +27,15 @@ public class TestHelper {
|
|||
}
|
||||
|
||||
public static void test(Item item, String name) {
|
||||
name = "test_" + name;
|
||||
Map<Item, Double> ref = ValidatedValues.get(item);
|
||||
SumResult calculations = calculate(item);
|
||||
assertMap(ref, calculations.getMap());
|
||||
//plot
|
||||
name = "test_" + name;
|
||||
plot2(calculations.getProduction(), name);
|
||||
javaPlot(name);
|
||||
list(calculations, name);
|
||||
// assert
|
||||
assertMap(ref, calculations.getMap());
|
||||
}
|
||||
|
||||
private static SumResult calculate(Item item) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue