Skip to content

[Discussion] Handling mismatched assignments of entity and recipe. #591

Description

@DaleStan

A somewhat sensible resolution to the removed test in #569 is adding a reactor to ProductionTableContentTests.lua. This will create a Mechanics.reactor@750.heat object to replace the no-longer-generated Mechanics.reactor.heat.

However, when I do that, Change..._ShouldPreserve... starts running assembly-machine recipes in the reactor. Also, all three tests run Mechanics.generator.electricity in the assembly machines. The tests work fine once the expected counts are updated, but should the model be objecting that the recipe and crafter are incompatible?

In the real world, the most likely cause is someone changing their mod settings to turn on the classic "Max 2×⁠N ingredients in an Assembly Machine N" limitation.

Diff

--- a/Yafc.Model.Tests/Model/ProductionTableContentTests.cs
+++ b/Yafc.Model.Tests/Model/ProductionTableContentTests.cs
@@ -23,7 +23,7 @@ public class ProductionTableContentTests {
         table.modules.beaconsPerBuilding = 2;
         table.modules.autoFillPayback = MathF.Sqrt(float.MaxValue);

-        RunTest(row, testCombinations, (3 * 3 + 3 * 1) * (9 + 2) * 6); // Crafter&fuel * modules * available fixed values
+        RunTest(row, testCombinations, (4 * 3 + 3 * 1) * (9 + 2) * 6); // Crafter&fuel * modules * available fixed values

         // Cycle through all crafters (3 burner, 3 electric), fuels (3+1), and internal modules (9 + empty + default), and call assert for each combination.
         // assert will ensure the currently fixed value has not changed by more than 0.01%.
@@ -65,7 +65,7 @@ public class ProductionTableContentTests {
         List<Module> modules = [.. Database.allModules.Where(m => !m.name.Contains("productivity"))];
         EntityBeacon beacon = Database.allBeacons.Single();

-        RunTest(row, testCombinations, (3 * 3 + 3 * 1) * 6 * 13 * 32 * 6); // Crafter&fuel * modules * beacon count * payback values * available fixed values
+        RunTest(row, testCombinations, (4 * 3 + 3 * 1) * 6 * 13 * 32 * 6); // Crafter&fuel * modules * beacon count * payback values * available fixed values

         // Cycle through all crafters (3 burner, 3 electric), fuels (3+1), and beacon modules (6). Also cycle through 0-12 beacons per building and 32 possible payback values.
         // Call assert for each combination. assert will ensure the currently fixed value has not changed by more than 0.01%.
@@ -189,11 +189,11 @@ public class ProductionTableContentTests {
         }

         // Ignoring quality, we have:
-        // 2 recipes, 2 mechanics, 3 electric crafters and 3 burner crafters (with 3 fuels), and 9 modules (plus no modules)
+        // 2 recipes, 2 mechanics, 3 electric crafters and 4 burner crafters (with 3 fuels), and 9 modules (plus no modules)
         // Considering quality, we have:
-        // 4 recipes, 2 mechanics, 6 electric crafters and 6 burner crafters (with 6 fuels), and 18 modules (plus no modules)
-        // All combinations should be tested
-        Assert.Equal((4 + 2) * (6 + 6 * 6) * (18 + 1), testCount);
+        // 4 recipes, 2 mechanics, 6 electric crafters and 8 burner crafters (with 6 fuels), and 18 modules (plus no modules)
+        // All combinations should be tested, including combinations where the crafter and recipe are incompatible:
+        Assert.Equal((4 + 2) * (6 + 8 * 6) * (18 + 1), testCount);
     }

     /// <summary>
--- a/Yafc.Model.Tests/Model/ProductionTableContentTests.lua
+++ b/Yafc.Model.Tests/Model/ProductionTableContentTests.lua
@@ -289,6 +289,25 @@ data = {
         },
       },
     },
+    reactor = {
+      reactor = {
+        consumption = "1MW",
+        energy_source = {
+          fuel_categories = {
+            "chemical",
+          },
+          fuel_inventory_size = 1,
+          type = "burner",
+        },
+        heat_buffer = {
+          max_temperature = 750,
+          max_transfer = "10GW",
+          specific_heat = "5.4MJ",
+        },
+        name = "reactor",
+        type = "reactor",
+      },
+    },
     recipe = {
       recipe = {
         type = "recipe",
@@ -334,6 +353,7 @@ defines.prototypes = {
   entity = {
     ["assembling-machine"] = 0,
     beacon = 0,
+    reactor = 0,
   },
   item = {
     item = 0,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions