diff --git a/server/NeonSprawl.Server.Tests/Game/Contracts/ContractTemplateCatalogLoaderTests.cs b/server/NeonSprawl.Server.Tests/Game/Contracts/ContractTemplateCatalogLoaderTests.cs index 7153d3b..7eef3cd 100644 --- a/server/NeonSprawl.Server.Tests/Game/Contracts/ContractTemplateCatalogLoaderTests.cs +++ b/server/NeonSprawl.Server.Tests/Game/Contracts/ContractTemplateCatalogLoaderTests.cs @@ -155,7 +155,7 @@ public class ContractTemplateCatalogLoaderTests { // Arrange var (_, contractsDir, schemaPath) = CreateTempContentLayout(); - var emptyCatalog = """{"schemaVersion": 1, "contractTemplates": []}"""; + const string emptyCatalog = """{"schemaVersion": 1, "contractTemplates": []}"""; File.WriteAllText(Path.Combine(contractsDir, "prototype_contract_templates.json"), emptyCatalog, Encoding.UTF8); // Act var ex = Record.Exception(() => LoadCatalog(contractsDir, schemaPath)); diff --git a/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalog.cs b/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalog.cs index fdbc861..c89df35 100644 --- a/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalog.cs +++ b/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalog.cs @@ -3,25 +3,19 @@ using System.Collections.ObjectModel; namespace NeonSprawl.Server.Game.Contracts; /// In-memory contract template catalog loaded at startup (NEO-145). Game code should prefer for lookups. -public sealed class ContractTemplateCatalog +public sealed class ContractTemplateCatalog( + string contractsDirectory, + IReadOnlyDictionary byId, + int catalogJsonFileCount) { - public ContractTemplateCatalog( - string contractsDirectory, - IReadOnlyDictionary byId, - int catalogJsonFileCount) - { - ContractsDirectory = contractsDirectory; - ById = new ReadOnlyDictionary(new Dictionary(byId, StringComparer.Ordinal)); - CatalogJsonFileCount = catalogJsonFileCount; - } - /// Absolute path to the directory that was enumerated for *_contract_templates.json catalogs. - public string ContractsDirectory { get; } + public string ContractsDirectory { get; } = contractsDirectory; - public IReadOnlyDictionary ById { get; } + public IReadOnlyDictionary ById { get; } = + new ReadOnlyDictionary(new Dictionary(byId, StringComparer.Ordinal)); public int DistinctTemplateCount => ById.Count; /// Number of *_contract_templates.json files under . - public int CatalogJsonFileCount { get; } + public int CatalogJsonFileCount { get; } = catalogJsonFileCount; } diff --git a/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalogLoader.cs b/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalogLoader.cs index 52126e8..e04c072 100644 --- a/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalogLoader.cs +++ b/server/NeonSprawl.Server/Game/Contracts/ContractTemplateCatalogLoader.cs @@ -233,7 +233,7 @@ public static class ContractTemplateCatalogLoader return new QuestRewardBundleRow(itemGrants, skillXpGrants, reputationGrants); } - private static IReadOnlyList ParseReputationGrantRows(JsonArray? array) + private static List ParseReputationGrantRows(JsonArray? array) { if (array is null || array.Count == 0) return []; @@ -252,7 +252,7 @@ public static class ContractTemplateCatalogLoader return rows; } - private static IReadOnlyList ParseItemGrantRows(JsonArray? array) + private static List ParseItemGrantRows(JsonArray? array) { if (array is null || array.Count == 0) return []; @@ -271,7 +271,7 @@ public static class ContractTemplateCatalogLoader return rows; } - private static IReadOnlyList ParseSkillXpGrantRows(JsonArray? array) + private static List ParseSkillXpGrantRows(JsonArray? array) { if (array is null || array.Count == 0) return []; diff --git a/server/NeonSprawl.Server/Game/Contracts/PrototypeE7M4ContractCatalogRules.cs b/server/NeonSprawl.Server/Game/Contracts/PrototypeE7M4ContractCatalogRules.cs index a0cb3f7..1614f42 100644 --- a/server/NeonSprawl.Server/Game/Contracts/PrototypeE7M4ContractCatalogRules.cs +++ b/server/NeonSprawl.Server/Game/Contracts/PrototypeE7M4ContractCatalogRules.cs @@ -237,18 +237,9 @@ public static class PrototypeE7M4ContractCatalogRules private static NormalizedBundle NormalizeBundle(QuestRewardBundleRow bundle) => new( - bundle.ItemGrants - .OrderBy(g => g.ItemId, StringComparer.Ordinal) - .ThenBy(g => g.Quantity) - .ToArray(), - bundle.SkillXpGrants - .OrderBy(g => g.SkillId, StringComparer.Ordinal) - .ThenBy(g => g.Amount) - .ToArray(), - bundle.ReputationGrants - .OrderBy(g => g.FactionId, StringComparer.Ordinal) - .ThenBy(g => g.Amount) - .ToArray()); + [.. bundle.ItemGrants.OrderBy(g => g.ItemId, StringComparer.Ordinal).ThenBy(g => g.Quantity)], + [.. bundle.SkillXpGrants.OrderBy(g => g.SkillId, StringComparer.Ordinal).ThenBy(g => g.Amount)], + [.. bundle.ReputationGrants.OrderBy(g => g.FactionId, StringComparer.Ordinal).ThenBy(g => g.Amount)]); private static bool BundlesEqual(NormalizedBundle left, NormalizedBundle right) {