using HSchool.Content; namespace HSchool.Ai; /// /// How much a lesson adds to one skill this step. Hungry learns worse; trait offsets scale the /// rate. The world stores the running total — this is just the number. /// public static class LessonLearning { public static float NeedFactor(float hunger) => Math.Clamp(0.25f + (0.75f * hunger), 0.25f, 1f); public static float TraitFactor(int offset) => Math.Max(0.1f, 1f + (offset / 100f)); public static float Gain( float current, SkillDef skill, float share, float lessonSkillPerHour, float hours, float hunger, int traitOffset) { ArgumentNullException.ThrowIfNull(skill); var delta = share * lessonSkillPerHour * hours * NeedFactor(hunger) * TraitFactor(traitOffset); return Math.Clamp(current + delta, skill.Range.Min, skill.Range.Max); } }