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.

Unity: UnitRoster reads State.Units; figures follow Q-UI-3 (GDD Phase 5 PR 14, refs #753) (#1205)

Beri65ea0e6a4d59
diff --git a/changelog.d/unity-unit-roster-753.md b/changelog.d/unity-unit-roster-753.md
new file mode 100644
index 000000000..00845a0b6
--- /dev/null
+++ b/changelog.d/unity-unit-roster-753.md
@@ -0,0 +1,9 @@
+### Changed
+- GDD Phase 5 PR 14: the map's army tokens come from the sim's units (refs #753, #385). In the GDD loop `UnitRoster`
+ draws one token per military unit in `GameState.Units` on its sim hex, grouped per hex; a unit that moved is placed
+ once within one hex of its new hex, off the other tokens' hexes, and the spot is cached. A token's figures follow
+ Q-UI-3 (3 at two thirds or more of the unit's starting strength, 2 at a third or more, 1 below), not the reserve
+ call-up. The squadron and the ships still come from their rows. Etzioni (no sourced strength) and the brigades whose
+ windows open later draw no token in the GDD loop until a sim unit exists for them. In the GDD loop the unit card no
+ longer leads with the reserve call-up: an army token's card drops that line, and the squadron's shows only the security
+ level. The legacy loop is unchanged.
diff --git a/docs/units.md b/docs/units.md
index 96780d3a8..442a52ae0 100644
--- a/docs/units.md
+++ b/docs/units.md
@@ -66,8 +66,8 @@ Not in the slice:
Normal play draws one token per unit from two inputs: the sim's state and `content/map/units_1948.yaml`.
- **The state** gives the date, the security level and the reserve call-up (`GameState.Date`, `Rung`, `Mobilization`).
- Since Phase 5 PR 4 it also holds the starting forces (below); the tokens do not read them yet, they keep reading the
- file's rows until Phase 5 PR 14 (design: `docs/superpowers/specs/2026-10-11-units-in-play-design.md`).
+ Since Phase 5 PR 4 it also holds the starting forces (below), and since Phase 5 PR 14 the GDD loop's army tokens come
+ from them (below, "Tokens from the state"; design: `docs/superpowers/specs/2026-10-11-units-in-play-design.md`).
- **The data file** is read by both. The sim reads the rows a new game starts a unit from (`StartingForces`; Q-START-1,
owner, 15 October 2026), so the file is in the content hash and moves the goldens
(`StartingForcesTests.TheUnitFileEntersTheContentHash`). The WebGL manifest ships it.
@@ -149,8 +149,8 @@ ruled (al-Malikiyya on 15 May is the ALA's, #226 ruling 2).
Army. `UnitRoster.OnMap` (not hidden, and `side: israel` or a side with a figure) keeps the roster and the placer to
those rows; the Egyptian, Syrian, Iraqi and Lebanese rows give no token, take no spot and clear no ground for the kits.
A drawn force's token has no code-built figure: it is drawn only once its figure has arrived, so a missing or damaged
- bundle draws nothing. Three figures (Q-UI-3 at full strength: the rows give only the sourced 15 May strength; owner,
- 17 October 2026, #226), under the neutral pennant (Q-ART-1). Its spot never stands on ground Israel held on its
+ bundle draws nothing. In the legacy loop, three figures (Q-UI-3 at full strength: the rows give only the sourced 15 May
+ strength; owner, 17 October 2026, #226); in the GDD loop, Q-UI-3 by the sim unit's strength ("Tokens from the state"); under the neutral pennant (Q-ART-1). Its spot never stands on ground Israel held on its
window's first day (#226, ruling 9; `control_hexes_1948_49.yaml`). The card leaves out Israel's call-up line. The
goldens do not move. Tests: `UnitsInPlayTests.OnlyTheForcesWithAFigureAreDrawnAndOnlyOnceItHasArrived`,
`UnitFiguresTests.TheArabForcesAreDrawnOnlyWithTheirOwnFiguresOnceTheyArrive`.
@@ -206,6 +206,29 @@ defaults"). The unit stands on the hex holding the anchor's coordinates, by the
name the rows; today that is all twelve.
- Tests: `StartingForcesTests` (dotnet) and `UnitsInPlayTests.TheStartMatchesTheMap` (EditMode).
+### Tokens from the state (Phase 5 PR 14, #753)
+
+In the GDD loop (`systems.loop: gdd`, the real content) the army tokens come from `GameState.Units`, not from the rows'
+dated windows (`UnitRoster.FromState`; impact plan §2.6). The legacy loop keeps the rows and the call-up until D-E1
+deletes it.
+- **One token per military unit** whose row is on the map, grouped per hex ((q, r) order). Unit i of a new game is the
+ starting force `Content.StartingForces[i]` (R-UNIT-006), and that row gives the card, the flag, the headgear and the
+ vehicles. A halutz, or a unit with no row, draws no token. An Arab force's token still waits for its Collection figure.
+- **The sim hex is authoritative.** A unit on its starting hex stands on its starting anchor's spot (UnitPlacer's one-hex
+ offset still clears the town kits and the roads). A unit that moved stands within one hex of its new hex, off the
+ hexes the other tokens hold; that spot is placed once and cached, so a rebuild places only the units that moved. Its
+ card names no place (no source does) and gives the row's sources.
+- **Figures follow Q-UI-3** (owner, 15 October 2026; #226): 3 at two thirds or more of full strength, 2 at a third or
+ more, 1 below that. Full strength is the sourced strength the unit started with (Q-UNIT-4), so a new game draws three
+ figures on every token whatever the call-up, and losses take figures away. So the card leaves out the call-up: an army
+ token's card has no national line, and the squadron's gives the security level alone ("Security level 5 of 5"), which
+ still sets whether it flies.
+- **The squadron and the ships** are tokens only (Q-UNIT-5): they still come from their rows' windows.
+- So from 15 May 1948 the map draws the twelve starting forces where the sim holds them. A row with no sim unit (Etzioni,
+ which has no sourced strength, and the brigades whose windows open later, such as Yiftach and the 7th) draws no token
+ in the GDD loop until a later Phase 5 PR raises it.
+- Tests: `UnitsFromStateTests` (EditMode).
+
### The 1948 Collection on the tokens (#665)
The tokens wear Tal Heuberger's figures from The 1948 Collection (#507, #680), streamed after the first frame
@@ -366,7 +389,8 @@ checks every anchor and logs each spot and its distance.
never clear `wikipedia_only` (#902). The shipped rows carry none yet; the translations in `research_notes/Map/unit-card-hebrew-harel-givati-negev.md` wait for its
person's source checks. Tests: `UnitsInPlayTests` (`TheHebrewProseShows...`, `EachHebrewFieldFallsBack...`,
`AHebrewCommanderWithoutTheEnglishAddsNoLine`, `BadHebrewProseNamesTheProblem`), on test-only fixtures.
-- It also gives the national values the token reflects ("Reserve call-up 80% · security level 5 of 5") and the source
+- It also gives the national values the token reflects on Israel's cards (legacy loop: "Reserve call-up 80% · security level
+ 5 of 5"; in the GDD loop only the squadron's card has one, "Security level 5 of 5", see above) and the source
hosts, with a draft note that says "Wikipedia only" when the position's own sources are.
- It has no orders; a button opens the Defence screen.
diff --git a/unity/Assets/Scripts/Map/Units/UnitGround.cs b/unity/Assets/Scripts/Map/Units/UnitGround.cs
index cf638bad0..2dbf04480 100644
--- a/unity/Assets/Scripts/Map/Units/UnitGround.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitGround.cs
@@ -109,9 +109,10 @@ namespace Statecraft.Game.Map.Units
}
/// <summary>Every anchor's spot (UnitPlacer.PlaceAll) on this ground.</summary>
- public Dictionary<UnitAnchor, AnchorSpot> Place(IReadOnlyList<UnitEntry> units, Func<double, double, Vector2> toXZ, Action<string>? skipped) =>
+ public Dictionary<UnitAnchor, AnchorSpot> Place(IReadOnlyList<UnitEntry> units, Func<double, double, Vector2> toXZ, Action<string>? skipped,
+ IEnumerable<(int q, int r)>? taken = null) =>
UnitPlacer.PlaceAll(units, hexes, HexSizeM, (lon, lat) => { var v = toXZ(lon, lat); return (v.x, v.y); },
(service, x, z, compact, inTown, ax, az) => Clear(service, new Vector2((float)x, (float)z), compact, inTown, new Vector2((float)ax, (float)az)),
- (x, z) => TownOverlap(new Vector2((float)x, (float)z), compact: true), skipped);
+ (x, z) => TownOverlap(new Vector2((float)x, (float)z), compact: true), skipped, taken);
}
}
diff --git a/unity/Assets/Scripts/Map/Units/UnitLayer.cs b/unity/Assets/Scripts/Map/Units/UnitLayer.cs
index 025616e02..2d06855d0 100644
--- a/unity/Assets/Scripts/Map/Units/UnitLayer.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitLayer.cs
@@ -71,6 +71,19 @@ namespace Statecraft.Game.Map.Units
/// changes nothing and returns at once (GameRoot calls it every frame). Cleared when the tokens are rebuilt.</summary>
(Vector3 eye, Quaternion rotation)? facedFor;
+ /// <summary>The GDD loop's anchors for units that moved off their starting hex (UnitRoster.FromState), one per row and
+ /// sim hex, and their spots: placed once, the first time a unit stands there, so a rebuild after a move places only
+ /// the units that moved (#563's spot cache, GDD Phase 5 PR 14). The spots drawn from are <see cref="spots"/> with these.
+ /// A cached spot keeps off the hexes other tokens held when it was placed, not those they take later: two tokens can
+ /// then share a hex until stacks are drawn together.</summary>
+ readonly Dictionary<(string row, int q, int r), UnitAnchor> movedAnchors = new Dictionary<(string, int, int), UnitAnchor>();
+ readonly Dictionary<UnitAnchor, AnchorSpot> movedSpots = new Dictionary<UnitAnchor, AnchorSpot>();
+ /// <summary>Moved anchors made since the last placement (each is placed once, spot or not).</summary>
+ readonly HashSet<UnitAnchor> movedNew = new HashSet<UnitAnchor>();
+ Dictionary<UnitAnchor, AnchorSpot>? drawSpots;
+ /// <summary>How many moved units' anchors the layer has placed (each once; the tests read it).</summary>
+ public int MovedSpotsPlaced { get; private set; }
+
/// <summary>The tokens drawn now, in the data's order.</summary>
public IReadOnlyList<PlacedToken> Tokens => placed;
/// <summary>Every anchor's spot, from the data alone.</summary>
@@ -238,15 +251,49 @@ namespace Statecraft.Game.Map.Units
public bool Show(Content content, GameState state)
{
shownContent = content; shownState = state;
- var now = UnitRoster.Build(units, content, state, UnitFigures.Arrived);
+ // The GDD loop draws the army from the sim's units (GDD Phase 5 PR 14); the legacy loop keeps the rows and the call-up.
+ var now = content.IsGdd
+ ? UnitRoster.FromState(units, content, state, UnitFigures.Arrived, (row, start, q, r) => MovedAnchor(content, row, start, q, r))
+ : UnitRoster.Build(units, content, state, UnitFigures.Arrived);
if (roster != null && roster.SequenceEqual(now)) return false;
roster = now;
- placed = UnitPlacer.Place(now, spots);
+ PlaceMoved(now);
+ placed = UnitPlacer.Place(now, drawSpots ?? spots);
Rebuild();
if (Selected != null && !placed.Any(p => p.Token.Unit.Id == Selected)) Select(null); else Select(Selected);
return true;
}
+ /// <summary>The anchor of <paramref name="row"/>'s unit on sim hex (<paramref name="q"/>, <paramref name="r"/>) after a
+ /// move: the hex's centre, no place name and no sources (the card then gives the row's), with the starting anchor's
+ /// window. The same object every time, so the roster compares equal and the spot is placed once.</summary>
+ UnitAnchor MovedAnchor(Content content, UnitEntry row, UnitAnchor start, int q, int r)
+ {
+ if (movedAnchors.TryGetValue((row.Id, q, r), out var a)) return a;
+ var hex = content.HexAt(q, r);
+ if (hex == null) return start; // the sim never moves a unit off the map; stay drawn where it started
+ a = new UnitAnchor { Lon = hex.Lon, Lat = hex.Lat, From = start.From, To = start.To };
+ movedAnchors[(row.Id, q, r)] = a;
+ movedNew.Add(a);
+ return a;
+ }
+
+ /// <summary>Places the moved units' anchors in <paramref name="tokens"/> that have no spot yet, as UnitPlacer places
+ /// any anchor (within one hex, clear of the town kits and the roads), off the hexes the other drawn tokens hold.</summary>
+ void PlaceMoved(List<UnitToken> tokens)
+ {
+ var fresh = tokens.Where(t => movedNew.Remove(t.Anchor)).ToList();
+ if (fresh.Count == 0) return;
+ var taken = tokens.Select(t => spots.TryGetValue(t.Anchor, out var s) ? s : movedSpots.TryGetValue(t.Anchor, out s) ? s : (AnchorSpot?)null)
+ .Where(s => s != null).Select(s => (s!.Value.Q, s.Value.R)).ToList();
+ var entries = fresh.Select(t => new UnitEntry { Id = t.Unit.Id, Side = t.Unit.Side, Service = t.Unit.Service, Anchors = new List<UnitAnchor> { t.Anchor } }).ToList();
+ foreach (var kv in ground.Place(entries, XZ(map), Debug.LogWarning, taken)) movedSpots[kv.Key] = kv.Value;
+ MovedSpotsPlaced += fresh.Count;
+ drawSpots = new Dictionary<UnitAnchor, AnchorSpot>(spots.Count + movedSpots.Count);
+ foreach (var kv in spots) drawSpots[kv.Key] = kv.Value;
+ foreach (var kv in movedSpots) drawSpots[kv.Key] = kv.Value;
+ }
+
/// <summary>A Collection model arrived: draws the tokens again if it lets a new one show (an Arab force's figure).</summary>
void OnModelArrived(string id)
{
diff --git a/unity/Assets/Scripts/Map/Units/UnitPlacer.cs b/unity/Assets/Scripts/Map/Units/UnitPlacer.cs
index 60fc1c91a..799591867 100644
--- a/unity/Assets/Scripts/Map/Units/UnitPlacer.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitPlacer.cs
@@ -59,9 +59,11 @@ namespace Statecraft.Game.Map.Units
/// <param name="clear">(service, x, z, compact, inTown, anchor x, anchor z): true when a token of that service may
/// stand there.</param>
/// <param name="townOverlap">(x, z): how deep (m) a compact token there reaches into a town (round 3's ranking).</param>
+ /// <param name="taken">Hexes other tokens already hold for good (a moved unit's spot keeps off the drawn tokens'
+ /// hexes, UnitLayer); null: none.</param>
public static Dictionary<UnitAnchor, AnchorSpot> PlaceAll(IReadOnlyList<UnitEntry> units, IReadOnlyList<MapHex> hexes, double hexSizeM,
Func<double, double, (double x, double z)> toXZ, Func<string, double, double, bool, bool, double, double, bool> clear,
- Func<double, double, double> townOverlap, Action<string>? skipped = null)
+ Func<double, double, double> townOverlap, Action<string>? skipped = null, IEnumerable<(int q, int r)>? taken = null)
{
if (units == null) throw new ArgumentNullException(nameof(units));
if (hexes == null || hexes.Count == 0) throw new ArgumentException("no hexes", nameof(hexes));
@@ -69,6 +71,7 @@ namespace Statecraft.Game.Map.Units
for (int i = 0; i < hexes.Count; i++) centres[i] = toXZ(hexes[i].Lon, hexes[i].Lat);
double maxOffset = Math.Sqrt(3.0) * hexSizeM + 1.0; // one hex step (plus a metre of rounding)
var held = new List<(int q, int r, DateTime from, DateTime to)>();
+ if (taken != null) foreach (var (q, r) in taken) held.Add((q, r, DateTime.MinValue, DateTime.MaxValue));
var result = new Dictionary<UnitAnchor, AnchorSpot>();
foreach (var u in units)
{
diff --git a/unity/Assets/Scripts/Map/Units/UnitRoster.cs b/unity/Assets/Scripts/Map/Units/UnitRoster.cs
index efbe38569..6f211750f 100644
--- a/unity/Assets/Scripts/Map/Units/UnitRoster.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitRoster.cs
@@ -109,6 +109,62 @@ namespace Statecraft.Game.Map.Units
return list;
}
+ /// <summary>The GDD loop's tokens (GDD Phase 5 PR 14, #753; impact plan §2.6): one army token per military unit in
+ /// <see cref="GameState.Units"/>, grouped per hex ((q, r) order, then id), and the squadron and the ships from their
+ /// rows as <see cref="Build(IReadOnlyList{UnitEntry}, Content, GameState, Func{string, bool})"/> draws them (they are
+ /// tokens only, Q-UNIT-5). The sim hex is authoritative: a unit on its starting hex stands on its row's starting
+ /// anchor (that anchor's spot, UnitPlacer's one-hex offset included); a unit that moved takes
+ /// <paramref name="moved"/>'s anchor for its row and hex (the layer caches it with its spot). Its figures follow
+ /// Q-UI-3 (<see cref="FiguresForStrength"/>), not the call-up. A unit is drawn only from a row: unit i of a new game is
+ /// <c>content.StartingForces[i]</c> (R-UNIT-006), whose row is its card, flag and figures, and a unit with no row (a
+ /// halutz; a unit raised in play, which has no art yet) draws no token. An Arab force's token still waits for its
+ /// Collection figure (<paramref name="arrived"/>), and a row off the map (<see cref="OnMap"/>) draws nothing.
+ /// Pure and read-only like Build.</summary>
+ public static List<UnitToken> FromState(IReadOnlyList<UnitEntry> units, Content content, GameState state, Func<string, bool>? arrived,
+ Func<UnitEntry, UnitAnchor, int, int, UnitAnchor> moved)
+ {
+ if (units == null) throw new ArgumentNullException(nameof(units));
+ if (content == null) throw new ArgumentNullException(nameof(content));
+ if (state == null) throw new ArgumentNullException(nameof(state));
+ if (moved == null) throw new ArgumentNullException(nameof(moved));
+ var list = new List<UnitToken>();
+ foreach (var unit in state.Units.Values.OrderBy(v => v.Q).ThenBy(v => v.R).ThenBy(v => v.Id))
+ {
+ // Unit i of a new game is StartingForces[i] (R-UNIT-006); a unit raised in play takes the next id, at or above
+ // the count, and has no row yet (UnitsFromStateTests.AUnitRaisedInPlayDrawsNoToken).
+ if (unit.Side == "" || unit.Id >= content.StartingForces.Count) continue;
+ var force = content.StartingForces[unit.Id];
+ var row = units.FirstOrDefault(u => u.Id == force.Row);
+ if (row == null || !OnMap(row) || row.Service != UnitData.Army) continue;
+ var start = AnchorAt(row, content.Rules.Start);
+ if (start == null) continue; // the map's copy of the file disagrees with the sim's; nothing to stand on
+ var anchor = unit.Q == force.Q && unit.R == force.R ? start : moved(row, start, unit.Q, unit.R);
+ int figures = FiguresForStrength(unit.Strength, force.Strength);
+ if (row.Side != UnitData.Israel)
+ {
+ var figure = UnitFigures.SideFigure(row.Side)!;
+ if (arrived != null && arrived(figure)) list.Add(new UnitToken(row, anchor, figures, figure, false));
+ continue;
+ }
+ var hats = (row.Headgear ?? (IReadOnlyList<string>)UnitData.DefaultHeadgear).Take(figures).ToList();
+ list.Add(new UnitToken(row, anchor, figures, RiflemanType(hats[0]), false, hats, UnitFigures.VehiclesAt(row, state.Date)));
+ }
+ list.AddRange(Build(units, content, state, arrived).Where(t => t.Unit.Service != UnitData.Army));
+ return list;
+ }
+
+ /// <summary>Q-UI-3 (owner, 15 October 2026, "Take all recommendations"; #226, 17 October 2026): "3 figures at two
+ /// thirds or more of the type's full strength, 2 at a third or more, 1 below that". A unit's full strength is the
+ /// sourced strength it started with (Q-UNIT-4: a starting unit's Strength is its row's), so a new game draws every
+ /// unit with three, and losses take figures away. Integers only: 3s &gt;= 2f, then 3s &gt;= f.</summary>
+ public static int FiguresForStrength(int strength, int full)
+ {
+ if (full <= 0) throw new ArgumentOutOfRangeException(nameof(full), full, "a full strength is at least 1");
+ if (3 * strength >= 2 * full) return 3;
+ if (3 * strength >= full) return 2;
+ return 1;
+ }
+
/// <summary>The art type of a rifleman with <paramref name="headgear"/> (the authored-prefab hook's key).</summary>
public static string RiflemanType(string headgear) => headgear switch
{
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index a759820fe..94490b0d7 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -251,7 +251,7 @@ namespace Statecraft.Game.UI
panel.EnableInClassList(UnitClass, unit != null);
if (unit != null)
{
- var card = UnitCard.For(unit.Value, s, text);
+ var card = UnitCard.For(unit.Value, s, text, c.IsGdd);
panel.EnableInClassList("info-empty", false);
title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = card.Body;
ShowLocalities("");
diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.cs
index 72d070078..2f3cc14bf 100644
--- a/unity/Assets/Scripts/UI/UnitCard.cs
+++ b/unity/Assets/Scripts/UI/UnitCard.cs
@@ -10,14 +10,15 @@ namespace Statecraft.Game.UI
/// <summary>The info panel's text for a selected unit (read only; no orders: the panel links to the Defence screen):
/// its name, number and service; where it stands, and since when only from a sourced start (the anchor's `since`,
/// never the game's first day: review I1); its formation and first commander where sourced; the sector in the
- /// source's words; on Israel's units, the national values its token reflects (the reserve call-up sets its figures, the
- /// security level whether its aircraft fly); and its sources, with a draft note that says "Wikipedia only" when the
- /// position's own sources are (review M8).</summary>
+ /// source's words; on Israel's units, the national values its token reflects (legacy loop: the reserve call-up sets an
+ /// army token's figures, the security level whether the aircraft fly; GDD loop: the unit's strength sets the figures,
+ /// Q-UI-3, so only the squadron's card keeps a line, the security level); and its sources, with a draft note that says
+ /// "Wikipedia only" when the position's own sources are (review M8).</summary>
public sealed class UnitCard
{
public string Title = "", Subtitle = "", Body = "", Footer = "", Note = "";
- public static UnitCard For(PlacedToken placed, GameState state, UiText text)
+ public static UnitCard For(PlacedToken placed, GameState state, UiText text, bool gddLoop = false)
{
var t = placed.Token; var u = t.Unit; var a = t.Anchor;
bool hebrew = text["ui.lang"] == UiLanguage.Hebrew;
@@ -29,22 +30,30 @@ namespace Statecraft.Game.UI
var aircraft = text[t.ArtType == UnitShowcase.SpitfireType ? "unit.aircraft.spitfire" : "unit.aircraft.s199"];
lines.Add(text.Format(t.Flying ? "unit.flying" : "unit.parked", aircraft));
}
- var place = Local(a.Place, a.PlaceHe);
- lines.Add(string.IsNullOrWhiteSpace(a.Since) ? text.Format("unit.position_plain", place) : text.Format("unit.position", place, a.Since!));
+ // A unit that moved in play (GDD loop) stands on a hex no source names: no position line, and the row's sources.
+ bool sourced = a.Place != "";
+ if (sourced)
+ {
+ var place = Local(a.Place, a.PlaceHe);
+ lines.Add(string.IsNullOrWhiteSpace(a.Since) ? text.Format("unit.position_plain", place) : text.Format("unit.position", place, a.Since!));
+ }
if (!string.IsNullOrEmpty(u.Formed)) lines.Add(text.Format("unit.formed", u.Formed!));
// The English decides whether the line exists: a Hebrew commander never adds one (owner, #558).
if (!string.IsNullOrEmpty(u.FirstCommander)) lines.Add(text.Format("unit.commander", Local(u.FirstCommander!, u.FirstCommanderHe)));
lines.Add(Local(u.Sector, u.SectorHe));
+ // Israel's call-up and security level set only Israel's tokens; an Arab force's token reflects neither (#665).
+ var national = u.Side != UnitData.Israel ? ""
+ : !gddLoop ? text.Format("unit.national", PlayerText.Percent(state.Mobilization), state.Rung)
+ : u.Service == UnitData.Air ? text.Format("unit.security", state.Rung) : "";
var hosts = u.AllSources().Select(s => new Uri(s.Url).Host).Distinct(StringComparer.Ordinal).OrderBy(h => h, StringComparer.Ordinal);
return new UnitCard
{
Title = text["ui.lang"] == UiLanguage.Hebrew && !string.IsNullOrEmpty(u.NameHe) ? u.NameHe : u.Name,
Subtitle = text.Format("unit.subtitle", u.Number, text["unit.service." + u.Service]),
Body = string.Join("\n", lines),
- // Israel's call-up and security level set only Israel's tokens; an Arab force's token reflects neither (#665).
- Footer = (u.Side == UnitData.Israel ? text.Format("unit.national", PlayerText.Percent(state.Mobilization), state.Rung) + "\n" : "")
+ Footer = (national == "" ? "" : national + "\n")
+ text.Format("unit.sources", string.Join(", ", hosts)),
- Note = UnitData.IsWikipediaOnly(a.Sources) ? text["unit.draft_wikipedia"] : text["unit.draft"],
+ Note = (sourced ? UnitData.IsWikipediaOnly(a.Sources) : UnitData.IsWikipediaOnly(u)) ? text["unit.draft_wikipedia"] : text["unit.draft"],
};
}
}
diff --git a/unity/Assets/Tests/EditMode/UnitFiguresTests.cs b/unity/Assets/Tests/EditMode/UnitFiguresTests.cs
index b493b4495..5875c7b5a 100644
--- a/unity/Assets/Tests/EditMode/UnitFiguresTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitFiguresTests.cs
@@ -23,7 +23,9 @@ using UnityEngine.TestTools;
/// force's token is not drawn at all (#740: no IDF figures, no placeholder).</summary>
public class UnitFiguresTests
{
- static readonly Content C = ContentLoader.Load(Paths.Content);
+ /// <summary>The legacy loop, whose roster follows the rows' dated windows and the call-up: these tests sweep the war's
+ /// tokens by date (the GDD loop draws the sim's units, UnitsFromStateTests).</summary>
+ static readonly Content C = SimBridgeGddTests.Legacy;
static List<UnitEntry> Units => UnitData.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", UnitData.DefaultFileName)));
static readonly DateTime May20 = new DateTime(1948, 5, 20), July12 = new DateTime(1948, 7, 12), LastArmistice = new DateTime(1949, 7, 20);
diff --git a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs b/unity/Assets/Tests/EditMode/UnitPlinthTests.cs
index a852fc53a..6d32119c8 100644
--- a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitPlinthTests.cs
@@ -16,7 +16,9 @@ using UnityEngine;
/// (docs/units.md, "The plinth and the flag").</summary>
public class UnitPlinthTests
{
- static readonly Content C = ContentLoader.Load(Paths.Content);
+ /// <summary>The legacy loop, whose roster follows the rows' dated windows and the call-up: these tests sweep the war's
+ /// tokens by date (the GDD loop draws the sim's units, UnitsFromStateTests).</summary>
+ static readonly Content C = SimBridgeGddTests.Legacy;
static string CommittedYaml => File.ReadAllText(Path.Combine(Paths.Content, "map", UnitData.DefaultFileName));
static readonly DateTime[] Dates = { new DateTime(1948, 5, 29), new DateTime(1948, 7, 12), new DateTime(1948, 12, 4) };
diff --git a/unity/Assets/Tests/EditMode/UnitsFromStateTests.cs b/unity/Assets/Tests/EditMode/UnitsFromStateTests.cs
new file mode 100644
index 000000000..14f508891
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitsFromStateTests.cs
@@ -0,0 +1,240 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using Statecraft.Game.Map.Units;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+
+/// <summary>GDD Phase 5 PR 14 (#753; impact plan §2.6): in the GDD loop the map's army tokens come from the sim's units
+/// (GameState.Units), one per unit on its sim hex, and a token's figures follow Q-UI-3, not the call-up. The squadron and
+/// the ships stay tokens drawn from their rows (Q-UNIT-5).</summary>
+public class UnitsFromStateTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static List<UnitEntry> Units => UnitData.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", UnitData.DefaultFileName)));
+ static GameState NewGame() => Simulation.NewGame(C, GoldenRun.Seed, Mode.Historical).Clone();
+
+ /// <summary>A moved unit's anchor as the layer makes it: the hex's centre, made once per row and hex.</summary>
+ sealed class Moved
+ {
+ public readonly Dictionary<(string, int, int), UnitAnchor> Made = new Dictionary<(string, int, int), UnitAnchor>();
+ public UnitAnchor At(UnitEntry row, UnitAnchor start, int q, int r)
+ {
+ if (!Made.TryGetValue((row.Id, q, r), out var a))
+ {
+ var h = C.HexAt(q, r)!;
+ Made[(row.Id, q, r)] = a = new UnitAnchor { Lon = h.Lon, Lat = h.Lat, From = start.From, To = start.To };
+ }
+ return a;
+ }
+ }
+
+ static List<UnitToken> Army(List<UnitToken> tokens) => tokens.Where(t => t.Unit.Service == UnitData.Army).ToList();
+
+ /// <summary>A land hex next to (q, r) that holds no unit.</summary>
+ static (int q, int r) FreeNeighbour(GameState s, int q, int r)
+ {
+ foreach (var (dq, dr) in new[] { (1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1) })
+ {
+ var h = C.HexAt(q + dq, r + dr);
+ if (h != null && h.Land && !s.Units.Values.Any(u => u.Q == h.Q && u.R == h.R)) return (h.Q, h.R);
+ }
+ throw new InvalidOperationException($"no free land hex next to ({q},{r})");
+ }
+
+ static void MoveTo(GameState s, int id, int q, int r)
+ {
+ var u = s.Units[id];
+ s.Units[id] = new Unit(u.Id, u.Type, q, r, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget);
+ }
+
+ [Test]
+ public void OneTokenPerUnitOnItsHex()
+ {
+ Assert.IsTrue(C.IsGdd, "the real content runs the GDD loop");
+ var s = NewGame();
+ var units = Units;
+ var moved = new Moved();
+ var drawn = s.Units.Values.Where(u => u.Side != "" && UnitRoster.OnMap(units.Single(e => e.Id == C.StartingForces[u.Id].Row))).ToList();
+ Assert.Greater(drawn.Count, 0);
+ var army = Army(UnitRoster.FromState(units, C, s, _ => true, moved.At));
+ CollectionAssert.AreEquivalent(drawn.Select(u => C.StartingForces[u.Id].Row), army.Select(t => t.Unit.Id), "one token per drawn unit");
+ Assert.AreEqual(army.Count, army.Select(t => t.Unit.Id).Distinct().Count());
+ var hexes = MapBuilder.LoadHexes(Path.Combine(Paths.Content, "map", "hexes.json"));
+ foreach (var u in drawn)
+ {
+ var t = army.Single(x => x.Unit.Id == C.StartingForces[u.Id].Row);
+ Assert.AreEqual((u.Q, u.R), HexPicker.FromLonLat(t.Anchor.Lon, t.Anchor.Lat, hexes.bounds, hexes.hex_size_km), $"{t}: the sim hex");
+ Assert.AreEqual(C.StartingForces[u.Id].Anchor, t.Anchor.Place, $"{t}: unmoved, it stands on its starting anchor");
+ }
+ Assert.IsEmpty(moved.Made, "no unit moved, so no moved anchor");
+ // Grouped per hex: the army tokens come in (q, r) order.
+ var order = army.Select(t => drawn.Single(u => C.StartingForces[u.Id].Row == t.Unit.Id)).Select(u => (u.Q, u.R)).ToList();
+ CollectionAssert.AreEqual(order.OrderBy(h => h.Q).ThenBy(h => h.R).ToList(), order);
+
+ // A unit that moves is drawn on its new hex, once, and a halutz draws nothing.
+ var first = drawn[0];
+ var to = FreeNeighbour(s, first.Q, first.R);
+ MoveTo(s, first.Id, to.q, to.r);
+ s.Units.Add(s.NextId, new Unit(s.NextId, "halutz", first.Q, first.R)); s.NextId++;
+ army = Army(UnitRoster.FromState(units, C, s, _ => true, moved.At));
+ Assert.AreEqual(drawn.Count, army.Count, "still one token per unit; the halutz has none");
+ var mt = army.Single(t => t.Unit.Id == C.StartingForces[first.Id].Row);
+ Assert.AreSame(moved.Made.Values.Single(), mt.Anchor, "the moved unit takes its moved anchor");
+ Assert.AreEqual(to, HexPicker.FromLonLat(mt.Anchor.Lon, mt.Anchor.Lat, hexes.bounds, hexes.hex_size_km));
+ Assert.AreEqual("", mt.Anchor.Place, "no source names the hex it moved to");
+ // The squadron and the ships are still the rows' tokens.
+ var late = NewGame(); late.Date = new DateTime(1948, 6, 1);
+ var rows = UnitRoster.Build(units, C, late, _ => true).Where(t => t.Unit.Service != UnitData.Army).ToList();
+ Assert.IsNotEmpty(rows);
+ CollectionAssert.AreEqual(rows, UnitRoster.FromState(units, C, late, _ => true, moved.At).Where(t => t.Unit.Service != UnitData.Army).ToList());
+ }
+
+ [TestCase(6, 6, 3)]
+ [TestCase(4, 6, 3)]
+ [TestCase(3, 6, 2)]
+ [TestCase(2, 6, 2)]
+ [TestCase(1, 6, 1)]
+ [TestCase(1, 1, 3)]
+ [TestCase(1, 2, 2)]
+ [TestCase(1, 4, 1)]
+ public void FiguresFollowTheAnswerAtEveryStrength(int strength, int full, int figures) =>
+ Assert.AreEqual(figures, UnitRoster.FiguresForStrength(strength, full), "Q-UI-3: 3 at two thirds or more, 2 at a third or more, 1 below");
+
+ /// <summary>Q-UI-3 on the map: a new game draws every unit at full strength with three figures whatever the call-up,
+ /// and a unit that lost strength shows it.</summary>
+ [Test]
+ public void FiguresFollowTheAnswer()
+ {
+ var s = NewGame();
+ s.Mobilization = 0; s.Rung = 1; // the call-up no longer sets the figures (legacy: 1 figure here)
+ var units = Units;
+ var moved = new Moved();
+ var army = Army(UnitRoster.FromState(units, C, s, _ => true, moved.At));
+ Assert.IsNotEmpty(army);
+ foreach (var t in army) Assert.AreEqual(3, t.Figures, $"{t}: full strength");
+ var big = s.Units.Values.Where(u => u.Side == "israel").OrderByDescending(u => u.Strength).ThenBy(u => u.Id).First();
+ Assert.AreEqual(5, big.Strength, "the largest brigades start at 5 units (docs/units.md, the starting forces)");
+ var row = C.StartingForces[big.Id].Row;
+ foreach (var (strength, figures) in new[] { (5, 3), (4, 3), (3, 2), (2, 2), (1, 1) })
+ {
+ var u = s.Units[big.Id];
+ s.Units[big.Id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, strength, u.Order, u.OrderTarget);
+ var t = Army(UnitRoster.FromState(units, C, s, _ => true, moved.At)).Single(x => x.Unit.Id == row);
+ Assert.AreEqual(figures, t.Figures, $"{row} at {strength} of 5");
+ Assert.AreEqual(figures, t.Headgear.Count, "one headgear per figure");
+ }
+ }
+
+ /// <summary>A unit that moved stands on a hex no source names: its card gives no position and the row's sources.</summary>
+ [Test]
+ public void AMovedUnitsCardNamesNoPlaceAndGivesTheRowsSources()
+ {
+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ var s = NewGame();
+ var u = s.Units.Values.First(x => x.Side == "israel");
+ var to = FreeNeighbour(s, u.Q, u.R);
+ MoveTo(s, u.Id, to.q, to.r);
+ var row = C.StartingForces[u.Id].Row;
+ var t = Army(UnitRoster.FromState(Units, C, s, _ => true, new Moved().At)).Single(x => x.Unit.Id == row);
+ var card = UnitCard.For(new PlacedToken(t, default), s, text);
+ var start = UnitRoster.AnchorAt(t.Unit, C.Rules.Start)!;
+ var position = string.IsNullOrWhiteSpace(start.Since) ? text.Format("unit.position_plain", start.Place) : text.Format("unit.position", start.Place, start.Since!);
+ var home = UnitCard.For(new PlacedToken(new UnitToken(t.Unit, start, 3, t.ArtType, false), default), s, text);
+ CollectionAssert.Contains(home.Body.Split('\n'), position, "on its starting anchor the card names the place");
+ CollectionAssert.DoesNotContain(card.Body.Split('\n'), position, "no position line for a hex no source names");
+ foreach (var host in t.Unit.AllSources().Select(x => new Uri(x.Url).Host)) StringAssert.Contains(host, card.Footer);
+ Assert.AreEqual(UnitData.IsWikipediaOnly(t.Unit) ? text["unit.draft_wikipedia"] : text["unit.draft"], card.Note);
+ }
+
+ /// <summary>A unit raised in play takes the next id, at or above <c>StartingForces.Count</c>, so it has no row and no art
+ /// yet: it draws no token (UnitRoster.FromState's id check).</summary>
+ [Test]
+ public void AUnitRaisedInPlayDrawsNoToken()
+ {
+ var s = NewGame();
+ var units = Units;
+ var before = Army(UnitRoster.FromState(units, C, s, _ => true, new Moved().At));
+ Assert.IsNotEmpty(before);
+ var like = s.Units.Values.First(x => x.Side == "israel");
+ var to = FreeNeighbour(s, like.Q, like.R);
+ Assert.GreaterOrEqual(s.NextId, C.StartingForces.Count, "ids below the count are the starting forces");
+ s.Units.Add(s.NextId, new Unit(s.NextId, like.Type, to.q, to.r, side: like.Side, strength: like.Strength)); s.NextId++;
+ CollectionAssert.AreEqual(before, Army(UnitRoster.FromState(units, C, s, _ => true, new Moved().At)), "the raised unit draws nothing");
+ }
+
+ /// <summary>Review point 3 on #1205: in the GDD loop the call-up no longer sets the figures, so the card's footer does not
+ /// lead with it. An army token's footer gives only its sources; the squadron's keeps the security level, which still
+ /// sets whether it flies. The legacy loop keeps the call-up line.</summary>
+ [Test]
+ public void TheGddCardDoesNotLeadWithTheCallUp()
+ {
+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ var s = NewGame(); s.Date = new DateTime(1948, 7, 1); // the squadron at Herzliya
+ var tokens = UnitRoster.FromState(Units, C, s, _ => true, new Moved().At);
+ var army = tokens.First(t => t.Unit.Service == UnitData.Army && t.Unit.Side == UnitData.Israel);
+ var air = tokens.First(t => t.Unit.Service == UnitData.Air);
+ var national = text.Format("unit.national", PlayerText.Percent(s.Mobilization), s.Rung);
+ string First(UnitToken t, bool gdd) => UnitCard.For(new PlacedToken(t, default), s, text, gdd).Footer.Split('\n')[0];
+ StringAssert.StartsWith(text.Format("unit.sources", ""), First(army, true), "an army token: sources only");
+ Assert.AreEqual(text.Format("unit.security", s.Rung), First(air, true), "the squadron: the security level alone");
+ Assert.AreEqual(national, First(army, false), "the legacy loop still leads with the call-up");
+ Assert.AreEqual(national, First(air, false));
+ }
+
+ /// <summary>#563's spot cache: a rebuild after a move places only the unit that moved; every other token keeps its spot,
+ /// and a unit back on its starting hex stands on its starting spot again.</summary>
+ [Test]
+ public void ARebuildAfterAMoveKeepsTheSpotCache()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
+ var map = new GameObject("MapScene").AddComponent<MapScene>();
+ try
+ {
+ map.Configure(Load("Terrain"), Load("SettlementMarker"), Load("HexSelection"), Load("Sea"), Load("MapFrame"));
+ Statecraft.Game.Map.Kits.KitPopulation.Use(Statecraft.Game.Map.Kits.KitPopulation.Parse(
+ File.ReadAllText(Path.Combine(Paths.Content, "map", Statecraft.Game.Map.Kits.KitPopulation.FileName))));
+ map.Build();
+ var s = NewGame();
+ var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);
+ Assert.IsTrue(layer.Show(C, s));
+ Assert.AreEqual(0, layer.MovedSpotsPlaced);
+ var start = layer.Tokens.ToDictionary(p => p.Token.Unit.Id, p => p.Spot);
+ var israel = s.Units.Values.Where(u => u.Side == "israel").Take(2).ToArray();
+ string a = C.StartingForces[israel[0].Id].Row, b = C.StartingForces[israel[1].Id].Row;
+ var home = (israel[0].Q, israel[0].R);
+
+ var to = FreeNeighbour(s, israel[0].Q, israel[0].R);
+ MoveTo(s, israel[0].Id, to.q, to.r);
+ Assert.IsTrue(layer.Show(C, s));
+ Assert.AreEqual(1, layer.MovedSpotsPlaced, "only the moved unit is placed");
+ var spotA = layer.Tokens.Single(p => p.Token.Unit.Id == a).Spot;
+ Assert.LessOrEqual(MapActions.Distance(spotA.Q, spotA.R, to.q, to.r), UnitPlacer.MaxShift, "within one hex of its sim hex");
+ foreach (var p in layer.Tokens.Where(p => p.Token.Unit.Id != a)) Assert.AreEqual(start[p.Token.Unit.Id], p.Spot, $"{p}: kept its spot");
+ Assert.IsFalse(layer.Tokens.Any(p => p.Token.Unit.Id != a && p.Q == spotA.Q && p.R == spotA.R), "off the other tokens' hexes");
+
+ var toB = FreeNeighbour(s, israel[1].Q, israel[1].R);
+ MoveTo(s, israel[1].Id, toB.q, toB.r);
+ Assert.IsTrue(layer.Show(C, s));
+ Assert.AreEqual(2, layer.MovedSpotsPlaced, "the second move places only the second unit");
+ Assert.AreEqual(spotA, layer.Tokens.Single(p => p.Token.Unit.Id == a).Spot, "the first keeps its cached spot");
+ Assert.IsFalse(layer.Show(C, s), "nothing changed, nothing rebuilt");
+
+ MoveTo(s, israel[0].Id, home.Item1, home.Item2);
+ Assert.IsTrue(layer.Show(C, s));
+ Assert.AreEqual(2, layer.MovedSpotsPlaced, "back home is the starting spot, not a new placement");
+ Assert.AreEqual(start[a], layer.Tokens.Single(p => p.Token.Unit.Id == a).Spot);
+ Assert.AreNotEqual(start[b], layer.Tokens.Single(p => p.Token.Unit.Id == b).Spot, "the second still stands where it moved");
+ }
+ finally { UnityEngine.Object.DestroyImmediate(map.gameObject); }
+ }
+
+ static Material Load(string name) => AssetDatabase.LoadAssetAtPath<Material>($"Assets/Materials/{name}.mat");
+}
diff --git a/unity/Assets/Tests/EditMode/UnitsFromStateTests.cs.meta b/unity/Assets/Tests/EditMode/UnitsFromStateTests.cs.meta
new file mode 100644
index 000000000..1d22f9f61
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitsFromStateTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: cf58dd62daa18cb8d841619be3ef5d5b
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
index 889d8103b..61ec1c69e 100644
--- a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
@@ -557,7 +557,7 @@ public class UnitsInPlayTests
var checkedFigures = 0; float worstFloat = 0f;
foreach (var d in new[] { new DateTime(1948, 5, 29), new DateTime(1948, 6, 5), new DateTime(1948, 7, 12), new DateTime(1948, 12, 4) })
{
- layer.Show(C, StateAt(d, 5, 0.8));
+ layer.Show(SimBridgeGddTests.Legacy, StateAt(d, 5, 0.8)); // the legacy loop: the war's tokens by date
foreach (var f in map.Terrain.transform.Find(UnitLayer.RootName).Find("Tokens").GetComponentsInChildren<Transform>().Where(t => t.name.StartsWith("Rifleman")))
{
var p = f.position; float lowest = float.MaxValue;
@@ -620,7 +620,7 @@ public class UnitsInPlayTests
int figures = 0, hidden = 0;
foreach (var d in OrchardDates)
{
- layer.Show(C, StateAt(d, 5, 0.8));
+ layer.Show(SimBridgeGddTests.Legacy, StateAt(d, 5, 0.8)); // the legacy loop: the war's tokens by date
var feet = FigureFeet(map);
Assert.Greater(feet.Count, 0, $"{d:yyyy-MM-dd}: figures are drawn");
var through = veg.Drawable().Where(t => UnderAFigure(t.kind, t.m, feet)).ToList();
@@ -647,7 +647,7 @@ public class UnitsInPlayTests
var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);
foreach (var d in OrchardDates.Concat(new[] { new DateTime(1948, 7, 25) }))
{
- layer.Show(C, StateAt(d, 5, 0.8));
+ layer.Show(SimBridgeGddTests.Legacy, StateAt(d, 5, 0.8)); // the legacy loop: the war's tokens by date
var feet = FigureFeet(map);
int expected = veg.Planted().Count(t => UnderAFigure(t.kind, t.m, feet));
Assert.AreEqual(expected, veg.Hidden, $"{d:yyyy-MM-dd}: exactly the trees under the shown figures are left out");
@@ -746,7 +746,8 @@ public class UnitsInPlayTests
{
var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);
var day = new DateTime(1948, 5, 29);
- layer.Show(C, StateAt(day, 5, 0.8));
+ // The legacy loop, whose roster follows the dates and the call-up (the GDD loop draws the sim's units).
+ layer.Show(SimBridgeGddTests.Legacy, StateAt(day, 5, 0.8));
var cam = Camera.main; Assert.IsNotNull(cam, "the default scene's camera");
var tokensRoot = map.Terrain.transform.Find(UnitLayer.RootName).Find("Tokens");
Dictionary<string, Vector3> Figures() => tokensRoot.Cast<Transform>().SelectMany(t => t.Cast<Transform>().Where(x => x.name.StartsWith("Rifleman"))
@@ -764,8 +765,8 @@ public class UnitsInPlayTests
Assert.Greater(at90.Count, 10, "the figures of 29 May 1948 (not a vacuous pass)");
// A roster change and back, the camera still at yaw 90: Rebuild faces the new tokens to it.
var fewer = StateAt(day, 5, 0.3);
- Assert.IsTrue(layer.Show(C, fewer), "the call-up changes the roster");
- Assert.IsTrue(layer.Show(C, StateAt(day, 5, 0.8)), "and back");
+ Assert.IsTrue(layer.Show(SimBridgeGddTests.Legacy, fewer), "the call-up changes the roster");
+ Assert.IsTrue(layer.Show(SimBridgeGddTests.Legacy, StateAt(day, 5, 0.8)), "and back");
AssertStill(at90, "rebuilt at yaw 90");
// A second camera at yaw 0 renders: the badges and flags face it, the figures stay turned for the game camera.
other.transform.SetPositionAndRotation(cam.transform.position, Quaternion.Euler(CameraRig.Pitch, 0f, 0f));
@@ -803,11 +804,12 @@ public class UnitsInPlayTests
Assert.IsTrue(layer.Show(C, session.State));
Assert.AreEqual(before, session.State.Hash(), "drawing the units changed the state");
Assert.IsFalse(layer.Show(C, session.State), "the same roster draws nothing new");
- Assert.AreEqual(10, layer.Tokens.Count);
+ // The GDD loop draws the sim's units (GDD Phase 5 PR 14): seven brigades and the two ships; Etzioni has no sim unit.
+ Assert.AreEqual(9, layer.Tokens.Count);
var tokens = map.Terrain.transform.Find(UnitLayer.RootName).Find("Tokens");
- Assert.AreEqual(10, tokens.childCount);
+ Assert.AreEqual(9, tokens.childCount);
var kiryati = tokens.Find("kiryati");
- Assert.AreEqual(3, kiryati.Cast<Transform>().Count(t => t.name.StartsWith("Rifleman")), "three riflemen at full call-up");
+ Assert.AreEqual(3, kiryati.Cast<Transform>().Count(t => t.name.StartsWith("Rifleman")), "three riflemen at full strength (Q-UI-3)");
var badge = kiryati.Find("Badge");
Assert.IsNotNull(badge, "the promo's badge over every token");
Assert.AreEqual(2, badge.GetComponentsInChildren<MeshRenderer>().Length, "a plate and a glyph");
@@ -1016,7 +1018,7 @@ public class UnitsInPlayTests
var words = ui.Q<VisualElement>("info-panel").Query<Label>().ToList().Select(l => l.text).ToList();
Assert.AreEqual("Golani Brigade", ui.Q<Label>("info-title").text);
Assert.IsTrue(words.Any(w => w.Contains("At Yavne'el since February 1948")), string.Join(" | ", words));
- Assert.IsTrue(words.Any(w => w.Contains("Reserve call-up 80%") && w.Contains("security level 5")), string.Join(" | ", words));
+ Assert.IsFalse(words.Any(w => w.Contains("Reserve call-up")), "the GDD loop: the call-up no longer sets the figures (#1205) | " + string.Join(" | ", words));
Assert.IsTrue(words.Any(w => w.Contains("Wikipedia only")), "a Wikipedia-only position says it is a draft");
Assert.AreEqual(DisplayStyle.None, ui.Q<Button>("build-camp").style.display.value, "no orders on a unit");
var defence = ui.Q<Button>("info-defence");
@@ -1057,11 +1059,12 @@ public class UnitsInPlayTests
var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);
var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(), null,
() => layer.Selected is string id ? layer.Tokens.First(p => p.Token.Unit.Id == id) : (PlacedToken?)null);
- layer.Show(C, StateAt(new DateTime(1948, 7, 12), 5, 0.8));
+ // The legacy loop, whose roster follows the dates and the call-up (the GDD loop draws the sim's units).
+ layer.Show(SimBridgeGddTests.Legacy, StateAt(new DateTime(1948, 7, 12), 5, 0.8));
var yiftach = layer.Tokens.Single(p => p.Token.Unit.Id == "yiftach");
GameRoot.OnHexClicked(map, layer, info, yiftach.Q, yiftach.R);
Assert.IsTrue(info.ShowsUnit);
- layer.Show(C, StateAt(new DateTime(1948, 7, 24), 5, 0.8)); // Operation Dani is over
+ layer.Show(SimBridgeGddTests.Legacy, StateAt(new DateTime(1948, 7, 24), 5, 0.8)); // Operation Dani is over
Assert.IsNull(layer.Selected);
Assert.IsNull(map.Terrain.transform.Find(UnitLayer.RootName).Find("SelectionRing"));
info.Render();
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 91b077e5d..787c1c8ce 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -403,6 +403,7 @@ unit.aircraft.spitfire: "Supermarine Spitfire LF Mk IXe"
unit.flying: "{0}, flying over the base"
unit.parked: "{0}, on the ground at the base"
unit.national: "Reserve call-up {0} · security level {1} of 5"
+unit.security: "Security level {0} of 5"
unit.sources: "Sources: {0}"
unit.draft_wikipedia: "Draft: from Wikipedia only, not yet checked against a published history"
unit.draft: "Draft: not yet checked by a historian"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 160d5ecbd..457606e37 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -420,6 +420,8 @@ unit.aircraft.spitfire: "ספיטפייר LF Mk IXe"
unit.flying: "{0}, בטיסה מעל הבסיס"
unit.parked: "{0}, על הקרקע בבסיס"
unit.national: "גיוס מילואים {0} · רמת ביטחון {1} מתוך 5"
+# The squadron card's footer in the GDD loop: the security level alone (#753). For the native reviewer (#564).
+unit.security: "רמת ביטחון {0} מתוך 5"
unit.sources: "מקורות: {0}"
unit.draft_wikipedia: "טיוטה: מוויקיפדיה בלבד, טרם נבדק מול מחקר שפורסם"
unit.draft: "טיוטה: טרם נבדק בידי היסטוריון"