Merge branch 'phase/69-offense-memory'
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # src/HSchool.Server/Api/PeopleModels.cs # src/HSchool.Server/Game/PersonCardReader.cs
This commit is contained in:
@@ -108,7 +108,49 @@ internal static partial class PersonCardReader
|
||||
TalkCircleMemberIds: circle?.MemberIds ?? [],
|
||||
TalkTopicId: circle?.TopicId,
|
||||
ClassTeacherId: classTeacherId,
|
||||
ClassTeacherName: classTeacherName);
|
||||
ClassTeacherName: classTeacherName,
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user