Sick people seek MedicalOffice for tend by Medicine skill; symptoms cut talk weight; no heal API. Co-authored-by: Cursor <cursoragent@cursor.com>
103 lines
3.2 KiB
C#
103 lines
3.2 KiB
C#
using HSchool.Content;
|
|
using HSchool.People;
|
|
|
|
namespace HSchool.People.Tests;
|
|
|
|
public class NurseTendAndTalkWeightTests
|
|
{
|
|
private static readonly DateTime Now = new(2012, 4, 3, 10, 0, 0, DateTimeKind.Utc);
|
|
|
|
[Fact]
|
|
public void Tend_WithMedicine_DropsSeverityFasterThanNaturalTick()
|
|
{
|
|
var catalog = LoadVanilla();
|
|
var tended = Blank("a");
|
|
var control = Blank("b");
|
|
Onset(tended, "CommonCold", 0.55f);
|
|
Onset(control, "CommonCold", 0.55f);
|
|
|
|
Assert.True(DiseaseEffects.Tend(
|
|
tended,
|
|
peopleSeed: 7,
|
|
dayNumber: 100,
|
|
gameMinutes: 24 * 60,
|
|
catalog,
|
|
medicineSkill: 90f,
|
|
Now));
|
|
Assert.True(HealthConditions.Tick(
|
|
control,
|
|
peopleSeed: 7,
|
|
dayNumber: 100,
|
|
gameMinutes: 24 * 60,
|
|
catalog,
|
|
Now));
|
|
|
|
Assert.True(tended.Conditions![0].Severity < control.Conditions![0].Severity);
|
|
Assert.True(tended.Conditions[0].Progress > control.Conditions[0].Progress);
|
|
}
|
|
|
|
[Fact]
|
|
public void HeavySymptom_TalkWeightBelowHealthyControl()
|
|
{
|
|
var catalog = LoadVanilla();
|
|
var sick = Blank("s");
|
|
var healthy = Blank("h");
|
|
Onset(sick, "Influenza", 0.8f);
|
|
|
|
var sickFactor = DiseaseEffects.TalkWeightFactor(sick, catalog, Now);
|
|
var healthyFactor = DiseaseEffects.TalkWeightFactor(healthy, catalog, Now);
|
|
Assert.Equal(1f, healthyFactor);
|
|
Assert.True(sickFactor < 0.3f);
|
|
Assert.True(sickFactor < healthyFactor);
|
|
}
|
|
|
|
private static void Onset(Person person, string defName, float severity) =>
|
|
HealthConditions.Add(
|
|
person,
|
|
new HealthCondition
|
|
{
|
|
DefName = defName,
|
|
Severity = severity,
|
|
Progress = 0.1f,
|
|
Source = "test",
|
|
StartedAt = Now.AddDays(-3),
|
|
});
|
|
|
|
private static Person Blank(string id)
|
|
{
|
|
var cases = new CaseTable
|
|
{
|
|
Nom = id,
|
|
Gen = id,
|
|
Dat = id,
|
|
Acc = id,
|
|
Ins = id,
|
|
Pre = id,
|
|
};
|
|
return new Person
|
|
{
|
|
Id = id,
|
|
FamilyId = "f",
|
|
Female = false,
|
|
BirthDate = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc),
|
|
Name = new PersonName(id, id, id, cases, cases, cases),
|
|
IsStudent = true,
|
|
IsStaff = false,
|
|
IsParent = false,
|
|
Numbers = new Dictionary<string, int>(StringComparer.Ordinal),
|
|
Choices = new Dictionary<string, string>(StringComparer.Ordinal),
|
|
Skills = new Dictionary<string, int>(StringComparer.Ordinal),
|
|
Traits = [],
|
|
Needs = new Dictionary<string, float>(StringComparer.Ordinal),
|
|
Opinions = new Dictionary<string, int>(StringComparer.Ordinal),
|
|
};
|
|
}
|
|
|
|
private static DefCatalog LoadVanilla()
|
|
{
|
|
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
|
|
var documents = PackDocuments.FromDirectory(CatalogLoader.CorePackId, root).ToList();
|
|
return new CatalogLoader().Load([CatalogLoader.CorePackId], documents);
|
|
}
|
|
}
|