Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Sim: Reassign craftsmen cannot take workshop workers or builders under gdd-0.3 (Fixes #2730) (#2731)

Eyal Golan491be16c6810
diff --git a/changelog.d/2730-reassign-craftsmen-idle.md b/changelog.d/2730-reassign-craftsmen-idle.md
new file mode 100644
index 000000000..e763f255c
--- /dev/null
+++ b/changelog.d/2730-reassign-craftsmen-idle.md
@@ -0,0 +1,4 @@
+### Fixed
+
+- Under the GDD 0.3 rules, Reassign craftsmen no longer takes people who are working in an arms workshop or as builders;
+ like Train, it counts only civilians without work.
diff --git a/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs b/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs
index 8513a08ec..7ee076907 100644
--- a/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs
+++ b/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs
@@ -789,6 +789,26 @@ public class ArmsWorkshopTests
}
}
+ // R-QUAL-004 with R-ARMS-005 and R-CITY-011 (#2730): a craftsmen reassignment cannot take a staffed workshop's worker or
+ // a builder either: like Train and the pioneer reassignment, it counts Training.Idle(s, city). Refused, state unchanged.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void ReassignCraftsmenCannotTakeAStaffedWorkshopsWorkerOrABuilder(bool builder)
+ {
+ var (c, s, id) = Built(civilians: 3, employed: 2, jobs: 2, jobsDefault: false);
+ var x = s.Cities["town_a"];
+ s.Cities["town_a"] = x.WithQualified(new Qualified(1, 0, Array.Empty<int>()));
+ if (builder) s.CityProjects[id] = s.CityProjects[id].WithBuilder(true);
+ else s.Workshops.Add(id, new Workshop(id, true, SyntheticWorkshopTier.Ordinary));
+ Assert.Equal(0, Training.Idle(s, s.Cities["town_a"]));
+ int craftsmen = s.Cities["town_a"].Craftsmen;
+ var r = Step(c, s, new ReassignCraftsmen("town_a", 1));
+ Assert.Equal("Town A has 0 civilians without work", Assert.Single(r.Rejected).Reason);
+ Assert.Equal(1, r.State.Cities["town_a"].Qualified.Craftsmen); // nobody reassigned
+ Assert.Equal(craftsmen, r.State.Cities["town_a"].Craftsmen);
+ }
+
// R-TRAIN-001 with R-ARMS-005 (#2270): Training.Idle stops at 0 when a staffed workshop's worker leaves no free civilian,
// so a Train refusal never names a negative count.
[Fact]
diff --git a/sim/Statecraft.Sim/Qualification.cs b/sim/Statecraft.Sim/Qualification.cs
index 887ad3770..81dae4178 100644
--- a/sim/Statecraft.Sim/Qualification.cs
+++ b/sim/Statecraft.Sim/Qualification.cs
@@ -85,7 +85,8 @@ namespace Statecraft.Sim
/// <summary>R-QUAL-004: <paramref name="count"/> of the city's qualified craftsmen, without a job, become craftsmen
/// again. Refused, state untouched, for an unknown city, a count below 1, more than the qualified craftsmen, or more than
- /// the civilians without work (<see cref="Training.Idle"/>).</summary>
+ /// the civilians without work (<see cref="Training.Idle(GameState, City)"/>: a staffed workshop's worker or a builder is
+ /// not idle, R-ARMS-005, R-CITY-011; #2730).</summary>
public static string? ReassignCraftsmen(Content c, GameState s, string city, int count, List<Cause> why)
{
PopulationLedger.RefuseAggregate(s);
@@ -93,7 +94,7 @@ namespace Statecraft.Sim
if (count < 1) return "Reassign at least one group";
var name = PlayerText.Settlement(c, city);
if (count > x.Qualified.Craftsmen) return FormattableString.Invariant($"{name} has {x.Qualified.Craftsmen} qualified craftsmen");
- var idle = Training.Idle(x);
+ var idle = Training.Idle(s, x); // R-ARMS-005, R-CITY-011: as Train and ReassignPioneers count it
if (count > idle) return FormattableString.Invariant($"{name} has {idle} civilians without work");
s.Cities[city] = x.WithCounts(x.Civilians - count, x.Employed, x.Refugees).WithCraftsmen(x.Craftsmen + count)
.WithQualified(x.Qualified.WithCraftsmen(x.Qualified.Craftsmen - count));