AetherDb: mining and volatiles descriptions name Diamond and Ammonia; the ExtractionKindDescriptions batch restates them
Every commodity a kind extracts (a recipe with no inputs) is named in that kind's description: checked over the shipped catalog, only these two kinds broke it. The batch applies in the catalog commit that follows; until then the catalog tests for it fail. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1013e2a2e4
commit
ac45a5c836
3 changed files with 66 additions and 2 deletions
37
tests/Aetheria.Shared.Tests/StationKindDescriptionTests.cs
Normal file
37
tests/Aetheria.Shared.Tests/StationKindDescriptionTests.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System.Linq;
|
||||
using GameCult.Caching;
|
||||
using Xunit;
|
||||
|
||||
// A station kind's description is what a player and a planner read of what it does; the recipes at the kind are what it does.
|
||||
public sealed class StationKindDescriptionTests
|
||||
{
|
||||
// Every good the shipped catalog extracts at a station kind (a commodity recipe with no inputs; a gear recipe is a design on offer, not raw) is named in that kind's description.
|
||||
// Kills: a kind that gains an extraction recipe (Diamond at mining, Ammonia at volatiles) while its description still lists the old set.
|
||||
[Fact]
|
||||
public void EveryRawGoodAKindExtractsIsNamedInItsDescription()
|
||||
{
|
||||
using var db = AetherDb.Open();
|
||||
var cache = db.Cache;
|
||||
var unnamed = cache.GetAll<RecipeData>().Where(recipe => recipe.Inputs.Count == 0 && recipe.StationKind.IsSet())
|
||||
.Select(recipe => (Kind: cache.Get(recipe.StationKind), Output: cache.Get(recipe.Output)))
|
||||
.Where(pair => pair.Kind != null && (pair.Output is SimpleCommodityData || pair.Output is CompoundCommodityData) && !pair.Kind.Description.Contains(pair.Output.Name))
|
||||
.Select(pair => $"{pair.Kind.Name} extracts {pair.Output.Name}, which its description omits")
|
||||
.Distinct().OrderBy(line => line).ToList();
|
||||
Assert.True(unnamed.Count == 0, string.Join("\n", unnamed));
|
||||
}
|
||||
|
||||
// The two kinds the rule was cut for, by name, so the rule cannot pass by the catalog having lost the recipes.
|
||||
[Fact]
|
||||
public void MiningExtractsDiamondAndVolatilesAmmonia()
|
||||
{
|
||||
using var db = AetherDb.Open();
|
||||
var cache = db.Cache;
|
||||
string Extracted(string kindId) => string.Join(",", cache.GetAll<RecipeData>()
|
||||
.Where(recipe => recipe.Inputs.Count == 0 && recipe.StationKind.IsSet() && recipe.StationKind.Key.Equals(StationKindData.KeyOf(kindId)))
|
||||
.Select(recipe => cache.Get(recipe.Output).Name));
|
||||
Assert.Contains("Diamond", Extracted("mining"));
|
||||
Assert.Contains("Ammonia", Extracted("volatiles"));
|
||||
Assert.Contains("Diamond", cache.Get<StationKindData>(StationKindData.KeyOf("mining")).Description);
|
||||
Assert.Contains("Ammonia", cache.Get<StationKindData>(StationKindData.KeyOf("volatiles")).Description);
|
||||
}
|
||||
}
|
||||
24
tools/AetherDb/Economy/ExtractionKindDescriptions.cs
Normal file
24
tools/AetherDb/Economy/ExtractionKindDescriptions.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using GameCult.Caching;
|
||||
|
||||
// Economy content, batch 1c: the mining and volatiles station-kind descriptions name every good their kind now extracts.
|
||||
// MunitionsFeed gave mining a Diamond recipe and volatiles an Ammonia recipe; the descriptions the station-round bench
|
||||
// wrote predate them. The same text is StationKindsCatalog.Table's, so a catalog authored fresh says the same thing.
|
||||
// Sets the description whatever it was, so a rerun converges.
|
||||
public sealed class ExtractionKindDescriptions : EconomyBatch
|
||||
{
|
||||
public override void Author(EconomyAuthor author)
|
||||
{
|
||||
foreach (var (id, description) in new[]
|
||||
{
|
||||
("mining", StationKindsCatalog.DescriptionOf("mining")),
|
||||
("volatiles", StationKindsCatalog.DescriptionOf("volatiles")),
|
||||
})
|
||||
{
|
||||
var key = StationKindData.KeyOf(id);
|
||||
var kind = author.Catalog.Get<StationKindData>(key) ?? throw new InvalidOperationException($"The catalog holds no station kind '{id}'.");
|
||||
kind.Description = description;
|
||||
author.Put(kind, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,8 +14,8 @@ public static class StationKindsCatalog
|
|||
|
||||
private static readonly (string id, string name, string description)[] Table =
|
||||
{
|
||||
("mining", "Mining Station", "Extracts ore (Rock, New Metals, Gold, Uranium, Potassium) from bodies and belts; consumes tools and food."),
|
||||
("volatiles", "Volatiles Station", "Skims Hydrogen, Methane and Water from gas giants and ice; consumes tools."),
|
||||
("mining", "Mining Station", "Extracts ore (Rock, New Metals, Gold, Uranium, Potassium) and Diamond from bodies and belts; consumes tools and food."),
|
||||
("volatiles", "Volatiles Station", "Skims Hydrogen, Methane, Ammonia and Water from gas giants and ice; consumes tools."),
|
||||
("agriculture", "Agriculture Station", "Grows Organics (Algae, Fungi, Bacteria, Animal Products) from Water and Potassium; feeds residential."),
|
||||
("processing", "Processing Station", "Refines ore and volatiles into Metals, Alloys and Compounds."),
|
||||
("fabrication", "Fabrication Station", "Turns Alloys and Compounds into Manufacturing compounds, Assemblies, gear, Ammo and consumer goods."),
|
||||
|
|
@ -33,6 +33,9 @@ public static class StationKindsCatalog
|
|||
("waystation", "Waystation", "Fuel, repair and medicine along a corridor."),
|
||||
};
|
||||
|
||||
// A kind's authored description: the one text a fresh catalog gets and an economy batch restates.
|
||||
public static string DescriptionOf(string id) => Table.Single(row => row.id == id).description;
|
||||
|
||||
public static int Run(CultCache cache, bool apply, TextWriter output)
|
||||
{
|
||||
var held = cache.GetAll<StationKindData>().Select(kind => cache.RefOf(kind).Key.Value).ToHashSet(StringComparer.Ordinal);
|
||||
|
|
|
|||
Loading…
Reference in a new issue