Stats: stat sheets, formulas, archetypes, traits, stat pools, actions, conditions and sheet panel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cthangoverandClaude Opus 5.5 committed 2026-10-24 10:01:14 +02:00
commit c6e53dedd3
66 files changed
+3976

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
namespace Cthangover.Mods.Stats.Tests
{
using System.Text.Json;
using Cthangover.Core.Mods.Testing;
/// <summary>The saved stats survive a JSON round trip in every field.</summary>
public class StatStateDataTests
{
[ModTest("state/json_round_trip")]
static void JsonRoundTrip(ModTestContext ctx)
{
var original = new StatStateData();
var hero = new CharacterStatState { Archetype = "warrior", Level = 3, Exp = 61 };
hero.Bonus["str"] = 2;
hero.Bonus["cha"] = -1.5;
hero.Pools["mp"] = 4;
original.Characters["rpg_hero"] = hero;
var restored = JsonSerializer.Deserialize<StatStateData>(JsonSerializer.Serialize(original));
var back = restored.Characters["rpg_hero"];
ModAssert.Equal("warrior", back.Archetype, "archetype");
ModAssert.Equal(3, back.Level, "level");
ModAssert.Equal(61, back.Exp, "exp");
ModAssert.CloseTo(2, back.Bonus["str"], what: "bonus str");
ModAssert.CloseTo(-1.5, back.Bonus["cha"], what: "negative bonus");
ModAssert.CloseTo(4, back.Pools["mp"], what: "pool");
}
[ModTest("state/of_creates_find_ignores_case")]
static void OfCreatesFindIgnoresCase(ModTestContext ctx)
{
var state = new StatState();
ModAssert.Null(state.Find("Hero"), "nothing yet");
var created = state.Of("Hero");
ModAssert.True(ReferenceEquals(created, state.Of("hero")), "the same entry in any case");
ModAssert.True(ReferenceEquals(created, state.Find("HERO")), "find ignores case");
}
}
}