手册数值改为占位符,渲染时从 Tuning 取值;加规则文件和测试

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ZHU MINCHAOandClaude Sonnet 5.5 committed 2026-11-04 12:45:29 +08:00
1 parent 38f9ea9daf
commit d28ca4e50c
6 files changed
+94 -3

No files matched your search

@@ -1515,6 +1515,21 @@ internal static class Program
Check(Merchants.PlatformAccepts.Contains(Assets.CRT) && Tuning.BmAutoSwapSlip > Tuning.DexFee * 10, "自动换币的滑点远高于 DEX 手续费");
});
Test("手册数值占位符:中英文都能从 Tuning 取到值,渲染后不留花括号", () =>
{
var dir = System.IO.Path.GetFullPath(System.IO.Path.Combine(AppContext.BaseDirectory, "../../../../../src/Decentralized/ModFiles/Localization"));
foreach (var lang in new[] { "zh", "en" })
{
var line = System.IO.File.ReadAllLines(System.IO.Path.Combine(dir, lang + ".csv")).First(l => l.StartsWith("guide.web3.text,"));
var text = line.Substring("guide.web3.text,".Length).Trim('"').Replace("\"\"", "\"");
Check(text.Contains("{"), lang + " 手册用了占位符");
var bad = TuningText.Unresolved(text);
Check(bad.Count == 0, lang + " 手册有取不到值的占位符:" + string.Join(" ", bad));
Check(!TuningText.Render(text).Contains("{"), lang + " 渲染后没有残留花括号");
}
Check(TuningText.Render("{BmListFee:%}") == "5%" && TuningText.Render("{PonziRates[4]:%}") == "10%" && TuningText.Render("{WalletMax}") == "5", "格式:百分比、数组下标、整数");
});
Test("预测市场:先验概率", () =>
{
Check(Math.Abs(PredictMath.PurityAtLeast(8500, 8000, 8999) - 0.5) < 1e-9, "纯度 8500 以上一半");