Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace BlaxLaws
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Why enforcement waits: the Keyed keys LawCase.waitReason holds and the Cases tab shows
|
|
|
|
|
/// (WaitReasons.Label). A case that waits is Open; the 250-tick sweep retries it, a case waiting for a
|
|
|
|
|
/// prisoner bed only every 2500 ticks (design: "Enforcement runs a tick later").
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class WaitReasons
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Hostiles threaten the offender's map (a raid, a berserk colonist): nobody is sent.</summary>
|
|
|
|
|
public const string Danger = "BlaxLaws_Wait_Danger";
|
|
|
|
|
|
|
|
|
|
/// <summary>Nobody on the map can ever enforce it (no warden in "Wardens only", nobody able): the player has to act.</summary>
|
|
|
|
|
public const string NoEnforcer = "BlaxLaws_Wait_NoEnforcer";
|
|
|
|
|
|
|
|
|
|
/// <summary>Enforcers exist but none is free now (asleep, on a rescue, in a ritual, out of reach).</summary>
|
|
|
|
|
public const string Busy = "BlaxLaws_Wait_Busy";
|
|
|
|
|
|
|
|
|
|
/// <summary>No prisoner bed the enforcer can take the offender to.</summary>
|
|
|
|
|
public const string NoBed = "BlaxLaws_Wait_NoBed";
|
|
|
|
|
|
|
|
|
|
/// <summary>Someone else holds the offender or the bed (a doctor's rescue): the arrest waits, no reservation error.</summary>
|
|
|
|
|
public const string Reserved = "BlaxLaws_Wait_Reserved";
|
|
|
|
|
|
|
|
|
|
/// <summary>The offender's break is hostile to the colony (berserk): the arrest waits until it ends or the pawn is down.</summary>
|
|
|
|
|
public const string HostileBreak = "BlaxLaws_Wait_HostileBreak";
|
|
|
|
|
|
|
|
|
|
/// <summary>A role holder or a mechanitor with mechs: Laws doesn't arrest it on its own; "Arrest now" does.</summary>
|
|
|
|
|
public const string Hold = "BlaxLaws_Wait_Hold";
|
|
|
|
|
|
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
|
|
|
/// <summary>The offender carries a pawn (a rescue, a capture): the arrest waits until it puts the pawn down.</summary>
|
|
|
|
|
public const string Carrying = "BlaxLaws_Wait_Carrying";
|
|
|
|
|
|
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
|
|
|
/// <summary>The offender isn't on a map (carried, in a caravan).</summary>
|
|
|
|
|
public const string Away = "BlaxLaws_Wait_Away";
|
|
|
|
|
|
|
|
|
|
/// <summary>The reason's text, or "" for none.</summary>
|
|
|
|
|
public static string Label(string reason)
|
|
|
|
|
{
|
|
|
|
|
if (reason.NullOrEmpty())
|
|
|
|
|
return "";
|
|
|
|
|
return reason.CanTranslate() ? reason.Translate().ToString() : reason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Puts the case back to Open with the reason. Returns true when the reason changed, so a letter goes
|
|
|
|
|
/// out once per wait and not on every sweep.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static bool Set(LawCase c, string reason)
|
|
|
|
|
{
|
|
|
|
|
if (c == null)
|
|
|
|
|
return false;
|
|
|
|
|
bool changed = c.waitReason != reason;
|
|
|
|
|
c.status = CaseStatus.Open;
|
|
|
|
|
c.waitReason = reason;
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Outcome keys of this package beside CaseOutcomes. Saved as strings; the label is
|
|
|
|
|
/// "BlaxLaws_Outcome_" + key (CaseOutcomes.Label), from BlaxLaws_Enforcement.xml.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class EnforcementOutcomes
|
|
|
|
|
{
|
|
|
|
|
/// <summary>The subdue gave up: three hits in a row caused no pain (go-juice, painkillers, every part at its cap).</summary>
|
|
|
|
|
public const string NotSubdued = "NotSubdued";
|
|
|
|
|
|
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
|
|
|
/// <summary>A jailed pawn escaped off the map (the escape hook noted it).</summary>
|
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
|
|
|
public const string Escaped = "Escaped";
|
|
|
|
|
|
|
|
|
|
/// <summary>A jailed pawn died.</summary>
|
|
|
|
|
public const string Died = "Died";
|
|
|
|
|
|
|
|
|
|
/// <summary>The offender became a prisoner some other way (arrested by hand, another mod): Laws never touches it.</summary>
|
|
|
|
|
public const string AlreadyPrisoner = "AlreadyPrisoner";
|
|
|
|
|
}
|
|
|
|
|
}
|