Census: list every distinct maker, don't invent a single one
MakerOf picked the first product for a design from any maker, the same tie-break Brand() uses to resolve a runtime item's actual attribution. That made census silently agree with an attribution it has no business asserting on its own. Census's job is to report what the catalog says, including when a design has more than one seller. MakerOf now lists every distinct maker that sells a design (via its products, manufacturer set), in record-key order, or "(none)" when no product sells it. The existing duplicate (maker, design) detector is unchanged. Verified byte-identical `census` output before and after, since today's catalog has no design with two makers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
40055024b5
commit
fc1c0526fe
1 changed files with 12 additions and 4 deletions
|
|
@ -43,13 +43,21 @@ public static class Program
|
|||
var products = db.Cache.GetAll<FactionProductData>()
|
||||
.OrderBy(p => db.Cache.RefOf(p).Key.Value, StringComparer.Ordinal).ToArray();
|
||||
|
||||
// The manufacturer no longer lives on the design: it is derived the way Brand() derives it, from the
|
||||
// first product in record-key order that sells the design. A design no product sells shows "(none)".
|
||||
// The manufacturer no longer lives on the design; a runtime item picks one via Brand()'s tie-break, but
|
||||
// census must not invent that same attribution for a design with several sellers. Instead it lists every
|
||||
// distinct maker that sells the design (via products), in record-key order. A design no product sells,
|
||||
// or that only unset-manufacturer products sell, shows "(none)".
|
||||
string MakerOf(EquippableItemData item)
|
||||
{
|
||||
var design = db.Cache.RefOf(item).Key;
|
||||
var product = products.FirstOrDefault(p => p.Design.Key.Equals(design));
|
||||
return product == null ? "(none)" : db.Cache.Get(product.Manufacturer)?.ShortName ?? "(none)";
|
||||
var makers = products
|
||||
.Where(p => p.Design.Key.Equals(design) && p.Manufacturer.IsSet())
|
||||
.Select(p => p.Manufacturer.Key)
|
||||
.Distinct()
|
||||
.OrderBy(k => k.Value, StringComparer.Ordinal)
|
||||
.Select(k => db.Cache.Get<Faction>(k)?.ShortName ?? "(none)")
|
||||
.ToArray();
|
||||
return makers.Length == 0 ? "(none)" : string.Join(", ", makers);
|
||||
}
|
||||
|
||||
var kinds = new Dictionary<string, List<string>>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue