From 45cc484049b6b7ae0420de17de4434b399c5f0d1 Mon Sep 17 00:00:00 2001 From: soul Date: Wed, 25 Nov 2026 23:41:11 +0100 Subject: [PATCH] Demo ore sheet: Rock becomes Regolith at price 1, New Metals becomes Nickel-Iron Rulings regolith-demo-retune and rock-becomes-regolith. DemoOre finds the two renamed records by key, takes the ores batch's names and descriptions, and shifts Asteroid yields to 5/4/1 so a full hold is worth about 900 a unit against 920. The mining station description names the new ores (StationKindsCatalog row, restated into the catalog). Catalog rewritten through AetherDb economy author. Co-Authored-By: Claude Sonnet 5.5 --- GameData/Aetheria.cc | 4 +-- tests/Aetheria.Shared.Tests/DemoLoopTests.cs | 2 +- .../DemoOreSheetTests.cs | 24 +++++++++++-- tools/AetherDb/Economy/DemoOre.cs | 34 ++++++++++++++----- tools/AetherDb/StationKindsCatalog.cs | 2 +- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index b58ec27b4..9e50ef64e 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58e9e0ceadc3b4908491563eb9dfad8ee062024b036a4d3d3cab1e00c168cda9 -size 225267 +oid sha256:7bfba1bdf25112c11f8c88a74d9ca53382d5d98245f68a4be9f67065ad5fe6e7 +size 225617 diff --git a/tests/Aetheria.Shared.Tests/DemoLoopTests.cs b/tests/Aetheria.Shared.Tests/DemoLoopTests.cs index a2daf444a..29700b4e0 100644 --- a/tests/Aetheria.Shared.Tests/DemoLoopTests.cs +++ b/tests/Aetheria.Shared.Tests/DemoLoopTests.cs @@ -45,7 +45,7 @@ public sealed partial class RunStartTests var info = player.ChunkInfo(rock); Assert.False(arena.ChunkExists(rock), $"the laser broke the rock: designated {FireControl.Designated(laser, player, rock, out var range)} range {range} info {info} target {player.Target} pos {player.Position} rockpos {arena.ChunkPose(rock.Field, rock.Index)} hp {arena.Settings.AsteroidHitpoints.Evaluate(arena.AsteroidBelts[rock.Field].Data.Asteroids[0].Size)}"); - var ores = new[] { "Rock", "New Metals", "Gold" }; + var ores = new[] { "Regolith", "Nickel-Iron", "Gold" }; var held = player.CargoBays.SelectMany(bay => bay.Cargo.Keys.OfType().Select(stack => (bay, stack))) .Where(h => ores.Contains(_items.GetData(h.stack).Name)).ToArray(); Assert.NotEmpty(held); diff --git a/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs b/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs index 24ef521eb..a9b520151 100644 --- a/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs +++ b/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs @@ -10,7 +10,7 @@ using Xunit; // Asteroid belt holds can be carried and sold, so mine, sell, repair closes on the existing stations. public sealed class DemoOreSheetTests : IDisposable { - private static readonly string[] Ores = { "Rock", "New Metals", "Gold" }; + private static readonly string[] Ores = { "Regolith", "Nickel-Iron", "Gold" }; private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-demoore-" + Guid.NewGuid().ToString("N")); public DemoOreSheetTests() => Directory.CreateDirectory(_root); @@ -33,12 +33,30 @@ public sealed class DemoOreSheetTests : IDisposable var yield = FieldKinds.Yield(Asteroid(cache), default, cache); var amounts = yield.ToDictionary(y => cache.Get(y.Commodity).Name, y => y.Amount); Assert.Equal(Ores.OrderBy(n => n).ToArray(), amounts.Keys.OrderBy(n => n).ToArray()); - Assert.Equal(6f, amounts["Rock"]); - Assert.Equal(3f, amounts["New Metals"]); + Assert.Equal(5f, amounts["Regolith"]); + Assert.Equal(4f, amounts["Nickel-Iron"]); Assert.Equal(1f, amounts["Gold"]); Assert.Equal(yield.Select(y => y.Commodity.Key.Value).OrderBy(k => k, StringComparer.Ordinal), yield.Select(y => y.Commodity.Key.Value)); } + // Ruling regolith-demo-retune: Regolith sells for 1, and the yield shifts so a full hold is worth about what it was with Rock at 200. + // Each unit is drawn by abundance weight, and a hold cell takes MaxStack units, so a cell's value is sum(w x price) / sum(w / MaxStack). + [Fact] + public void AFullHoldSellsForAboutWhatItDidBeforeRegolith() + { + using var cache = Shipped(); + var yields = cache.GetAll().Single(k => k.Name == "Asteroid").Yields + .Select(y => (data: cache.Get(y.Commodity), weight: y.Abundance)).ToArray(); + double Cell(IEnumerable<(double weight, double price, double stack)> ores) => + ores.Sum(o => o.weight * o.price) / ores.Sum(o => o.weight / o.stack); + + Assert.Equal(1, yields.Single(y => y.data.Name == "Regolith").data.Price); + var now = Cell(yields.Select(y => ((double) y.weight, (double) y.data.Price, (double) y.data.MaxStack))); + var oldPrice = new Dictionary { ["Regolith"] = (6, 200), ["Nickel-Iron"] = (3, 1000), ["Gold"] = (1, 5000) }; + var before = Cell(yields.Select(y => (oldPrice[y.data.Name].weight, oldPrice[y.data.Name].price, (double) y.data.MaxStack))); + Assert.InRange(now, before * .9, before * 1.1); + } + [Fact] public void EveryYieldedOreCanBeHeldAndSold() { diff --git a/tools/AetherDb/Economy/DemoOre.cs b/tools/AetherDb/Economy/DemoOre.cs index df2a2aff2..14d49bca6 100644 --- a/tools/AetherDb/Economy/DemoOre.cs +++ b/tools/AetherDb/Economy/DemoOre.cs @@ -3,25 +3,32 @@ using System.Collections.Generic; using System.Linq; using GameCult.Caching; -// Interim ore sheet (ruling mining-demo-ore-minimal-yields-now): the Asteroid field kind yields Rock, New Metals and Gold, and those +// Interim ore sheet (ruling mining-demo-ore-minimal-yields-now): the Asteroid field kind yields Regolith, Nickel-Iron and Gold, and those // three can be held (a 1x1 shape, a mass) and are sold (a price). The economy ores batch may rewrite the yields by element id. // Prices are ruling mining-demo-ore-prices-gear-scale, gear-scale so the mine, sell, repair loop closes: a retune is an edit here and a rerun. +// Ruling regolith-demo-retune (rock-becomes-regolith): Rock becomes Regolith at price 1 and New Metals becomes Nickel-Iron; yield shifts toward +// Nickel-Iron so a full hold sells for about what it did (expected 900.5 a unit against 920). The names and descriptions are the ores batch's. // Munitions and MunitionsFeed never rewrite these three commodities, so rerunning them does not clobber this sheet. public sealed class DemoOre : EconomyBatch { - private const int RockPrice = 200; - private const int NewMetalsPrice = 1000; + private const int RegolithPrice = 1; + private const int NickelIronPrice = 1000; private const int GoldPrice = 5000; - // Authored element ids (the cache takes a hand-written id only as 12 lowercase hex): asteroid-rock, asteroid-new-metals, asteroid-gold. + // The two renamed records are found by key, so a rerun converges after the rename (the ores batch finds them the same way). + private static readonly CultRecordKey RegolithKey = new CultRecordKey("043997a8-0661-4206-ab8a-10215ecf4efc"); + private static readonly CultRecordKey NickelIronKey = new CultRecordKey("00b5b3b2-2fc5-4adb-a1d7-c1a35d19afd3"); + + // Authored element ids (the cache takes a hand-written id only as 12 lowercase hex): asteroid regolith, nickel-iron, gold. The ids keep + // their first names; the ores batch rewrites yields by element id. private const string RockId = "a57e0c000001"; private const string NewMetalsId = "a57e0c000002"; private const string GoldId = "a57e0c000003"; public override void Author(EconomyAuthor author) { - author.Edit("Rock", o => { o.Shape = new Shape(); o.Price = RockPrice; }); - author.Edit("New Metals", o => { o.Shape = new Shape(); o.Price = NewMetalsPrice; o.Mass = 2; }); + Rename(author, RegolithKey, "Regolith", "Crushed silicate rubble and dust, the bulk of every belt: what is left when the ore is picked out, and the aggregate cast habitats and berms are made of.", RegolithPrice, null); + Rename(author, NickelIronKey, "Nickel-Iron", "Native nickel-iron, kamacite and taenite, cut from metallic asteroids: about nine parts iron to one of nickel, with a trace of cobalt and platinum.", NickelIronPrice, 2); author.Edit("Gold", o => { o.Shape = new Shape(); o.Price = GoldPrice; }); var kinds = author.Catalog.GetAll().Where(k => k.Name == "Asteroid").ToArray(); @@ -29,13 +36,24 @@ public sealed class DemoOre : EconomyBatch var asteroid = kinds[0]; asteroid.Yields = new List { - Yield(author, "Rock", 6, RockId), - Yield(author, "New Metals", 3, NewMetalsId), + Yield(author, "Regolith", 5, RockId), + Yield(author, "Nickel-Iron", 4, NewMetalsId), Yield(author, "Gold", 1, GoldId) }; author.Put(asteroid, author.Catalog.RefOf(asteroid).Key); } + private static void Rename(EconomyAuthor author, CultRecordKey key, string name, string description, int price, float? mass) + { + var record = author.Catalog.Get(key) ?? throw new InvalidOperationException($"The catalog holds no simple commodity {key.Value}."); + record.Name = name; + record.Description = description; + record.Price = price; + record.Shape = new Shape(); + if (mass.HasValue) record.Mass = mass.Value; + author.Put(record, key); + } + private static FieldYield Yield(EconomyAuthor author, string name, float abundance, string id) { var item = author.Catalog.GetAll().Single(i => i.Name == name); diff --git a/tools/AetherDb/StationKindsCatalog.cs b/tools/AetherDb/StationKindsCatalog.cs index 51d865f57..37be9b0ff 100644 --- a/tools/AetherDb/StationKindsCatalog.cs +++ b/tools/AetherDb/StationKindsCatalog.cs @@ -14,7 +14,7 @@ public static class StationKindsCatalog private static readonly (string id, string name, string description)[] Table = { - ("mining", "Mining Station", "Extracts ore (Rock, New Metals, Gold, Potassium) and Diamond from bodies and belts; consumes tools and food."), + ("mining", "Mining Station", "Extracts ore (Regolith, Nickel-Iron, Gold, Potassium) and Diamond from bodies and belts; consumes tools and food."), ("volatiles", "Volatiles Station", "Skims Methane, Ammonia and Water from gas giants and ice; consumes tools."), ("agriculture", "Agriculture Station", "Grows Algae from Water and Potassium; feeds residential."), ("processing", "Processing Station", "Refines ore and volatiles into Metals, Alloys and Compounds."),