Sick people seek MedicalOffice for tend by Medicine skill; symptoms cut talk weight; no heal API. Co-authored-by: Cursor <cursoragent@cursor.com>
100 lines
3.8 KiB
C#
100 lines
3.8 KiB
C#
using HSchool.Content;
|
|
using HSchool.People;
|
|
using HSchool.Server.Api;
|
|
using HSchool.Server.Game;
|
|
using HSchool.Simulation;
|
|
|
|
namespace HSchool.Server.Tests;
|
|
|
|
public class PersonCardReaderHealthTests
|
|
{
|
|
private static readonly DateTime Start = new(2012, 4, 3, 9, 0, 0, DateTimeKind.Utc);
|
|
|
|
[Fact]
|
|
public void Card_ShowsActiveHealthConditions()
|
|
{
|
|
var (catalog, map) = Vanilla();
|
|
var roster = RosterGenerator.Generate(catalog, map, schoolSeed: 80, "Russia", Start);
|
|
var pupil = roster.People.First(person => person.IsStudent && !person.IsParent);
|
|
HealthConditions.Add(
|
|
pupil,
|
|
new HealthCondition
|
|
{
|
|
DefName = "Influenza",
|
|
Severity = 0.5f,
|
|
Progress = 0.2f,
|
|
Source = "test",
|
|
StartedAt = Start.AddDays(-3),
|
|
});
|
|
|
|
var school = School.Create(80, "HealthCard", Start, catalog, map);
|
|
using (school)
|
|
{
|
|
school.InstallPeople(roster, 80, "Russia", ApplicantPool.Empty);
|
|
var card = PersonCardReader.Read(school, pupil.Id, "ru");
|
|
Assert.NotNull(card);
|
|
Assert.NotNull(card!.HealthConditions);
|
|
var row = Assert.Single(card.HealthConditions!);
|
|
Assert.Equal("Influenza", row.DefName);
|
|
Assert.Equal("Грипп", row.Label);
|
|
Assert.Equal(0.5f, row.Severity);
|
|
Assert.Equal(0.2f, row.Progress);
|
|
Assert.Equal("Высокая температура, мало сил на разговоры", row.Effect);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void HealthyCard_HasEmptyHealthConditions()
|
|
{
|
|
var (catalog, map) = Vanilla();
|
|
var roster = RosterGenerator.Generate(catalog, map, schoolSeed: 80, "Russia", Start);
|
|
var pupil = roster.People.First(person =>
|
|
person.IsStudent && (person.Conditions is null || person.Conditions.Count == 0));
|
|
var school = School.Create(81, "HealthEmpty", Start, catalog, map);
|
|
using (school)
|
|
{
|
|
school.InstallPeople(roster, 81, "Russia", ApplicantPool.Empty);
|
|
var card = PersonCardReader.Read(school, pupil.Id, "en");
|
|
Assert.NotNull(card);
|
|
Assert.NotNull(card!.HealthConditions);
|
|
Assert.Empty(card.HealthConditions!);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void WorkerCommands_HaveNoHealOrTendIntent()
|
|
{
|
|
var names = typeof(WorkerCommand).GetNestedTypes()
|
|
.Select(type => type.Name)
|
|
.ToArray();
|
|
Assert.DoesNotContain(names, name => name.Contains("Heal", StringComparison.OrdinalIgnoreCase));
|
|
Assert.DoesNotContain(names, name => name.Contains("Tend", StringComparison.OrdinalIgnoreCase));
|
|
Assert.DoesNotContain(names, name => name.Contains("Cure", StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
|
|
private static (DefCatalog Catalog, MapLayout Map) Vanilla()
|
|
{
|
|
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
|
|
Assert.True(Directory.Exists(root), $"Vanilla pack missing at {root}.");
|
|
var documents = new List<ContentDocument>();
|
|
foreach (var path in Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories))
|
|
{
|
|
if (!path.EndsWith(".jsonc", StringComparison.OrdinalIgnoreCase)
|
|
&& !path.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
documents.Add(new ContentDocument(
|
|
CatalogLoader.CorePackId,
|
|
Path.GetRelativePath(root, path).Replace('\\', '/'),
|
|
File.ReadAllText(path)));
|
|
}
|
|
|
|
var catalog = new CatalogLoader().Load([CatalogLoader.CorePackId], documents);
|
|
var map = CatalogLoader.LastDefaultMap([CatalogLoader.CorePackId], documents);
|
|
Assert.NotNull(map);
|
|
return (catalog, map);
|
|
}
|
|
}
|