Merge origin/eureka/aetheria-release-pirates-record (8e51016f) into master

AetherDb Program.cs: both sides appended a command (pd-gear/mine-launcher, pirates-faction);
kept all, one usage line. GameData/Aetheria.cc: master's blob kept here, pirates-faction
apply replayed on it in the next commit (follow-up catalog-blob-merge-order).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-08 21:37:22 +02:00
commit 2c065937ee
7 changed files with 342 additions and 37 deletions

View file

@ -198,7 +198,7 @@ public class LoadoutGenerator
// Hardpoint gear that no hull in the catalog can mount has no home (operator, 2026-09-30: "we'll need to author a
// bunch more hulls before all the gear variety in the game has a home"): generation never offers it, so no station
// stocks it. It gains one the moment a hull with a hardpoint that takes it exists. Tool gear goes in any interior.
private static bool HasHome(EquippableItemData design, HullData[] hulls) =>
public static bool HasHome(EquippableItemData design, HullData[] hulls) =>
design.HardpointType == HardpointType.Tool || design.HardpointType == HardpointType.Hull ||
hulls.Any(hull => hull.Hardpoints.Any(hardpoint => hardpoint.Takes(design)));

View file

@ -9,30 +9,16 @@ using CultMath;
using Xunit;
// The demo scenario (aetheria-release, cut demo-galaxy): a prelude galaxy of a fixed cast whose antagonist's home is the
// boss zone and the exit. The shipped catalog holds no Pirates faction yet, so each test that needs one adds it to its
// scratch copy of the catalog.
// boss zone and the exit. The cast, the Pirates included, is in the shipped catalog.
public sealed partial class RunStartTests
{
private static readonly uint[] DemoSeeds = { 1, 2, 3, 4, 5 };
// The catalog record the demo's protagonist needs, until the shipped catalog has one. Zone names need a name file,
// and the entrance's station needs a faction whose allegiance reaches some manufacturer, so it reaches every one.
private void AddPirates()
{
var pirates = new Faction
{
Name = "Pirates", ShortName = "Pirates", GeonameFile = _cache.RefOf(_cache.GetAll<NameFile>().First())
};
foreach (var faction in _cache.GetAll<Faction>().ToArray()) pirates.Allegiance[_cache.RefOf(faction)] = 1;
_cache.Upsert(pirates);
}
private Galaxy DemoGalaxy(uint seed) => RunStart.Generate(new DemoTerminus(), Inputs(() => seed));
[Fact]
public void DemoTerminus_fixed_cast()
{
AddPirates();
foreach (var seed in DemoSeeds)
Assert.Equal(new[] { "Pirates", "Zhestokost", "Lucent Media", "Aeronautics Unlimited" },
DemoGalaxy(seed).Factions.Select(faction => faction.Name));
@ -41,7 +27,6 @@ public sealed partial class RunStartTests
[Fact]
public void DemoTerminus_gate_at_antagonist_home()
{
AddPirates();
foreach (var seed in DemoSeeds)
{
var galaxy = DemoGalaxy(seed);
@ -60,7 +45,6 @@ public sealed partial class RunStartTests
[Fact]
public void DemoTerminus_standing_survives_continue()
{
AddPirates();
var (galaxy, arena, staged, failures) = Launch(new DemoTerminus(), Inputs(() => 1));
Assert.True(failures.Count == 0, string.Join("; ", failures));
galaxy.Entrance.Contents = arena;
@ -83,11 +67,16 @@ public sealed partial class RunStartTests
restored.BossZones.Select(boss => (boss.Key.Name, Array.IndexOf(restored.Zones, boss.Value))));
}
// On the shipped catalog, which has no Pirates, the run does not start: the galaxy refuses, naming the cast field,
// and the scenario never reaches staging.
// A catalog without the Pirates (the shipped record and its products removed from this scratch copy) does not start the
// run: the galaxy refuses, naming the cast field, and the scenario never reaches staging.
[Fact]
public void DemoTerminus_missing_cast_refused()
{
var pirates = _cache.GetAll<Faction>().Single(faction => faction.Name == "Pirates");
var piratesRef = _cache.RefOf(pirates);
foreach (var product in _cache.GetAll<FactionProductData>().Where(product => product.Manufacturer.Equals(piratesRef)).ToArray())
Assert.True(_cache.Remove(_cache.RefOf(product).Key));
Assert.True(_cache.Remove(piratesRef.Key));
Assert.DoesNotContain(_cache.GetAll<Faction>(), faction => faction.Name.StartsWith("Pirates", StringComparison.Ordinal));
var refusal = Assert.Throws<InvalidOperationException>(() => DemoGalaxy(1));
Assert.Contains("Pirates", refusal.Message);
@ -108,7 +97,6 @@ public sealed partial class RunStartTests
[Fact]
public void DemoTerminus_player_flies_a_non_pirates_brand_hull_the_longinus()
{
AddPirates();
foreach (var seed in DemoSeeds)
{
var (galaxy, _, staged, failures) = Launch(new DemoTerminus(), Inputs(() => seed));
@ -130,7 +118,6 @@ public sealed partial class RunStartTests
[Fact]
public void DemoTerminus_player_carries_the_longinus_default_fit()
{
AddPirates();
string Fit(Entity ship) => string.Join(";", ship.Equipment
.Select(item => $"{item.Data.Name}@{item.Position}/{item.EquippableItem.Rotation}")
.OrderBy(entry => entry, StringComparer.Ordinal));
@ -151,7 +138,6 @@ public sealed partial class RunStartTests
[Fact]
public void DemoTerminus_region_is_sixty_four_zones_linked_at_half_density()
{
AddPirates();
string Links(Galaxy g) => string.Join(";", g.Zones.Select(zone =>
string.Join(",", zone.AdjacentZones.Select(adjacent => Array.IndexOf(g.Zones, adjacent)).OrderBy(index => index))));
Galaxy Reference(uint seed, float density)
@ -177,7 +163,6 @@ public sealed partial class RunStartTests
[Fact]
public void ACastNamingNoQuestFactionPlacesNoQuestZone()
{
AddPirates();
var galaxy = DemoGalaxy(1);
Assert.Equal(4, galaxy.HomeZones.Count);
Assert.Equal(4, galaxy.Factions.Length);

View file

@ -0,0 +1,155 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using GameCult.Caching;
using GameCult.Caching.MessagePack;
using Xunit;
// AetherDb's pirates-faction command (aetheria-release, cut pirates-record), run on a scratch copy of the shipped catalog
// with the Pirates removed from it.
public sealed class PiratesFactionCommandTests : IDisposable
{
private readonly string _root = Path.Combine(Path.GetTempPath(), "pirates-command-" + Guid.NewGuid().ToString("N"));
private string CatalogPath => Path.Combine(_root, "GameData", "Aetheria.cc");
public PiratesFactionCommandTests()
{
Directory.CreateDirectory(Path.Combine(_root, "GameData"));
File.Copy(Path.Combine(AetherDb.FindRoot(), "GameData", "Aetheria.cc"), CatalogPath);
// AetherDb.Open composes the process-wide registry, which in this test host also sees this assembly's TestCatalogGlobal
// (see FireControlCut7Tests). So the copy is stripped through a registry scoped to the shipped assembly and then given
// the record that registry's shared sibling demands, as AetheriaStoresTests does.
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
using (var cache = new CultCache(registry))
{
cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes);
var pirates = cache.GetAll<Faction>().Single(faction => faction.Name == "Pirates");
var ours = cache.RefOf(pirates);
foreach (var product in cache.GetAll<FactionProductData>().Where(product => product.Manufacturer.Equals(ours)).ToArray())
Assert.True(cache.Remove(cache.RefOf(product).Key));
Assert.True(cache.Remove(ours.Key));
cache.FlushAsync().Wait();
}
using (var cache = new CultCache())
{
cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes);
cache.Upsert(new TestCatalogGlobal { Name = "Temperament" });
cache.FlushAsync().Wait();
}
}
public void Dispose() => Directory.Delete(_root, true);
private (Faction[] Pirates, FactionProductData[] Products) Read()
{
var db = AetherDb.Open(root: _root);
try
{
var pirates = db.Cache.GetAll<Faction>().Where(faction => faction.Name == "Pirates").ToArray();
var products = pirates.Length == 0 ? new FactionProductData[0]
: db.Cache.GetAll<FactionProductData>().Where(product => product.Manufacturer.Equals(db.Cache.RefOf(pirates[0]))).ToArray();
return (pirates, products);
}
finally { db.Cache.Dispose(); }
}
[Fact]
public void A_dry_run_writes_nothing_and_apply_lands_the_record_once()
{
var before = File.ReadAllBytes(CatalogPath);
Assert.Equal(0, Program.PiratesFaction(apply: false, root: _root));
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
Assert.Empty(Read().Pirates);
Assert.Equal(0, Program.PiratesFaction(apply: true, root: _root));
var landed = File.ReadAllBytes(CatalogPath);
var (pirates, products) = Read();
var faction = Assert.Single(pirates);
Assert.Equal("Pirates", faction.ShortName);
Assert.StartsWith("A loose coalition of crews and hidden docks", faction.Description);
Assert.Equal(3, faction.InfluenceDistance);
Assert.Equal(new CultMath.float3(.42f, .40f, .37f), faction.PrimaryColor);
Assert.Equal(new CultMath.float3(1f, .45f, .05f), faction.SecondaryColor);
Assert.Equal(12, faction.Allegiance.Count);
Assert.All(faction.Allegiance.Values, value => Assert.Equal(1f, value));
var db = AetherDb.Open(root: _root);
try
{
Assert.Equal("pleiades", db.Cache.Get(faction.GeonameFile).Name);
var expected = new (string Design, string Name, string Description)[]
{
("Autocannon", "🫳🔫", "Serial number filed off. Still shoots."),
("Earp", "🪦🤠", "The previous owner had no further use for it."),
("FastBlast+-", "🧾🚫", "Warranty void where prohibited, which is everywhere."),
("6k Shooter", "🎨🙈", "The logo underneath is somebody else's problem."),
("scorched void policy", "🔥", "Turns out we did start the fire after all."),
("Targeting Computer", "👀🎯", "Somebody else's eyes. They still work."),
("Small Drive", "🔑🏃💨", "Hotwired. Do not ask about the ignition."),
("Store-All Plus", "📦🤫", "Contents not as declared."),
};
Assert.Equal(expected.Select(e => e.Name).OrderBy(n => n, StringComparer.Ordinal), products.Select(p => p.Name).OrderBy(n => n, StringComparer.Ordinal));
foreach (var (designName, name, description) in expected)
{
var product = products.Single(p => p.Name == name);
var design = (CraftedItemData) db.Cache.Get(product.Design);
Assert.Equal(designName, design.Name);
Assert.Equal(description, product.Description);
Assert.Equal((design.Roles ?? new List<ItemRole>()).Select(role => role.Name), (product.Roles ?? new List<ProductRole>()).Select(role => role.Role));
Assert.All(product.Roles, role => { Assert.Equal(.45f, role.Mean); Assert.Equal(.22f, role.StandardDeviation); });
}
}
finally { db.Cache.Dispose(); }
// A second apply finds the faction and changes nothing.
Assert.Equal(0, Program.PiratesFaction(apply: true, root: _root));
Assert.Equal(landed, File.ReadAllBytes(CatalogPath));
}
[Fact]
public void An_existing_Pirates_faction_is_left_as_it_is()
{
var db = AetherDb.Open(catalogWritable: true, root: _root);
db.Cache.Commit(batch => batch.Upsert(typeof(Faction), new Faction { Name = "Pirates", ShortName = "Mine", Description = "authored by hand" }));
db.Cache.Dispose();
Assert.Equal(0, Program.PiratesFaction(apply: true, root: _root));
var (pirates, products) = Read();
Assert.Equal("authored by hand", Assert.Single(pirates).Description);
Assert.Empty(products);
}
[Fact]
public void A_missing_design_refuses_and_lands_nothing()
{
var db = AetherDb.Open(catalogWritable: true, root: _root);
var autocannon = db.Cache.GetAll<WeaponItemData>().Single(weapon => weapon.Name == "Autocannon");
autocannon.Name = "Autocannon (renamed)";
db.Cache.Commit(batch => batch.Upsert(typeof(WeaponItemData), autocannon, db.Cache.RefOf(autocannon).Key));
db.Cache.Dispose();
Assert.Throws<InvalidOperationException>(() => Program.PiratesFaction(apply: true, root: _root));
Assert.Empty(Read().Pirates);
}
[Fact]
public void A_missing_name_file_refuses_and_lands_nothing()
{
var db = AetherDb.Open(catalogWritable: true, root: _root);
var pleiades = db.Cache.GetAll<NameFile>().Single(file => file.Name == "pleiades");
Assert.True(db.Cache.Remove(db.Cache.RefOf(pleiades).Key));
db.Cache.FlushAsync().Wait();
db.Cache.Dispose();
Assert.Throws<InvalidOperationException>(() => Program.PiratesFaction(apply: true, root: _root));
Assert.Empty(Read().Pirates);
}
}

View file

@ -0,0 +1,67 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using Xunit;
// The Pirates record (aetheria-release, cut pirates-record): the shipped catalog's faction of rebrands, named in emoji.
public sealed partial class RunStartTests
{
private Faction ShippedPirates() => _cache.GetAll<Faction>().Single(faction => faction.Name == "Pirates");
private FactionProductData[] PiratesProducts()
{
var pirates = _cache.RefOf(ShippedPirates());
return _cache.GetAll<FactionProductData>().Where(product => product.Manufacturer.Equals(pirates)).ToArray();
}
// The demo's allied faction exists as catalog data with eight generatable rebrands of other makers' designs.
[Fact]
public void PiratesAreInTheShippedCatalog()
{
var pirates = ShippedPirates();
var others = _cache.GetAll<Faction>().Where(faction => faction != pirates).Select(faction => _cache.RefOf(faction)).ToArray();
Assert.NotEmpty(others);
Assert.All(others, other => Assert.True(pirates.Allegiance.ContainsKey(other)));
Assert.NotNull(_cache.Get(pirates.GeonameFile));
var products = PiratesProducts();
Assert.Equal(8, products.Length);
var hulls = _cache.GetAll<HullData>().ToArray();
foreach (var product in products)
{
var design = _cache.Get(product.Design) as EquippableItemData;
Assert.NotNull(design);
Assert.True(LoadoutGenerator.HasHome(design, hulls), $"{design.Name} has no home");
Assert.True(design.Price > 0, $"{design.Name} has no price");
Assert.Contains(_cache.GetAll<FactionProductData>(), other =>
other.Design.Key.Equals(product.Design.Key) && !other.Manufacturer.Equals(product.Manufacturer));
}
}
// The Pirates' products are named in emoji and nothing else: no ASCII letter or digit survives in a name.
[Fact]
public void PiratesProductsAreNamedInEmoji()
{
foreach (var product in PiratesProducts())
{
Assert.False(string.IsNullOrEmpty(product.Name));
Assert.DoesNotContain(product.Name, character => character < 128 && char.IsLetterOrDigit(character));
Assert.Contains(product.Name.EnumerateRunes(), rune => rune.Value >= 0x1F000);
}
}
// Brand finds a lot's product by (maker, design), so a maker may sell one product per design.
[Fact]
public void NoMakerSellsTwoProductsOfOneDesign()
{
var twice = _cache.GetAll<FactionProductData>()
.GroupBy(product => (Maker: product.Manufacturer.Key.Value, Design: product.Design.Key.Value))
.Where(group => group.Count() > 1)
.Select(group => string.Join(", ", group.Select(product => product.Name)))
.ToArray();
Assert.Empty(twice);
}
}

View file

@ -41,7 +41,6 @@ public sealed partial class RunStartTests
[Fact]
public void Boss_spawns_once_in_boss_zone()
{
AddPirates();
foreach (var seed in DemoSeeds.Take(3))
{
var galaxy = DemoGalaxy(seed);
@ -65,7 +64,6 @@ public sealed partial class RunStartTests
[Fact]
public void Boss_spawns_in_a_zone_that_is_not_ambient()
{
AddPirates();
var galaxy = DemoGalaxy(1);
var pack = BossZonePack(galaxy, _items, galaxy.Exit, ambient: false);
Assert.Single(pack.Entities, entity => entity.Boss);
@ -75,7 +73,6 @@ public sealed partial class RunStartTests
[Fact]
public void Boss_hull_from_BossHull_else_fallback()
{
AddPirates();
var galaxy = DemoGalaxy(1);
var antagonist = Zhestokost(galaxy);
var hulls = SoldShipHulls().OrderByDescending(hull => hull.Price).ThenBy(hull => hull.Name, StringComparer.Ordinal).ToArray();
@ -103,7 +100,6 @@ public sealed partial class RunStartTests
[Fact]
public void Boss_hull_nobody_sells_falls_back()
{
AddPirates();
var galaxy = DemoGalaxy(1);
var antagonist = Zhestokost(galaxy);
var sold = SoldShipHulls();
@ -121,7 +117,6 @@ public sealed partial class RunStartTests
[Fact]
public void Exit_sealed_until_boss_dies()
{
AddPirates();
var galaxy = DemoGalaxy(1);
var exit = ZoneOf(galaxy, galaxy.Exit);
var boss = Assert.Single(exit.Entities, entity => entity.IsBoss);
@ -143,7 +138,6 @@ public sealed partial class RunStartTests
[Fact]
public void Boss_mark_survives_continue()
{
AddPirates();
var (galaxy, arena, staged, failures) = Launch(new DemoTerminus(), Inputs(() => 1));
Assert.True(failures.Count == 0, string.Join("; ", failures));
galaxy.Entrance.Contents = arena;
@ -185,7 +179,6 @@ public sealed partial class RunStartTests
[Fact]
public void Exit_sealed_and_logged_when_the_boss_cannot_be_generated()
{
AddPirates();
var galaxy = DemoGalaxy(1);
galaxy.BossZones.Clear();
var log = new List<string>();
@ -201,7 +194,6 @@ public sealed partial class RunStartTests
[Fact]
public void Exit_open_after_save_of_a_slain_boss()
{
AddPirates();
var galaxy = DemoGalaxy(1);
var exit = ZoneOf(galaxy, galaxy.Exit);
Assert.Single(exit.Entities, entity => entity.IsBoss).HeatstrokeDeath.OnNext(Unit.Default);
@ -215,7 +207,6 @@ public sealed partial class RunStartTests
[Fact]
public void Exit_gate_shares_no_point_with_a_wormhole()
{
AddPirates();
var ratio = float.Parse(File.ReadLines(Path.Combine(FindRepoRoot(), "Assets", "Resources", "Settings.asset"))
.Select(line => Regex.Match(line, @"^ WormholeDistanceRatio: (.+)$")).First(match => match.Success).Groups[1].Value.Trim(),
System.Globalization.CultureInfo.InvariantCulture);
@ -244,7 +235,6 @@ public sealed partial class RunStartTests
[InlineData(new[] { 0.0, 45.0, 90.0, 135.0, 180.0, -135.0, -90.0, -45.0 })]
public void Exit_gate_sits_in_the_widest_gap_at_the_wormhole_radius(double[] neighbourDegrees)
{
AddPirates();
var galaxy = DemoGalaxy(1);
var zone = ZoneOf(galaxy, galaxy.Exit);
const float ratio = 0.75f;

View file

@ -96,7 +96,6 @@ public sealed partial class RunStartTests
[Fact]
public void EveryScenarioStages()
{
AddPirates();
Assert.Equal(EveryScenario.Count(), EveryScenario.Select(scenario => scenario.Name).Distinct().Count());
foreach (var scenario in EveryScenario)
{
@ -523,7 +522,6 @@ public sealed partial class RunStartTests
[Fact]
public void EveryUnsoldDesignIsAScenarioTestDesign()
{
AddPirates();
var runs = EveryScenario.Select(scenario => Launch(scenario, Inputs(() => GalaxySeed)).staged).ToList();
Assert.Empty(UnsoldAndUnplaced(runs));

View file

@ -42,8 +42,11 @@ public static class Program
case "field-kinds": return FieldKindsCatalog(args.Contains("apply"));
case "pd-gear": return PdGearCatalog(args.Contains("apply"));
case "mine-launcher": return MineLauncherCatalog(args.Contains("apply"));
case "pirates-faction":
Console.OutputEncoding = new System.Text.UTF8Encoding(false);
return PiratesFaction(args.Contains("apply"));
default:
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], pd-gear [apply]");
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], pd-gear [apply], pirates-faction [apply]");
return 1;
}
}
@ -1702,4 +1705,111 @@ public static class Program
Console.WriteLine($"\nAuthored \"{name}\" in Aetheria.cc");
return 0;
}
// Aetheria release, cut pirates-record (rulings pirates-record-content, catalog-grows-generic-designs-branded-products):
// the Pirates faction and eight rebrands of other makers' designs, named in emoji. The Pirates own no design: their range
// is what they took, so every product points at a design someone else also makes. Each product carries one ProductRole per
// role its design declares, middling and inconsistent (mean .45, sd .22, against makers' .15). Names are stored as the emoji
// only, written here as \U escapes so no editor or shell mangles them; the dry run prints them raw and as code points.
//
// Dry run unless passed "apply", same contract as the other *-migrate commands.
public static int PiratesFaction(bool apply, string root = null)
{
var db = AetherDb.Open(catalogWritable: apply, root: root);
var existing = db.Cache.GetAll<Faction>().FirstOrDefault(f => f.Name == "Pirates");
if (existing != null)
{
Console.WriteLine("A faction named \"Pirates\" already exists; nothing to do.");
return 0;
}
CraftedItemData DesignByName(string name)
{
var matches = db.Cache.GetAll<CraftedItemData>().Where(i => i.Name == name).ToArray();
if (matches.Length != 1) throw new InvalidOperationException($"Expected exactly one design named \"{name}\", found {matches.Length}.");
return matches[0];
}
string CodePoints(string text) => string.Join(" ", text.EnumerateRunes().Select(r => $"U+{r.Value:X4}"));
var nameFile = db.Cache.GetAll<NameFile>().FirstOrDefault(n => n.Name == "pleiades");
if (nameFile == null) throw new InvalidOperationException("No name file named \"pleiades\".");
var others = db.Cache.GetAll<Faction>().ToArray();
var pirates = new Faction
{
Name = "Pirates",
ShortName = "Pirates",
Description = "A loose coalition of crews and hidden docks moving people and goods outside official control. No command, no common law: possession has a maintenance schedule.",
PrimaryColor = new float3(.42f, .40f, .37f),
SecondaryColor = new float3(1f, .45f, .05f),
GeonameFile = db.Cache.RefOf(nameFile),
InfluenceDistance = 3,
};
foreach (var other in others) pirates.Allegiance[db.Cache.RefOf(other)] = 1f;
var rebrands = new (string Design, string Name, string Description)[]
{
("Autocannon", "\U0001FAF3\U0001F52B", "Serial number filed off. Still shoots."),
("Earp", "\U0001FAA6\U0001F920", "The previous owner had no further use for it."),
("FastBlast+-", "\U0001F9FE\U0001F6AB", "Warranty void where prohibited, which is everywhere."),
("6k Shooter", "\U0001F3A8\U0001F648", "The logo underneath is somebody else's problem."),
("scorched void policy", "\U0001F525", "Turns out we did start the fire after all."),
("Targeting Computer", "\U0001F440\U0001F3AF", "Somebody else's eyes. They still work."),
("Small Drive", "\U0001F511\U0001F3C3\U0001F4A8", "Hotwired. Do not ask about the ignition."),
("Store-All Plus", "\U0001F4E6\U0001F92B", "Contents not as declared."),
};
var products = rebrands.Select(r =>
{
var design = DesignByName(r.Design);
return (Design: design, r.Name, r.Description,
Roles: (design.Roles ?? new List<ItemRole>()).Select(role => new ProductRole { Role = role.Name, Mean = .45f, StandardDeviation = .22f }).ToList());
}).ToArray();
Console.WriteLine($"New faction \"{pirates.Name}\": influence {pirates.InfluenceDistance}, names \"{nameFile.Name}\", allegiance 1.0 to {pirates.Allegiance.Count} factions.");
Console.WriteLine($" colours: primary ({pirates.PrimaryColor.x:0.00}, {pirates.PrimaryColor.y:0.00}, {pirates.PrimaryColor.z:0.00}) primer grey, secondary ({pirates.SecondaryColor.x:0.00}, {pirates.SecondaryColor.y:0.00}, {pirates.SecondaryColor.z:0.00}) hazard orange");
Console.WriteLine($" {pirates.Description}");
Console.WriteLine($"\nNew products ({products.Length}):");
foreach (var (design, name, description, roles) in products)
{
var makers = db.Cache.GetAll<FactionProductData>()
.Where(p => p.Design.Key.Equals(db.Cache.RefOf(design).Key))
.Select(p => db.Cache.Get(p.Manufacturer)?.ShortName).OrderBy(n => n, StringComparer.Ordinal);
Console.WriteLine($" {name} [{CodePoints(name)}]");
Console.WriteLine($" design {design.GetType().Name} \"{design.Name}\" (made by {string.Join(", ", makers)}), roles [{string.Join(", ", roles.Select(r => r.Role))}]");
Console.WriteLine($" \"{description}\"");
}
CultRecordRefs.Validate(pirates);
foreach (var (design, name, description, roles) in products)
CultRecordRefs.Validate(new FactionProductData
{
Name = name, Description = description, Roles = roles,
Design = new CultRecordRef<CraftedItemData>(db.Cache.RefOf(design).Key),
Manufacturer = db.Cache.RefOf(others[0]),
});
if (!apply)
{
Console.WriteLine($"\nDry run. Pass \"apply\" to land the Pirates faction and {products.Length} products.");
return 0;
}
db.Cache.Commit(batch =>
{
var piratesKey = batch.Upsert(typeof(Faction), pirates);
foreach (var (design, name, description, roles) in products)
batch.Upsert(typeof(FactionProductData), new FactionProductData
{
Name = name, Description = description, Roles = roles,
Design = new CultRecordRef<CraftedItemData>(db.Cache.RefOf(design).Key),
Manufacturer = new CultRecordRef<Faction>(piratesKey),
});
});
Console.WriteLine($"\nLanded the Pirates faction and {products.Length} products in Aetheria.cc");
return 0;
}
}