Remember recent quarrels, fights and reprimands on the person.

Short offense list for the pupil card and save, capped by BehaviorDef — not a discipline score.
This commit is contained in:
Leonid Pershin
2026-08-21 09:37:12 +03:00
parent 910ba4da2d
commit fdcaed0f74
22 changed files with 760 additions and 16 deletions
+43 -1
View File
@@ -98,7 +98,49 @@ internal static partial class PersonCardReader
Connections: Connections(roster, person, catalog, locale),
Orientation: OrientationOf(person, catalog, locale),
TalkCircleMemberIds: circle?.MemberIds ?? [],
TalkTopicId: circle?.TopicId);
TalkTopicId: circle?.TopicId,
Offenses: Offenses(roster, person, catalog, locale));
}
private static IReadOnlyList<OffenseEntryResponse> Offenses(
Roster roster,
Person person,
DefCatalog? catalog,
string locale)
{
var rows = person.Offenses;
if (rows is null || rows.Count == 0)
{
return [];
}
var byId = roster.People.ToDictionary(candidate => candidate.Id, StringComparer.Ordinal);
var result = new OffenseEntryResponse[rows.Count];
for (var i = 0; i < rows.Count; i++)
{
var row = rows[i];
string? otherName = null;
if (row.OtherPersonId is { } otherId && byId.TryGetValue(otherId, out var other))
{
otherName = other.Name.Full;
}
var label = KindLabel(catalog, locale, row.Kind);
result[i] = new OffenseEntryResponse(row.Kind, label, row.Time, row.OtherPersonId, otherName);
}
return result;
}
private static string KindLabel(DefCatalog? catalog, string locale, string kind)
{
var key = OffenseKinds.LocaleKey(kind);
if (catalog is not null && catalog.HasText(locale, key))
{
return catalog.Text(locale, key);
}
return kind;
}
private static IReadOnlyDictionary<string, float>? LiveNeeds(World world, string personId)