add caterium circuit board, migrate to recipe builder
parent
0ab1f7b330
commit
4a28775e9c
File diff suppressed because it is too large
Load Diff
|
|
@ -132,7 +132,7 @@ public class Test {
|
||||||
planFor("p3_vf", new Production(Database.VersatileFrameWork, 1));
|
planFor("p3_vf", new Production(Database.VersatileFrameWork, 1));
|
||||||
planFor("screw", new Production(Database.ReinforcedIronPlate, 1));
|
planFor("screw", new Production(Database.ReinforcedIronPlate, 1));
|
||||||
planFor("rotor", new Production(Database.Rotor, 1));
|
planFor("rotor", new Production(Database.Rotor, 1));
|
||||||
planFor("mf", new Production(Database.ModularFrame, 1));
|
planFor("mf", new Production(Database.ModularFrame, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void planFor(Item item, int amount, String name) {
|
private static void planFor(Item item, int amount, String name) {
|
||||||
|
|
|
||||||
|
|
@ -40,20 +40,13 @@ public abstract class Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Recipe recipe) {
|
public void add(Recipe recipe) {
|
||||||
|
if (!recipe.checkOutput(this)){
|
||||||
|
throw new IllegalStateException("tried to add recipe which does not produce item");
|
||||||
|
}
|
||||||
if (recipes.isEmpty()) {
|
if (recipes.isEmpty()) {
|
||||||
setPreference(recipe);
|
setPreference(recipe);
|
||||||
}
|
}
|
||||||
add(recipe, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Recipe recipe, double output) {
|
|
||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
recipe.checkOutput(this, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Recipe recipe, int output) {
|
|
||||||
recipes.add(recipe);
|
|
||||||
recipe.checkOutput(this, output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,15 @@ public class Recipe {
|
||||||
this.byProducts = byProducts;
|
this.byProducts = byProducts;
|
||||||
this.building = building;
|
this.building = building;
|
||||||
}
|
}
|
||||||
|
public Recipe(int duration, Map<Item, Double> inputs, Map<Item, Double> outputs, Set<Item> byProducts, Building building,String name, boolean isHandCraftable) {
|
||||||
|
this.duration = duration;
|
||||||
|
this.inputs = inputs;
|
||||||
|
this.outputs = outputs;
|
||||||
|
this.byProducts = byProducts;
|
||||||
|
this.building = building;
|
||||||
|
this.name=name;
|
||||||
|
this.isHandCraftable = isHandCraftable;
|
||||||
|
}
|
||||||
|
|
||||||
public Recipe(int duration, String name, boolean isHandCraftable, Building building) {
|
public Recipe(int duration, String name, boolean isHandCraftable, Building building) {
|
||||||
this(duration, building);
|
this(duration, building);
|
||||||
|
|
@ -56,11 +65,11 @@ public class Recipe {
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInput(Item item, int amount) {
|
protected void addInput(Item item, int amount) {
|
||||||
inputs.put(item, (double) amount);
|
inputs.put(item, (double) amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInput(Item item, double amount) {
|
protected void addInput(Item item, double amount) {
|
||||||
inputs.put(item, amount);
|
inputs.put(item, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,41 +84,33 @@ public class Recipe {
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInput(Item input) {
|
protected void addInput(Item input) {
|
||||||
addInput(input, 1);
|
addInput(input, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOutput(Item item, int amount, boolean isByProduct) {
|
protected void addOutput(Item item, int amount, boolean isByProduct) {
|
||||||
addOutput(item, (double) amount, isByProduct);
|
addOutput(item, (double) amount, isByProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOutput(Item item, int amount) {
|
protected void addOutput(Item item, int amount) {
|
||||||
this.outputs.put(item, (double) amount);
|
this.outputs.put(item, (double) amount);
|
||||||
item.add(this, amount);
|
item.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOutput(Item item, double amount, boolean isByProduct) {
|
protected void addOutput(Item item, double amount, boolean isByProduct) {
|
||||||
addOutput(item, amount);
|
addOutput(item, amount);
|
||||||
if (isByProduct) {
|
if (isByProduct) {
|
||||||
byProducts.add(item);
|
byProducts.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOutput(Item item, double amount) {
|
protected void addOutput(Item item, double amount) {
|
||||||
this.outputs.put(item, amount);
|
this.outputs.put(item, amount);
|
||||||
item.add(this, amount);
|
item.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkOutput(Item item, int amount) {
|
public boolean checkOutput(Item item) {
|
||||||
if (!(outputs.containsKey(item) && outputs.get(item) == amount)) {
|
return outputs.containsKey(item);
|
||||||
outputs.put(item, (double) amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkOutput(Item item, double amount) {
|
|
||||||
if (!(outputs.containsKey(item) && outputs.get(item) == amount)) {
|
|
||||||
outputs.put(item, amount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatIO(Map<Item, Double> map) {
|
private String formatIO(Map<Item, Double> map) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
package satisfactory.items;
|
||||||
|
|
||||||
|
import satisfactory.buildings.Building;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class RecipeBuilder {
|
||||||
|
private int duration;
|
||||||
|
private Building building;
|
||||||
|
private Map<Item, Double> inputs = new HashMap<>();
|
||||||
|
private Map<Item, Double> outputs = new HashMap<>();
|
||||||
|
private Set<Item> byProducts = new HashSet<>();
|
||||||
|
private boolean isHandCraftable;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public RecipeBuilder setDuration(int duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder setBuilding(Building building) {
|
||||||
|
this.building = building;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder addInput(Item item, Double n) {
|
||||||
|
this.inputs.put(item, n);// TODO: merge?
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public RecipeBuilder addInput(Item item, Integer n) {
|
||||||
|
return addInput(item,(double) n);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder addOutput(Item item, Double n, boolean isByProduct) {
|
||||||
|
addByProduct(item);
|
||||||
|
return this.addOutput(item, n);
|
||||||
|
}
|
||||||
|
public RecipeBuilder addOutput(Item item, Double n) {
|
||||||
|
this.outputs.put(item, n);// TODO: merge?
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public RecipeBuilder addOutput(Item item, Integer n) {
|
||||||
|
return addOutput(item,(double) n);
|
||||||
|
}
|
||||||
|
public RecipeBuilder addOutput(Item item, Integer n, boolean isByProduct) {
|
||||||
|
return addOutput(item,(double) n, isByProduct);
|
||||||
|
}
|
||||||
|
public RecipeBuilder setInputs(Map<Item, Double> inputs) {
|
||||||
|
this.inputs = inputs;// TODO: merge?
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder setOutputs(Map<Item, Double> outputs) {
|
||||||
|
this.outputs = outputs;// TODO: merge?
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder addByProduct(Item byProduct) {
|
||||||
|
this.byProducts.add(byProduct);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public RecipeBuilder setByProducts(Set<Item> byProduct) {
|
||||||
|
this.byProducts =byProducts;// TODO: merge?
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder setIsHandCraftable(boolean isHandCraftable) {
|
||||||
|
this.isHandCraftable = isHandCraftable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recipe createRecipe() {
|
||||||
|
// public Recipe(int duration, Map<Item, Double> inputs, Map<Item, Double> outputs, Set<Item> byProducts, Building building,String name) {
|
||||||
|
if (outputs.isEmpty()){
|
||||||
|
throw new IllegalStateException("no outputs set");
|
||||||
|
}
|
||||||
|
Recipe recipe = new Recipe(duration, inputs,outputs, byProducts,building,name,isHandCraftable );
|
||||||
|
outputs.keySet().forEach(item -> item.add(recipe));
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -55,10 +55,12 @@ class ItemTest {
|
||||||
void productionPlastic() {
|
void productionPlastic() {
|
||||||
test(Database.Plastic, "plastic");
|
test(Database.Plastic, "plastic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void productionRubber() {
|
void productionRubber() {
|
||||||
test(Database.Rubber, "rubber");
|
test(Database.Rubber, "rubber");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void productionRubberAndPlastic() {
|
void productionRubberAndPlastic() {
|
||||||
test("rubberAndPlastic", Database.Rubber, Database.Plastic);
|
test("rubberAndPlastic", Database.Rubber, Database.Plastic);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue