Sample outdoor weather from the climate preset so people can freeze and the clock can show it.

Protocol v8 adds tenths of a °C and precipitation to the clock frame; warmth drains from insulation versus place temperature.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 03:49:40 +03:00
co-authored by Cursor
parent d8f4958167
commit 8e7ab46e79
40 changed files with 1008 additions and 39 deletions
@@ -0,0 +1,72 @@
namespace HSchool.Content.Tests;
public class ClimatePresetTests
{
private readonly CatalogLoader _loader = new();
[Fact]
public void VanillaPresets_HaveWorkingWeatherNumbers()
{
var catalog = Vanilla();
var temperate = catalog.ClimatePresets["TemperateContinental"];
Assert.Equal(12, temperate.MonthlyNorms.Count);
Assert.True(temperate.MonthlyNorms[0] < temperate.MonthlyNorms[6]);
Assert.InRange(temperate.PrecipitationChance, 0f, 1f);
Assert.True(temperate.IndoorOffset > 0);
var cold = catalog.ClimatePresets["ContinentalCold"];
Assert.True(cold.MonthlyNorms[0] < temperate.MonthlyNorms[0]);
}
[Fact]
public void HeatAndColdLoving_AreMutuallyIncompatible_AndOffsetComfort()
{
var catalog = Vanilla();
var heat = catalog.Traits["HeatLoving"];
var cold = catalog.Traits["ColdLoving"];
Assert.Contains("ColdLoving", heat.Incompatible);
Assert.Contains("HeatLoving", cold.Incompatible);
Assert.Contains("ColdLoving", catalog.TraitIncompatibilities("HeatLoving"));
Assert.Contains("HeatLoving", catalog.TraitIncompatibilities("ColdLoving"));
Assert.True(heat.ComfortTemperatureOffset > 0);
Assert.True(cold.ComfortTemperatureOffset < 0);
}
[Fact]
public void WarmthNeed_RestoresOffCampus_AndIsEnvironmental()
{
var warmth = Vanilla().Needs["Warmth"];
Assert.True(warmth.RestoredOffCampus);
Assert.True(warmth.Environmental);
Assert.True(warmth.DecayPerHour > 0);
}
[Fact]
public void Porch_IsOutdoor()
{
Assert.True(Vanilla().Rooms["EntranceHall"].Outdoor);
Assert.False(Vanilla().Rooms["Classroom"].Outdoor);
}
[Fact]
public void ConcretePresetWithoutMonthlyNorms_FailsTheCatalog()
{
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
[CatalogLoader.CorePackId],
[
PackDocuments.Def(
CatalogLoader.CorePackId,
"climates",
"empty",
"""{ "defName": "EmptyClimate" }"""),
]));
Assert.Contains("monthlyNorms", ex.Message, StringComparison.Ordinal);
}
private DefCatalog Vanilla()
{
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
return _loader.Load([CatalogLoader.CorePackId], PackDocuments.FromDirectory(CatalogLoader.CorePackId, root));
}
}
@@ -36,7 +36,7 @@ public class CountryDefTests
CatalogLoader.CorePackId,
"climates",
"temperate",
"""{ "defName": "TemperateContinental" }"""),
"""{ "defName": "TemperateContinental", "monthlyNorms": [0,0,0,0,0,0,0,0,0,0,0,0] }"""),
PackDocuments.Def(
CatalogLoader.CorePackId,
"countries",
@@ -58,7 +58,7 @@ public class CountryDefTests
CatalogLoader.CorePackId,
"climates",
"temperate",
"""{ "defName": "TemperateContinental" }"""),
"""{ "defName": "TemperateContinental", "monthlyNorms": [0,0,0,0,0,0,0,0,0,0,0,0] }"""),
PackDocuments.Def(
CatalogLoader.CorePackId,
"countries",
@@ -11,13 +11,15 @@ public class PeopleDefTests
var catalog = _loader.Load([CatalogLoader.CorePackId], PackDocuments.FromDirectory(CatalogLoader.CorePackId, root));
Assert.True(catalog.Skills.Count >= 10);
Assert.Equal(10, catalog.Traits.Count);
Assert.Equal(4, catalog.Needs.Count);
Assert.Equal(12, catalog.Traits.Count);
Assert.Equal(5, catalog.Needs.Count);
Assert.True(catalog.BodyAttributes.ContainsKey("Height"));
Assert.Equal(BodyAttributeKind.Number, catalog.BodyAttributes["Height"].Kind);
Assert.Equal(BodyAttributeKind.Choice, catalog.BodyAttributes["HairColor"].Kind);
Assert.All(catalog.Needs.Values, need => Assert.True(need.DecayPerHour > 0));
Assert.True(catalog.Needs["Sleep"].RestoredOffCampus);
Assert.True(catalog.Needs["Warmth"].RestoredOffCampus);
Assert.True(catalog.Needs["Warmth"].Environmental);
Assert.Equal(0.2f, catalog.Needs["Hunger"].DecayPerHour);
Assert.True(catalog.Skills["Communication"].Always);
Assert.True(catalog.Skills["Agility"].Always);
@@ -223,7 +225,7 @@ public class PeopleDefTests
CatalogLoader.CorePackId,
"climates",
"temperate",
"""{ "defName": "TemperateContinental" }"""),
"""{ "defName": "TemperateContinental", "monthlyNorms": [0,0,0,0,0,0,0,0,0,0,0,0] }"""),
PackDocuments.Def(
CatalogLoader.CorePackId,
"countries",