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
@@ -1,4 +1,5 @@
using HSchool.Content;
using HSchool.People;
namespace HSchool.Ai.Tests;
@@ -97,6 +98,40 @@ public class LessonLearningTests
Assert.Equal(explicitWarm, implied);
}
[Fact]
public void MissingTextbook_HalvesGain()
{
var withBook = LessonLearning.Gain(50, Math, 1, 0.05f, 1f, 1f, 0, 100, warmth: 1f, textbookFactor: 1f);
var without = LessonLearning.Gain(50, Math, 1, 0.05f, 1f, 1f, 0, 100, warmth: 1f, textbookFactor: 0.5f);
Assert.Equal((withBook - 50) * 0.5f, without - 50, precision: 5);
}
[Fact]
public void TextbookInBag_OnlyThatSubjectCounts()
{
var items = new[]
{
new InventoryItem("Textbook", null, 1f, ItemLocations.Bag, "Literature"),
new InventoryItem("Textbook", null, 1f, ItemLocations.Locker, "Mathematics"),
};
Assert.False(LessonLearning.HasTextbookInBag(items, "Mathematics"));
Assert.True(LessonLearning.HasTextbookInBag(items, "Literature"));
}
[Fact]
public void TextbookAtHome_DoesNotCount()
{
var items = new[]
{
new InventoryItem("Textbook", null, 1f, ItemLocations.Home, "Mathematics"),
};
Assert.False(LessonLearning.HasTextbookInBag(items, "Mathematics"));
}
[Fact]
public void MissingTeacherSkill_UsesRangeMin_AndStillGains()
{