feat: Blax Castes 1.0, work in progress
Castes bundle a pawn's apparel, food, drug and reading policy and medical
care. Join defaults put bought slaves, bought colonists, new colonists,
new slaves and new prisoners into a caste one tick after they join.
Includes the caste manager window, the Caste column in the Assign tab,
the join defaults window, Workshop art and the in-game test suite.
State: core and join defaults pass the suite (47 pass, 1 compat-only
skip). The manager window and Assign column were merged afterwards and
build, but the merged state has not run through the tests or review yet.
2026-11-28 22:22:36 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
using BlaxCastes;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace BlaxCastesTests
|
|
|
|
|
{
|
|
|
|
|
public static class SmokeTests
|
|
|
|
|
{
|
|
|
|
|
private static readonly string[] CoreKeys =
|
|
|
|
|
{
|
|
|
|
|
"BlaxCastes_NewCasteLabel", "BlaxCastes_Unmanaged", "BlaxCastes_SlotApparel", "BlaxCastes_SlotFood", "BlaxCastes_SlotDrug",
|
feat: Castes 1.0 scope: schedule, work priorities, loadouts, automatic status changes
Starter castes, join rows on every status change, old caste on return, overlap warnings, review fixes, test runner switches (-NoDlc, -Dlc, -Tasoc), Blax footer, deterministic DLL.
2026-11-29 10:57:22 +00:00
|
|
|
"BlaxCastes_SlotReading", "BlaxCastes_SlotMedCare", "BlaxCastes_NoCaste", "BlaxCastes_StarterColonist", "BlaxCastes_StarterSlave",
|
|
|
|
|
"BlaxCastes_StarterPrisoner", "BlaxCastes_StarterSeededMessage",
|
feat: Blax Castes 1.0, work in progress
Castes bundle a pawn's apparel, food, drug and reading policy and medical
care. Join defaults put bought slaves, bought colonists, new colonists,
new slaves and new prisoners into a caste one tick after they join.
Includes the caste manager window, the Caste column in the Assign tab,
the join defaults window, Workshop art and the in-game test suite.
State: core and join defaults pass the suite (47 pass, 1 compat-only
skip). The manager window and Assign column were merged afterwards and
build, but the merged state has not run through the tests or review yet.
2026-11-28 22:22:36 +00:00
|
|
|
"BlaxCastes_ManageCastesTitle", "BlaxCastes_JoinDefaultsTitle",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[BlaxTest("startup: patcher ran and logged, no errors mentioning Blax Castes")]
|
|
|
|
|
public static void StartupLogged()
|
|
|
|
|
{
|
|
|
|
|
int ours = Harmony.GetAllPatchedMethods()
|
|
|
|
|
.Select(Harmony.GetPatchInfo)
|
|
|
|
|
.Where(info => info != null)
|
|
|
|
|
.SelectMany(info => info.Prefixes.Concat(info.Postfixes).Concat(info.Finalizers).Concat(info.Transpilers))
|
|
|
|
|
.Count(p => p.owner == BlaxCastesStartup.HarmonyId);
|
|
|
|
|
T.Info("Harmony patches owned by " + BlaxCastesStartup.HarmonyId + ": " + ours);
|
|
|
|
|
bool logged = Log.Messages.Any(m => m.text != null && m.text.Contains("[Blax Castes]") && m.text.Contains("patches applied"));
|
|
|
|
|
T.Check(logged, "startup line '[Blax Castes] N patches applied' not in the log");
|
|
|
|
|
var errors = Log.Messages.Where(m => m.type == LogMessageType.Error && m.text != null && (m.text.Contains("Blax Castes") || m.text.Contains("BlaxCastes"))).ToList();
|
|
|
|
|
T.Check(errors.Count == 0, "errors mentioning Blax Castes at startup: " + string.Join(" | ", errors.Take(3).Select(e => e.text)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BlaxTest("startup: settings, game component and strings are loaded")]
|
|
|
|
|
public static void Loaded()
|
|
|
|
|
{
|
|
|
|
|
T.NotNull(BlaxCastesMod.Settings, "BlaxCastesMod.Settings");
|
|
|
|
|
T.NotNull(GameComponent_BlaxCastes.Instance, "GameComponent_BlaxCastes.Instance");
|
|
|
|
|
T.Check(GameComponent_BlaxCastes.Instance == Current.Game.GetComponent<GameComponent_BlaxCastes>(), "Instance is not the game's component");
|
|
|
|
|
var missing = CoreKeys.Concat(JoinReason.Rows.Select(r => "BlaxCastes_Row_" + r)).Where(k => !k.CanTranslate()).ToList();
|
|
|
|
|
T.Check(missing.Count == 0, "strings missing from Keyed: " + string.Join(", ", missing));
|
|
|
|
|
foreach (CasteSlot slot in CasteUtility.AllSlots)
|
|
|
|
|
T.Check(!CasteUtility.SlotLabel(slot).NullOrEmpty(), "no label for slot " + slot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BlaxTest("compat: IsActive finds Blax Castes and the base game, not a made-up id")]
|
|
|
|
|
public static void IsActiveWorks()
|
|
|
|
|
{
|
|
|
|
|
T.Check(Compat.IsActive("blax.castes"), "Compat.IsActive(\"blax.castes\") is false while Blax Castes runs");
|
|
|
|
|
T.Check(Compat.IsActive("ludeon.rimworld"), "Compat.IsActive(\"ludeon.rimworld\") is false");
|
|
|
|
|
T.Check(!Compat.IsActive("blax.castes.does.not.exist"), "Compat.IsActive is true for a made-up id");
|
|
|
|
|
T.Info("Blax Slaves active: " + Compat.IsActive(Compat.BlaxSlaves) + ", Ideology: " + ModsConfig.IdeologyActive + ", Biotech: " + ModsConfig.BiotechActive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BlaxTest("windows: the manager and join defaults windows construct, the join queue is callable")]
|
|
|
|
|
public static void WindowsConstruct()
|
|
|
|
|
{
|
|
|
|
|
T.NotNull(new Dialog_ManageCastes(), "new Dialog_ManageCastes()");
|
|
|
|
|
T.NotNull(new Dialog_JoinDefaults(), "new Dialog_JoinDefaults()");
|
|
|
|
|
Pawn p = Fixtures.Colonist();
|
|
|
|
|
JoinDefaults.Enqueue(p, JoinReason.NewColonist);
|
|
|
|
|
JoinDefaults.ApplyQueue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BlaxTest("harness: colonist, prisoner and colony slave fixtures")]
|
|
|
|
|
public static void Fixtures_()
|
|
|
|
|
{
|
|
|
|
|
Pawn c = Fixtures.Colonist();
|
|
|
|
|
T.Check(c.Spawned && c.IsFreeColonist, "colonist fixture is not a spawned free colonist");
|
|
|
|
|
Pawn pr = Fixtures.Prisoner();
|
|
|
|
|
T.Check(pr.IsPrisonerOfColony, "prisoner fixture is not a prisoner of the colony");
|
|
|
|
|
if (!ModsConfig.IdeologyActive)
|
|
|
|
|
T.Skip("slaves need Ideology; colonist and prisoner fixtures passed");
|
|
|
|
|
Pawn s = Fixtures.ColonySlave();
|
|
|
|
|
T.Check(s.IsSlaveOfColony, "slave fixture is not a slave of the colony");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|