Bruise heals on real seconds: wounds are Acute, Slow is for toxins, radiation and osmosis; one-lung test pins Breathing 0.5 at scale 1 and 20 and the blood store both sides (uptake)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-25 23:33:48 +01:00
commit cc26fa39ef
2 changed files with 29 additions and 6 deletions

View file

@ -70,14 +70,14 @@ namespace Lodur
var afflictions = new[]
{
// Acute: a wound bleeds, clots and heals in real seconds whatever the slow scale (ruling bds-physiology-clock). 1 mL/s per HP of severity
// Acute: a wound (Cut, Bruise) bleeds, clots and heals in real seconds whatever the slow scale (ruling bds-physiology-clock); Slow is for toxins, radiation and osmosis only. 1 mL/s per HP of severity
// (play-tuned), clotting with age (play-tuned); heals 10 HP per day of real seconds (RimWorld's rate).
new AfflictionDef("Cut", PhysiologyClock.Acute, -10.0 / Day, true, new[]
{
Curve(EffectTarget.Bleed, EffectOp.Offset, EffectDriver.Severity, (0.0, 0.0), (100.0, 1e-4)),
Curve(EffectTarget.Bleed, EffectOp.Factor, EffectDriver.Age, (0.0, 1.0), (60.0, 0.5), (300.0, 0.1)),
}),
new AfflictionDef("Bruise", PhysiologyClock.Slow, -20.0 / Day, true, Array.Empty<Effect>()),
new AfflictionDef("Bruise", PhysiologyClock.Acute, -20.0 / Day, true, Array.Empty<Effect>()),
};
// ATLS class IV past 40% loss (research df-and-atls) puts the lethal fraction at 0.5 (play-tuned); regrowth is RimWorld's 0.333 per slow day.

View file

@ -95,10 +95,12 @@ public sealed class OxygenTests
Assert.Equal(DeathCause.Consciousness, p.Cause);
}
[Fact]
public void One_lung_lost_still_breathes()
[Theory]
[InlineData(1.0)]
[InlineData(20.0)]
public void One_lung_lost_still_breathes(double slowScale)
{
var p = Spawn();
var p = new Physiology(Body, PhysiologyPlans.Humanoid(), slowScale);
var torso = Body.PartIndex("Torso");
Assert.True(p.Afflict(PhysiologyPlans.Humanoid().AfflictionIndex("Bruise"), torso, p.TissueIndex(torso, "LungLeft"), 16));
double c = 1.0;
@ -109,10 +111,31 @@ public sealed class OxygenTests
Assert.True(c >= 0.9, $"consciousness {c} at step {i}");
}
Assert.InRange(p.Breathing, 0.5, 0.52); // the bruise heals a little on the slow clock
Assert.Equal(0.5, p.Breathing); // the bruise is a wound: real seconds, so the slow scale cannot heal it
// Half the ventilation settles the blood store at 1 - use / (uptake x breathing) = 0.978 here: uptake 1.0 gives that, 0.5 gives 0.956, 2.0 gives 0.989;
// the bounds are the geometric midpoints of the deficit (ruling deterministic-bound-margin).
Assert.InRange(p.BloodOxygen, 0.969, 0.9844);
Assert.False(p.Dead);
}
[Fact]
public void A_bruise_heals_identically_at_every_slow_scale()
{
double Left(double scale)
{
var p = new Physiology(Body, PhysiologyPlans.Humanoid(), scale);
var torso = Body.PartIndex("Torso");
Assert.True(p.Afflict(PhysiologyPlans.Humanoid().AfflictionIndex("Bruise"), torso, p.TissueIndex(torso, "LungLeft"), 16));
for (var i = 0; i < (int)(300.0 / Dt); i++) p.Step(Dt);
Assert.Equal(1, Live(p));
return p.SlotSeverity(0);
}
var real = Left(1.0);
Assert.Equal(real, Left(20.0));
Assert.Equal(16.0 - 20.0 * 300.0 / 86400.0, real, 6); // 20 HP per day of real seconds
}
[Fact]
public void A_lifted_smothering_refills()
{