RynthCore as of 2026-11-08 (internal 9297e93): release 2026.11.8.1
This commit is contained in:
parent
418d80bafb
commit
c68204f160
99 changed files with 5032 additions and 185 deletions
|
|
@ -35,6 +35,9 @@ internal static class Program
|
|||
Missing();
|
||||
Words();
|
||||
Percents();
|
||||
XpPerKill();
|
||||
CorpseTime();
|
||||
ShieldTaken();
|
||||
Console.WriteLine($"DamageRowStatsTests: {_checks} checks, {_failed} failed.");
|
||||
return _failed == 0 ? 0 : 1;
|
||||
}
|
||||
|
|
@ -99,4 +102,113 @@ internal static class Program
|
|||
Eq(DamageRowStats.Percent(9, 200), "4.5%", "one decimal below 10%");
|
||||
Eq(DamageRowStats.Percent(7, 3), "100%", "clamped");
|
||||
}
|
||||
|
||||
private static void XpPerKill()
|
||||
{
|
||||
// An older RynthAi sends no xp/xk: nothing new on the line or in the tip.
|
||||
DamageRowStats old = Row(Full)!;
|
||||
Eq((old.Xp, old.XpKills, old.XpPerKill), (0L, 0, 0L), "no xp/xk: 0");
|
||||
Check(!old.Line().Contains("XP/kill"), "no xp/xk: no XP/kill on the line");
|
||||
Check(!old.Tip().Contains("XP:"), "no xp/xk: no XP in the tip");
|
||||
|
||||
DamageRowStats s = Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"k\":3,\"xp\":3703701,\"xk\":3}}")!;
|
||||
Eq((s.Xp, s.XpKills, s.XpPerKill), (3703701L, 3, 1234567L), "xp and xk read");
|
||||
Eq(s.Line(), "XP/kill 1,234,567 · It evades 23% (14/61)", "XP/kill leads the line, thousands");
|
||||
Check(s.Tip().Contains("XP: 3,703,701 from 3 kills, 1,234,567 per kill."), "tip: XP " + s.Tip());
|
||||
|
||||
Eq(Row("{\"mstats\":{\"xp\":5,\"xk\":2}}")!.XpPerKill, 3L, "rounded (2.5 up)");
|
||||
Eq(Row("{\"mstats\":{\"xp\":10,\"xk\":3}}")!.XpPerKill, 3L, "rounded (3.33 down)");
|
||||
Eq(Row("{\"mstats\":{\"k\":1,\"xp\":900,\"xk\":1}}")!.Line(), "XP/kill 900", "a kill with XP alone: the line shows XP/kill");
|
||||
Check(Row("{\"mstats\":{\"k\":1,\"xp\":900,\"xk\":1}}")!.Tip().Contains("from 1 kill,"), "one kill");
|
||||
Eq(Row("{\"mstats\":{\"k\":2,\"xp\":900,\"xk\":0}}")!.Line(), "", "xk 0: no XP/kill");
|
||||
Eq(Row("{\"mstats\":{\"k\":2,\"xp\":-50,\"xk\":-1}}")!.Line(), "", "negative xp/xk read as 0");
|
||||
Check(Row("{\"mstats\":{\"xp\":0,\"xk\":0}}") == null, "xp/xk all zero: no line");
|
||||
Eq(Row("{\"mstats\":{\"xp\":50000000000,\"xk\":2}}")!.Line(), "XP/kill 25,000,000,000", "XP past an int");
|
||||
}
|
||||
|
||||
private static void CorpseTime()
|
||||
{
|
||||
// An older RynthAi sends no cd/cn: nothing new.
|
||||
DamageRowStats old = Row(Full)!;
|
||||
Eq((old.CorpseMs, old.CorpseKills), (0, 0), "no cd/cn: 0");
|
||||
Check(!old.Line().Contains("Death animation"), "no cd/cn: no death animation on the line");
|
||||
Check(!old.Tip().Contains("Corpse appears"), "no cd/cn: no corpse in the tip");
|
||||
|
||||
DamageRowStats s = Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"k\":3,\"xp\":3703701,\"xk\":3,\"cd\":2140,\"cn\":3}}")!;
|
||||
Eq((s.CorpseMs, s.CorpseKills), (2140, 3), "cd and cn read");
|
||||
Eq(s.Line(), "XP/kill 1,234,567 · It evades 23% (14/61) · Death animation 2.1 s", "death animation last, after the rates");
|
||||
Eq(Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"at\":120,\"yev\":50,\"ysp\":8,\"yrs\":1,\"k\":3,\"cd\":2140,\"cn\":3}}")!.Line(),
|
||||
"It evades 23% (14/61) · You evade 42% (50/120) · You resist 13% (1/8) · Death animation 2.1 s", "far right, after You evade / You resist");
|
||||
Check(s.Tip().Contains("Corpse appears 2.1 s after the kill (over 3 kills)."), "tip: corpse " + s.Tip());
|
||||
Eq(Row("{\"mstats\":{\"k\":1,\"cd\":2140,\"cn\":1}}")!.Line(), "Death animation 2.1 s", "death animation alone (no XP sent)");
|
||||
Check(Row("{\"mstats\":{\"k\":1,\"cd\":900,\"cn\":1}}")!.Tip().Contains("(over 1 kill)."), "one kill");
|
||||
Check(Row("{\"mstats\":{\"cd\":1500,\"cn\":2}}") != null, "a timed corpse alone is something");
|
||||
|
||||
// Rounding to one decimal.
|
||||
Eq(Row("{\"mstats\":{\"cd\":2150,\"cn\":1}}")!.CorpseSeconds, "2.2", "2.15 s rounds up");
|
||||
Eq(Row("{\"mstats\":{\"cd\":2149,\"cn\":1}}")!.CorpseSeconds, "2.1", "2.149 s rounds down");
|
||||
Eq(Row("{\"mstats\":{\"cd\":3000,\"cn\":1}}")!.CorpseSeconds, "3.0", "whole seconds keep the decimal");
|
||||
Eq(Row("{\"mstats\":{\"cd\":40,\"cn\":1}}")!.CorpseSeconds, "0.0", "under 50 ms");
|
||||
Eq(Row("{\"mstats\":{\"cd\":12345,\"cn\":1}}")!.Line(), "Death animation 12.3 s", "over ten seconds");
|
||||
|
||||
// Bad values.
|
||||
Eq(Row("{\"mstats\":{\"k\":2,\"cd\":2000,\"cn\":0}}")!.Line(), "", "cn 0: no corpse");
|
||||
Eq(Row("{\"mstats\":{\"k\":2,\"cd\":2000}}")!.Line(), "", "cd without cn: no corpse");
|
||||
Eq(Row("{\"mstats\":{\"k\":2,\"cd\":2000,\"cn\":-4}}")!.Line(), "", "negative cn read as 0");
|
||||
Eq(Row("{\"mstats\":{\"cd\":-500,\"cn\":2}}")!.Line(), "Death animation 0.0 s", "negative cd read as 0");
|
||||
Eq(Row("{\"mstats\":{\"cd\":\"2000\",\"cn\":2}}")!.Line(), "Death animation 0.0 s", "text cd read as 0");
|
||||
Eq(Row("{\"mstats\":{\"k\":1,\"cd\":2000,\"cn\":1.5}}")!.Line(), "", "fractional cn read as 0");
|
||||
Check(Row("{\"mstats\":{\"cd\":0,\"cn\":0}}") == null, "cd/cn all zero: no line");
|
||||
}
|
||||
|
||||
// RynthAi 2026-11-08: the hits it landed by shield and facing (learned across logins).
|
||||
private const string Split =
|
||||
"{\"mstats\":{\"hsf\":19,\"dsf\":209,\"msf\":11,\"hsb\":1,\"dsb\":274,\"msb\":274,\"hnf\":54,\"dnf\":2916,\"mnf\":80}}";
|
||||
|
||||
private static void ShieldTaken()
|
||||
{
|
||||
// An older RynthAi sends no cells: nothing new.
|
||||
DamageRowStats old = Row(Full)!;
|
||||
Check(!old.HasShieldTaken, "no cells: none");
|
||||
Check(!old.Line().Contains("Hits taken"), "no cells: nothing on the line");
|
||||
Check(!old.Tip().Contains("Shield up"), "no cells: nothing in the tip");
|
||||
|
||||
// Cells alone (nothing since login): a row of its own, the session's numbers left out.
|
||||
DamageRowStats? s = Row(Split);
|
||||
Check(s != null, "the cells alone are something");
|
||||
if (s == null) return;
|
||||
Check(!s.HasSession, "no session numbers");
|
||||
Eq((s.ShieldCells[0].Hits, s.ShieldCells[0].Total, s.ShieldCells[0].Max), (19, 209L, 11L), "shield front read");
|
||||
Eq(s.ShieldCells[1].Hits, 1, "shield behind read");
|
||||
Eq(s.ShieldCells[2].Hits, 0, "a missing cell is 0");
|
||||
Eq((s.ShieldHits(true), s.ShieldHits(false)), (20, 54), "hits each way");
|
||||
Eq(Math.Round(s.ShieldAvg(true), 2), 24.15, "shield mean over every facing ((209 + 274) / 20)");
|
||||
Eq(s.Line(), "Hits taken: shield 24 avg (front 95%), no shield 54 avg", "the line");
|
||||
string tip = s.Tip();
|
||||
Check(!tip.Contains("Since you logged in"), "no session block: " + tip);
|
||||
Check(tip.Contains("Shield up: 20 hits, avg 24 - front 19 hits, avg 11, max 11; behind 1 hit, avg 274, max 274; facing unknown -."),
|
||||
"tip: shield cells: " + tip);
|
||||
Check(tip.Contains("No shield: 54 hits, avg 54 - front 54 hits, avg 54, max 80; behind -; facing unknown -."), "tip: no shield cells");
|
||||
Check(tip.Contains("within 90 degrees of your facing"), "tip: ACE's rule");
|
||||
|
||||
// With the session's numbers: the cells after XP/kill, the death animation last.
|
||||
DamageRowStats both = Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"k\":3,\"xp\":3703701,\"xk\":3,\"cd\":2140,\"cn\":3,"
|
||||
+ "\"hsf\":2,\"dsf\":20,\"msf\":12,\"hnb\":1,\"dnb\":60,\"mnb\":60}}")!;
|
||||
Eq(both.Line(), "XP/kill 1,234,567 · Hits taken: shield 10 avg (front 100%), no shield 60 avg · It evades 23% (14/61) · Death animation 2.1 s",
|
||||
"after XP/kill, before the rates; death animation last");
|
||||
Check(both.Tip().StartsWith("Since you logged in") && both.Tip().Contains("\n\nDamage it did to you, learned across logins:"),
|
||||
"tip: the session first, then the cells");
|
||||
|
||||
// One side only, and facing never measured.
|
||||
Eq(Row("{\"mstats\":{\"hnf\":3,\"dnf\":150,\"mnf\":60}}")!.Line(), "Hits taken: no shield 50 avg", "no shield only");
|
||||
Eq(Row("{\"mstats\":{\"hsu\":4,\"dsu\":40,\"msu\":12}}")!.Line(), "Hits taken: shield 10 avg (facing unknown)", "facing never measured");
|
||||
Eq(Row("{\"mstats\":{\"hsf\":1,\"dsf\":5,\"hsu\":3,\"dsu\":15}}")!.Line(), "Hits taken: shield 5 avg (front 100%)",
|
||||
"front share over the measured ones only");
|
||||
|
||||
// Bad values.
|
||||
Check(Row("{\"mstats\":{\"hsf\":0,\"dsf\":50}}") == null, "damage without hits: nothing");
|
||||
Check(Row("{\"mstats\":{\"hsf\":-3,\"dsf\":50}}") == null, "negative hits read as 0");
|
||||
Eq(Row("{\"mstats\":{\"hsf\":2,\"dsf\":-50}}")!.Line(), "Hits taken: shield 0 avg (front 100%)", "negative damage read as 0");
|
||||
Check(Row("{\"mstats\":{\"hsf\":1.5,\"dsf\":50}}") == null, "fractional hits read as 0");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue