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 <noreply@anthropic.com>
This commit is contained in:
parent
012f33e6ac
commit
45cc484049
5 changed files with 51 additions and 15 deletions
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
Binary file not shown.
|
|
@ -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<SimpleCommodity>().Select(stack => (bay, stack)))
|
||||
.Where(h => ores.Contains(_items.GetData(h.stack).Name)).ToArray();
|
||||
Assert.NotEmpty(held);
|
||||
|
|
|
|||
|
|
@ -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<FieldKindData>().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<string, (double weight, double price)> { ["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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<SimpleCommodityData>("Rock", o => { o.Shape = new Shape(); o.Price = RockPrice; });
|
||||
author.Edit<SimpleCommodityData>("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<SimpleCommodityData>("Gold", o => { o.Shape = new Shape(); o.Price = GoldPrice; });
|
||||
|
||||
var kinds = author.Catalog.GetAll<FieldKindData>().Where(k => k.Name == "Asteroid").ToArray();
|
||||
|
|
@ -29,13 +36,24 @@ public sealed class DemoOre : EconomyBatch
|
|||
var asteroid = kinds[0];
|
||||
asteroid.Yields = new List<FieldYield>
|
||||
{
|
||||
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<SimpleCommodityData>(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<SimpleCommodityData>().Single(i => i.Name == name);
|
||||
|
|
|
|||
|
|
@ -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."),
|
||||
|
|
|
|||
Loading…
Reference in a new issue