diff --git a/Assets/Scripts/ServerShared/EconomyChecks.cs b/Assets/Scripts/ServerShared/EconomyChecks.cs index 9a63d1688..274e9990b 100644 --- a/Assets/Scripts/ServerShared/EconomyChecks.cs +++ b/Assets/Scripts/ServerShared/EconomyChecks.cs @@ -420,7 +420,7 @@ public static class EconomyChecks bool IsCommodityKey(string key) => recipes.TryGetValue(key, out var r) && Recipes.IsCommodity(catalog.Get(r.Output)); var consumerRoles = new HashSet(recipes.Values.Where(r => Recipes.IsConsumerGood(catalog, r)) .SelectMany(r => Recipes.RolesOf(catalog.Get(r.Output))).Select(role => role.Name), StringComparer.Ordinal); - var gearRoles = new HashSet(recipes.Values.Where(r => !Recipes.IsCommodity(catalog.Get(r.Output)) && Recipes.IsRoleRecipe(catalog, r)) + var gearRoles = new HashSet(recipes.Values.Where(r => !Recipes.IsCommodity(catalog.Get(r.Output))) .SelectMany(r => Recipes.RolesOf(catalog.Get(r.Output))).Select(role => role.Name), StringComparer.Ordinal); var upkeep = new HashSet(recipes.Values.SelectMany(r => r.Upkeep).Select(c => c.Commodity.Key.Value), StringComparer.Ordinal); var takenBy = recipes.Values.Where(r => IsCommodityKey(r.Output.Key.Value)) diff --git a/tests/Aetheria.Shared.Tests/EconomyChecksTests.cs b/tests/Aetheria.Shared.Tests/EconomyChecksTests.cs index 4878d1f2a..d3bf3d591 100644 --- a/tests/Aetheria.Shared.Tests/EconomyChecksTests.cs +++ b/tests/Aetheria.Shared.Tests/EconomyChecksTests.cs @@ -381,7 +381,7 @@ public sealed class EconomyChecksTests f.Hull("tug", HullType.Ship, new[] { ("Plate", 1) }); var fault = Assert.Single(EconomyChecks.ConsumerDemand(f.Cache)); Assert.Equal("recipe:commodity:coke", fault.Record); - Assert.Contains("upkeep", fault.Message); + Assert.Contains("'coke' leads into upkeep but no use leads into a consumer good.", fault.Message); f.Good("pot", roles: new[] { ("Casing", 1) }); f.EditRecipe("commodity:coke", r => r.Fills.Add("Casing")); @@ -412,6 +412,22 @@ public sealed class EconomyChecksTests Assert.Empty(EconomyChecks.ConsumerDemand(f.Cache)); } + [Fact] + public void ConsumerDemandNamesEveryUseThatMadeTheGoodShared() + { + using var f = new EconomyFixture(); + f.Good("ore"); + f.Good("acid", inputs: new[] { ("ore", 1) }); + f.Good("warhead", inputs: new[] { ("acid", 1) }, fills: new[] { "Warhead" }); + f.Good("roundb", inputs: new[] { ("acid", 1) }); + f.Good("rounda", inputs: new[] { ("acid", 1) }); + f.Gear("mine", new[] { ("Warhead", 1) }); + Rifle(f, "riflea", "rounda"); + Rifle(f, "rifleb", "roundb"); + var fault = Assert.Single(EconomyChecks.ConsumerDemand(f.Cache)); + Assert.Equal("'acid' leads into Warhead, rounda and roundb but no use leads into a consumer good.", fault.Message); + } + [Fact] public void ConsumerDemandTreatsTheGateAsNoUse() { diff --git a/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs b/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs index f76b56aeb..0a3e8a75a 100644 --- a/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs +++ b/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs @@ -274,9 +274,11 @@ public sealed class EconomyCommandTests public void AnUnknownBatchNameIsRefusedWithoutEchoingIt() { var output = new StringWriter(); - Assert.Equal(1, EconomyCommand.Run(new[] { "author", "CANARY-9f2e-batch" }, output)); + Assert.Equal(1, EconomyCommand.Run(new[] { "author", "CANARY-9f2e-batch", "other-canary" }, output)); var text = output.ToString(); - Assert.Contains("Batches:", text); + Assert.Contains("2 of the names given match no batch.", text); + foreach (var batch in typeof(EconomyBatch).Assembly.GetTypes().Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(EconomyBatch)))) + Assert.Contains(batch.Name, text); Assert.DoesNotContain("CANARY", text); Assert.DoesNotContain("9f2e", text); }