Delete Faction.BossHull and its readers
Key 10 is retired (shipped values left in place). GenerateBossLoadout is its fallback alone; the factions command no longer reads a named boss; the two BossHull tests go (the named-but-unsold case cannot exist under a product-first derivation). Galaxy.PlaceFactionsMain, the Exit_open test and the derivation arrive in the next commit; this commit does not build. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eb27ced147
commit
4ab2ba15c7
4 changed files with 7 additions and 66 deletions
|
|
@ -39,8 +39,7 @@ public class Faction
|
|||
|
||||
// Key 9 was the faction's name-file link, retired by ruling faction-curated-place-names; never reuse it.
|
||||
|
||||
[Inspectable, JsonProperty("bossHull"), Key(10)]
|
||||
public CultRecordRef<HullData> BossHull;
|
||||
// Key 10 was the faction's named boss hull, retired by boss-hull-derived: a faction's boss hulls are derived from the Boss hulls it makes; never reuse it.
|
||||
|
||||
[Inspectable, JsonProperty("influence"), Key(11)]
|
||||
public int InfluenceDistance = 4;
|
||||
|
|
|
|||
|
|
@ -209,19 +209,11 @@ public class LoadoutGenerator
|
|||
return (available, preferManufacturers);
|
||||
}
|
||||
|
||||
// A faction's boss: its BossHull when the faction sets one and a product sells it, else the most expensive ship hull
|
||||
// the faction can be offered, with the gap logged. Null only when no ship hull is on offer at all.
|
||||
// A faction's boss: the most expensive ship hull the faction can be offered, with the gap logged. Null only when no
|
||||
// ship hull is on offer at all.
|
||||
public EntityPack GenerateBossLoadout()
|
||||
{
|
||||
var bossHull = Faction != null && Faction.BossHull.IsSet() ? ItemManager.ItemData.Get(Faction.BossHull) : null;
|
||||
if (bossHull != null)
|
||||
{
|
||||
var boss = GenerateShipLoadout(hull => hull == bossHull);
|
||||
if (boss != null) return boss;
|
||||
ItemManager.Log($"{Faction.Name}'s BossHull {bossHull.Name} is not sold by any product; its boss flies the most expensive ship hull instead.");
|
||||
}
|
||||
else
|
||||
ItemManager.Log($"{Faction?.Name ?? "This faction"} has no BossHull; its boss flies the most expensive ship hull instead.");
|
||||
ItemManager.Log($"{Faction?.Name ?? "This faction"} makes no boss hull; its boss flies the most expensive ship hull instead.");
|
||||
|
||||
var (available, _) = AvailableProducts<HullData>(hull => hull.HullType == HullType.Ship, required: true);
|
||||
if (available.Length == 0) return null;
|
||||
|
|
|
|||
|
|
@ -70,50 +70,6 @@ public sealed partial class RunStartTests
|
|||
Assert.DoesNotContain(pack.Entities, entity => !entity.Boss && entity is ShipPack);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Boss_hull_from_BossHull_else_fallback()
|
||||
{
|
||||
var galaxy = DemoGalaxy(1);
|
||||
var antagonist = Zhestokost(galaxy);
|
||||
var hulls = SoldShipHulls().OrderByDescending(hull => hull.Price).ThenBy(hull => hull.Name, StringComparer.Ordinal).ToArray();
|
||||
var priciest = hulls.First();
|
||||
var cheaper = hulls.Last();
|
||||
Assert.True(cheaper.Price < priciest.Price, "the catalog needs two ship hulls of different price for this test to tell them apart");
|
||||
|
||||
// Set and sold: the boss flies it, and nothing is logged about a gap.
|
||||
antagonist.BossHull = _cache.RefOf(cheaper);
|
||||
var log = new List<string>();
|
||||
var items = LoggingItems(log);
|
||||
var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
|
||||
Assert.Equal(cheaper.Name, HullName(items, boss));
|
||||
Assert.DoesNotContain(log, line => line.Contains("BossHull"));
|
||||
|
||||
// Unset: the most expensive ship hull on offer, and the log names the missing BossHull.
|
||||
antagonist.BossHull = default;
|
||||
log.Clear();
|
||||
boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
|
||||
Assert.Equal(priciest.Name, HullName(items, boss));
|
||||
Assert.Contains(log, line => line.Contains("Zhestokost") && line.Contains("no BossHull"));
|
||||
}
|
||||
|
||||
// Set but sold by no product: the boss falls back the same way, and the log says which hull has no seller.
|
||||
[Fact]
|
||||
public void Boss_hull_nobody_sells_falls_back()
|
||||
{
|
||||
var galaxy = DemoGalaxy(1);
|
||||
var antagonist = Zhestokost(galaxy);
|
||||
var sold = SoldShipHulls();
|
||||
// A ship hull no product sells, dearer than any that is sold: the fallback must not pick it.
|
||||
var unsold = new HullData { Name = "Unsold Test Hull", HullType = HullType.Ship, Price = sold.Max(hull => hull.Price) + 1 };
|
||||
_cache.Upsert(unsold);
|
||||
antagonist.BossHull = _cache.RefOf(unsold);
|
||||
var log = new List<string>();
|
||||
var items = LoggingItems(log);
|
||||
var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
|
||||
Assert.Equal(sold.OrderByDescending(hull => hull.Price).ThenBy(hull => hull.Name, StringComparer.Ordinal).First().Name, HullName(items, boss));
|
||||
Assert.Contains(log, line => line.Contains(unsold.Name) && line.Contains("BossHull"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exit_sealed_until_boss_dies()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -583,8 +583,7 @@ public static class Program
|
|||
|
||||
// Every CultRecordRef in the catalog that resolves to nothing, as "<record> <DeclaringType.Member> -> <key>".
|
||||
// Each "clear <DeclaringType.Member>" argument unsets that member's dangling refs, or removes that dictionary's
|
||||
// dangling keys (Faction.BossHull clears boss hulls that would claim a chokepoint no boss can spawn in). Dry
|
||||
// run unless passed "apply", which alone opens the catalog writable and lands every changed record in one commit.
|
||||
// dangling keys. Dry run unless passed "apply", which alone opens the catalog writable and lands every changed record in one commit.
|
||||
private static int Dangling(string[] args)
|
||||
{
|
||||
var apply = args.Contains("apply");
|
||||
|
|
@ -702,19 +701,14 @@ public static class Program
|
|||
var db = AetherDb.Open();
|
||||
var products = db.Cache.GetAll<FactionProductData>().ToArray();
|
||||
Console.WriteLine($"{"faction",-26} {"short",-13} {"places",-22} {"boss hull",-14} {"influence",-9} {"doctrine",-10} products");
|
||||
var broken = 0;
|
||||
foreach (var faction in db.Cache.GetAll<Faction>().OrderBy(f => f.Name))
|
||||
{
|
||||
var key = db.Cache.RefOf(faction).Key;
|
||||
var boss = !faction.BossHull.IsSet()
|
||||
? "none"
|
||||
: db.Cache.Get(faction.BossHull)?.Name ?? "DANGLING";
|
||||
if (boss == "DANGLING") broken++;
|
||||
var boss = "none";
|
||||
Console.WriteLine($"{faction.Name,-26} {faction.ShortName,-13} {faction.Places.Length,-22} {boss,-14} {faction.InfluenceDistance,-9} {(faction.Doctrine == null ? "none" : faction.Doctrine.EngageOn.ToString()),-10} " +
|
||||
products.Count(p => p.Manufacturer.Key.Equals(key)));
|
||||
}
|
||||
Console.WriteLine($"\n{broken} factions carry a link that would break generation");
|
||||
return broken;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// What the saved run actually holds per zone. A zone carrying orbits but no orbital entities was packed by a
|
||||
|
|
|
|||
Loading…
Reference in a new issue