Compare commits

...

2 Commits

Author SHA1 Message Date
agp8x 1d5c39b9e5 new items, stack sizes, init building dependencies 2024-03-07 23:55:34 +01:00
agp8x 33959e80d0 updates 2023-12-09 18:41:59 +01:00
18 changed files with 843 additions and 161 deletions

File diff suppressed because it is too large Load Diff

View File

@ -86,6 +86,7 @@ public class Test {
System.out.println("\ntest"); System.out.println("\ntest");
SumResult.sum(Database.Plastic, 4); SumResult.sum(Database.Plastic, 4);
*/ */
/*
Item a = Database.HeavyOilResidue; Item a = Database.HeavyOilResidue;
Item b = Database.Water; Item b = Database.Water;
Map<Item, Recipe> preferences = Database.preferences; Map<Item, Recipe> preferences = Database.preferences;
@ -133,6 +134,10 @@ public class Test {
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, 10)); planFor("mf", new Production(Database.ModularFrame, 10));
*/
//planFor("aluminumIngot", new Production(Database.AluminumIngot, 240));
//planFor("fusedFrame", new Production(Database.FusedModularFrame, 1.5));
planFor("p4", new Production(Database.AssemblyDirectorSystem,4), new Production(Database.MagneticFieldGenerator, 4), new Production(Database.ThermalPropulsionRocket, 1), new Production(Database.NuclearPasta, 1));
} }
private static void planFor(Item item, int amount, String name) { private static void planFor(Item item, int amount, String name) {

View File

@ -25,7 +25,7 @@ public abstract class Building {
public Map<Item, Integer> getCost(int n) { public Map<Item, Integer> getCost(int n) {
Map<Item, Integer> instances = new HashMap<>(); Map<Item, Integer> instances = new HashMap<>();
cost.forEach((item, integer) -> instances.put(item, n * integer)); getCost().forEach((item, integer) -> instances.put(item, n * integer));
return instances; return instances;
} }

View File

@ -0,0 +1,12 @@
package satisfactory.buildings;
import satisfactory.items.Item;
import java.util.Map;
public class DecorationBuilding extends Building {
public DecorationBuilding(String name, Map<Item, Integer> cost){
super(name);
this.cost = cost;
}
}

View File

@ -0,0 +1,16 @@
package satisfactory.buildings;
import satisfactory.items.Item;
import java.util.Map;
public class ParticleAccelerator extends ProductionBuilding{
public ParticleAccelerator(String name, int power, Map<Item, Integer> cost) {
super(name, power, cost);
}
@Override
public Integer getPower() {
return 1000; // TODO calculate
}
}

View File

@ -0,0 +1,22 @@
package satisfactory.buildings;
import satisfactory.Database;
import satisfactory.items.Item;
import java.util.HashMap;
import java.util.Map;
public class ResourceWellExtractor extends ProductionBuilding{
private final Building dependendBuilding;
public ResourceWellExtractor(String name, Map<Item, Integer> cost,Building pressurizer) {
super(name, 0, cost);
dependendBuilding = pressurizer;
}
@Override
public Map<Item, Integer> getCost() {
Map<Item, Integer> totalCost = new HashMap<>(super.getCost());
dependendBuilding.getCost().forEach((item, integer) -> totalCost.merge(item, integer, Integer::sum));
return totalCost;
}
}

View File

@ -13,21 +13,22 @@ import java.util.Set;
public abstract class Item { public abstract class Item {
private final String name; private final String name;
private final Set<Recipe> recipes; private final Set<Recipe> recipes;
public final int stackSize;
public int sum = 0; public int sum = 0;
protected boolean isRaw = false; protected boolean isRaw = false;
private Recipe preference = null; private Recipe preference = null;
protected Item(String name, Set<Recipe> recipes) { protected Item(String name, int stackSize, Set<Recipe> recipes) {
this.name = name; this.name = name;
this.stackSize = stackSize;
this.recipes = recipes; this.recipes = recipes;
Database.add(this);
for (Recipe recipe : recipes) { for (Recipe recipe : recipes) {
add(recipe); add(recipe);
} }
} }
public Item(String name) { public Item(String name, int stackSize) {
this(name, new HashSet<>()); this(name, stackSize, new HashSet<>());
} }
public static Map<Item, Double> production(Graph<Item, DefaultWeightedEdge> graph) { public static Map<Item, Double> production(Graph<Item, DefaultWeightedEdge> graph) {
@ -95,7 +96,11 @@ public abstract class Item {
} }
public String ID() { public String ID() {
return getName().replace(" ", "").replace(".", "_"); return getName()
.replace(" ", "")
.replace(".", "_")
.replace("-", "")
;
} }
public Recipe getPreference() { public Recipe getPreference() {

View File

@ -62,8 +62,8 @@ public class RecipeBuilder {
this.byProducts.add(byProduct); this.byProducts.add(byProduct);
return this; return this;
} }
public RecipeBuilder setByProducts(Set<Item> byProduct) { public RecipeBuilder setByProducts(Set<Item> byProducts) {
this.byProducts =byProducts;// TODO: merge? this.byProducts = byProducts;// TODO: merge?
return this; return this;
} }

View File

@ -5,6 +5,6 @@ import satisfactory.items.Item;
public abstract class Fluid extends Item { public abstract class Fluid extends Item {
public Fluid(String name) { public Fluid(String name) {
super(name); super(name, 0);
} }
} }

View File

@ -2,7 +2,7 @@ package satisfactory.items.type;
import satisfactory.items.Item; import satisfactory.items.Item;
public class Gas extends Item { public class Gas extends Fluid {
public Gas(String name) { public Gas(String name) {
super(name); super(name);

View File

@ -4,7 +4,7 @@ import satisfactory.items.Item;
public class Ingot extends Item { public class Ingot extends Item {
public Ingot(String name) { public Ingot(String name, int stackSize) {
super(name); super(name, stackSize);
} }
} }

View File

@ -4,8 +4,8 @@ import satisfactory.items.Item;
public class Ore extends Item { public class Ore extends Item {
public Ore(String name) { public Ore(String name, int stackSize) {
super(name); super(name, stackSize);
setIsRaw(); setIsRaw();
} }

View File

@ -4,7 +4,7 @@ import satisfactory.items.Item;
public class Part extends Item { public class Part extends Item {
public Part(String name) { public Part(String name, int stackSize) {
super(name); super(name, stackSize);
} }
} }

View File

@ -4,8 +4,8 @@ import satisfactory.items.Item;
public class Pickup extends Item { public class Pickup extends Item {
public Pickup(String name) { public Pickup(String name, int stackSize) {
super(name); super(name, stackSize);
setIsRaw(); setIsRaw();
} }
} }

View File

@ -4,7 +4,7 @@ import satisfactory.items.Item;
public class Tool extends Item { public class Tool extends Item {
public Tool(String name) { public Tool(String name, int stackSize) {
super(name); super(name, stackSize);
} }
} }

View File

@ -62,8 +62,14 @@ class ItemTest {
} }
@Test @Test
void productionRubberAndPlastic() { void productionRubberAndPlastic(
) {
test("rubberAndPlastic", Database.Rubber, Database.Plastic); test("rubberAndPlastic", Database.Rubber, Database.Plastic);
} }
@Test
void productionAluminumIngot() {
test("aluminumIngot", Database.AluminumIngot);
}
} }

View File

@ -0,0 +1,17 @@
package satisfactory.items;
import org.junit.jupiter.api.Test;
import satisfactory.Database;
import static org.junit.jupiter.api.Assertions.fail;
import static satisfactory.items.TestHelper.test;
class Phase4Test {
@Test
void testPhase4() {
test("phase4", Database.AssemblyDirectorSystem, Database.MagneticFieldGenerator);
fail("Missing items!");
//test("phase4", Database.AssemblyDirectorSystem, Database.MagneticFieldGenerator, Database.ThermalPropulsionRocket, Database.NuclearPasta);
}
}

View File

@ -94,6 +94,19 @@ public class ValidatedValues {
ref.put(item, 1.); ref.put(item, 1.);
values.put(item, ref); values.put(item, ref);
} }
{
Item item = Database.AluminumIngot;
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.AluminumScrap, 1.5);
ref.put(Database.Water, 1.5);
ref.put(Database.RawQuartz, 0.5);
ref.put(Database.Silica, 1.25);
ref.put(Database.AluminaSolution, 1.0);
ref.put(Database.Bauxite, 0.5);
ref.put(Database.Coal, 0.5);
ref.put(item, 1.0);
values.put(item, ref);
}
} }
public static Map<Item, Double> get(Item item) { public static Map<Item, Double> get(Item item) {