Halve lesson gain when the bag has no textbook for the subject.

Locker and home do not count. A pack without the field keeps vanilla 0.5.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 09:27:46 +03:00
co-authored by Cursor
parent f4a793aca4
commit 1b3479f984
13 changed files with 252 additions and 20 deletions
+12 -3
View File
@@ -8,8 +8,9 @@ namespace HSchool.Simulation;
/// <summary>
/// Grows skills for people who are actually in the lesson: at the room, not walking, not off
/// doing something else, and with the assigned teacher standing there. The formula lives in
/// <see cref="HSchool.Ai.LessonLearning"/>.
/// doing something else, and with the assigned teacher standing there. A pupil without today's
/// textbook in the bag learns at <see cref="BehaviorDef.LessonNoTextbookFactor"/>. The formula
/// lives in <see cref="HSchool.Ai.LessonLearning"/>.
/// </summary>
internal static class LessonLearningSystem
{
@@ -90,6 +91,13 @@ internal static class LessonLearningSystem
school.TryLogLessonOnce(personId, PersonLogTypes.LessonCold, lesson.Subject);
}
var textbookFactor = 1f;
if (person.IsStudent && !LessonLearning.HasTextbookInBag(person.Items, lesson.Subject))
{
textbookFactor = rules.LessonNoTextbookFactor;
school.TryLogLessonOnce(personId, PersonLogTypes.LessonNoTextbook, lesson.Subject);
}
IReadOnlyDictionary<string, float> taught = teacherSkills.TryGetValue(lesson.TeacherId, out var found)
? found
: new Dictionary<string, float>(StringComparer.Ordinal);
@@ -115,7 +123,8 @@ internal static class LessonLearningSystem
hunger,
TraitOffset(catalog, traits, share.Skill),
teacherSkill,
warmth);
warmth,
textbookFactor);
}
});
}
+6 -2
View File
@@ -17,6 +17,7 @@ public static class PersonLogTypes
public const string ApparelChanged = "apparel-changed";
public const string LessonNoTeacher = "lesson-no-teacher";
public const string LessonCold = "lesson-cold";
public const string LessonNoTextbook = "lesson-no-textbook";
}
/// <summary>
@@ -62,14 +63,17 @@ public sealed record PersonLogEvent(string PersonId, DateTime Time, string Type,
}
if (Type.Equals(PersonLogTypes.LessonNoTeacher, StringComparison.Ordinal)
|| Type.Equals(PersonLogTypes.LessonCold, StringComparison.Ordinal))
|| Type.Equals(PersonLogTypes.LessonCold, StringComparison.Ordinal)
|| Type.Equals(PersonLogTypes.LessonNoTextbook, StringComparison.Ordinal))
{
var name = catalog.Subjects.TryGetValue(ThingDef, out var subject)
? catalog.Label(locale, subject)
: ThingDef;
var key = Type.Equals(PersonLogTypes.LessonCold, StringComparison.Ordinal)
? "LessonCold"
: "LessonNoTeacher";
: Type.Equals(PersonLogTypes.LessonNoTextbook, StringComparison.Ordinal)
? "LessonNoTextbook"
: "LessonNoTeacher";
return string.Format(CultureInfo.InvariantCulture, catalog.Text(locale, key), name);
}