diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index c242e3e42..7265941c9 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -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 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; diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 55eea27f8..67cc7f6b4 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -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(hull => hull.HullType == HullType.Ship, required: true); if (available.Length == 0) return null; diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs index 25b46fdd3..5d133893f 100644 --- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs +++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs @@ -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(); - 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(); - 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() { diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs index 5df9ed99c..500d85a8e 100644 --- a/tools/AetherDb/Program.cs +++ b/tools/AetherDb/Program.cs @@ -583,8 +583,7 @@ public static class Program // Every CultRecordRef in the catalog that resolves to nothing, as " -> ". // Each "clear " 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().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().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