手册数值改为占位符,渲染时从 Tuning 取值;加规则文件和测试
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
38f9ea9daf
commit
d28ca4e50c
6 files changed
+94
-3
No files matched your search
@@ -0,0 +1,12 @@
|
||||
# 项目规则
|
||||
|
||||
## 数值
|
||||
|
||||
- 数值全部放在同一个配置类里(`src/Decentralized.Domain/Tuning.cs`,可以用嵌套类按主题划分),代码、测试里不写魔数。
|
||||
- 手册、说明文字里的数值不手写:用占位符 `{Name}`、`{Name:%}`、`{Name[2]:%}`(嵌套类用 `{Section.Name}`),由 `TuningText.Render` 在显示时从配置类取值。数值一改,文字跟着变。
|
||||
- 新增数值:先加进 `Tuning`,再登记到运营仓库的 `docs/tuning-index.md`,说明文字里用占位符引用。
|
||||
- 单元测试(`TuningText` 那一条)检查中英文手册的占位符都取得到值。
|
||||
|
||||
## 文案
|
||||
|
||||
- 界面标签用名词,提示用陈述句,不口语化;NPC 对话和报纸正文除外。界面不放说明文字,规则说明写进手册。
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Decentralized.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 文本里的数值占位符:<c>{Name}</c>、<c>{Name:%}</c>、<c>{Name[2]:%}</c>,也可以走嵌套类 <c>{Section.Name}</c>。
|
||||
/// 手册等说明文字不直接写数字,渲染时从 <see cref="Tuning"/> 取值,数值一改文字跟着变。
|
||||
/// <c>%</c> 把小数按百分比显示(0.03 → 3%);不带格式时去掉多余的零。
|
||||
/// </summary>
|
||||
public static class TuningText
|
||||
{
|
||||
private static readonly Regex Placeholder = new Regex(@"\{([A-Za-z0-9_.]+)(?:\[(\d+)\])?(?::(%))?\}", RegexOptions.Compiled);
|
||||
|
||||
public static string Render(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return text;
|
||||
return Placeholder.Replace(text, m => TryValue(m.Groups[1].Value, m.Groups[2].Success ? int.Parse(m.Groups[2].Value) : -1, out var v)
|
||||
? Format(v, m.Groups[3].Success)
|
||||
: m.Value);
|
||||
}
|
||||
|
||||
/// <summary>文本里取不到值的占位符(测试用)。</summary>
|
||||
public static System.Collections.Generic.List<string> Unresolved(string text)
|
||||
{
|
||||
var bad = new System.Collections.Generic.List<string>();
|
||||
foreach (Match m in Placeholder.Matches(text ?? ""))
|
||||
if (!TryValue(m.Groups[1].Value, m.Groups[2].Success ? int.Parse(m.Groups[2].Value) : -1, out _)) bad.Add(m.Value);
|
||||
return bad;
|
||||
}
|
||||
|
||||
private static string Format(double v, bool percent)
|
||||
{
|
||||
if (percent) v *= 100;
|
||||
return Math.Round(v, 4).ToString("0.####", CultureInfo.InvariantCulture) + (percent ? "%" : "");
|
||||
}
|
||||
|
||||
private static bool TryValue(string path, int index, out double value)
|
||||
{
|
||||
value = 0;
|
||||
var type = typeof(Tuning);
|
||||
var parts = path.Split('.');
|
||||
for (int i = 0; i < parts.Length - 1; i++)
|
||||
{
|
||||
type = type.GetNestedType(parts[i], BindingFlags.Public | BindingFlags.Static);
|
||||
if (type == null) return false;
|
||||
}
|
||||
var field = type.GetField(parts[parts.Length - 1], BindingFlags.Public | BindingFlags.Static);
|
||||
if (field == null) return false;
|
||||
var raw = field.GetValue(null);
|
||||
if (raw is Array arr)
|
||||
{
|
||||
if (index < 0 || index >= arr.Length) return false;
|
||||
raw = arr.GetValue(index);
|
||||
}
|
||||
else if (index >= 0) return false;
|
||||
try { value = Convert.ToDouble(raw, CultureInfo.InvariantCulture); return true; }
|
||||
catch (Exception) { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Decentralized.Domain;
|
||||
|
||||
namespace Decentralized
|
||||
{
|
||||
@@ -41,7 +42,7 @@ namespace Decentralized
|
||||
|
||||
public static void Open()
|
||||
{
|
||||
var chapters = L.T("guide.web3.text").Replace("¶", "\n\n").Split('§');
|
||||
var chapters = TuningText.Render(L.T("guide.web3.text")).Replace("¶", "\n\n").Split('§');
|
||||
if (_chapter >= chapters.Length) _chapter = 0;
|
||||
var b = CustomUIManager.Window(Id, L.T("item.web3guide.name"));
|
||||
if (b == null) return;
|
||||
|
||||
@@ -267,7 +267,7 @@ black.kind.Tech,High-tech (markup)
|
||||
nightlog.bm.ready,"Black market: {0} arrived; a courier will come by once you open."
|
||||
item.web3guide.name,Web3 Handbook
|
||||
item.web3guide.desc,Terminal manual: read by chapter.
|
||||
guide.web3.text,"Bank and trading: depositing turns credits into CRC in your Poinbase account; withdrawing turns CRC back into credits and goes through compliance screening, which looks at the Poinbase account's taint.¶Trading: PSC stands for Probably Stolen Coin, the coin mined by GPUs and miners. Buys are paid in the quote coin, sells in the traded coin.§Mixer: pick a coin, amount and rounds; each round takes a fee and lowers taint, rounds equal days of waiting, and the coins come back to the same address; the more you deposit, the worse the cleaning.§Hardware wallets: on-chain coins sit in PLEDGER hardware wallets, each with its own balances and taint; open and connect them on the terminal's Wallets page. The Web3 page's trading, shop and mixer use the connected wallet, and coin-paying customers and mining rewards go into it too.¶Payments (shop, mixer, Ponero desk, listing fees) start as an invoice on the terminal; type the payee address on the wallet and hold ✓ to sign. The last two characters of an address are a checksum, so a one-character typo is usually caught; once in a while it happens to be valid and the coins go to an address nobody uses. DEX swaps also need a signature on the wallet.¶Poinbase is a custodial account and can withdraw straight to the connected wallet; depositing from a wallet means sending to Poinbase's deposit address, which takes only CRC and PSC. More hardware wallets are sold by Dr. Jackson; drag one onto the trading terminal to add it, up to 5. The shop has cheaper ones. A wallet you no longer want can be destroyed on the Wallets page once its coins are moved out.¶Transfers pay a fee: slow, normal or fast, and gas prices rise and fall over roughly a week; when the network is congested fees rise and slow transactions may be dropped from the mempool. Check the full address before sending.§Staking: CRA staked in the Revolution pool earns a daily rate that compounds into the stake; withdrawing means requesting first and waiting four days, with no interest while waiting and no way to take it early. The pool pays from a subsidy fund; when it runs low the rate is cut and word of big holders pulling out may spread. Treat that as a warning: once it collapses CRA is worthless within three days and four days of unlocking is too slow. The balance token SPARK can be minted and burned against CRA at the going price (with a fee); its price swings hard and crashes with the collapse. Staking, minting and burning are contract calls and need a signature on the wallet.§Miners: RatDigg miners (M1 / M2 / M3) are standalone machines with far more hash than a card and a lower power draw per hash; they need a battery, take modules and use no rig slots. Only the shop's miner dealers sell them, gated by black-market standing (M1 40, M2 60, M3 80), sometimes second-hand. When one burns out, repair it by putting electronic components in its repair slot in order; it comes back 20 health lower. Somewhere between day 50 and day 90 a ""miner era"" arrives, announced in the paper a few days earlier: the big farms halve their power costs, network hash climbs, GPU miners are diluted and low-end cards barely earn, while miners still do fine.§Perps: the Perps tab on Poinbase uses your account CRC as margin, up to 5× on PSC and 3× on SPARK, one position per product, never long and short at once. Fills are worse than the quote (more so for bigger orders, like the spot pool) and opening and closing both cost a fee. Liquidation is checked only overnight against the day's average price: equity under 10% of notional wipes the margin. There is also a nightly funding payment; when the price is above its 7-day average, longs pay shorts.¶If a liquidation loses more than the margin, the insurance fund covers the gap; when it runs dry (a SPARK collapse can do that) winning positions are auto-deleveraged and give up half their profit; anything beyond that becomes your debt. Debt grows 2% a day, is repaid first from CRC in the account every night, blocks new positions and cash-outs, and after seven days items in your shop are seized to cover it; whatever is still short is written off and the perp account is banned for 30 days.§Shop: coin only, no CRC, 30% above normal channels, with extra markup on high-tech goods and GPUs; the coin you pay leaves its share of taint with the seller and the goods carry no stolen tag; GPUs may be fake, inspect them yourself.¶Shop purchases: pick a seller on the left, the shelf is on the right, and after 'Buy' the payment panel sets quantity, payment method and coin. Each kind of seller takes different coins: hardware and tech take PSC and CRT; arms, drugs, chemicals, documents, luxury and personal sellers take CRT and the anonymous coin; farming, husbandry, water and brewing take PSC and CRA; platform spot takes PSC, CRT and CRA. If you lack a coin the seller takes you can use the built-in auto-convert: it swaps from another coin in the wallet at an 8% slippage and signs once; oLine truncated
|
||||
guide.web3.text,"Bank and trading: depositing turns credits into CRC in your Poinbase account; withdrawing turns CRC back into credits and goes through compliance screening, which looks at the Poinbase account's taint.¶Trading: PSC stands for Probably Stolen Coin, the coin mined by GPUs and miners. Buys are paid in the quote coin, sells in the traded coin.§Mixer: pick a coin, amount and rounds; each round takes a fee and lowers taint, rounds equal days of waiting, and the coins come back to the same address; the more you deposit, the worse the cleaning.§Hardware wallets: on-chain coins sit in PLEDGER hardware wallets, each with its own balances and taint; open and connect them on the terminal's Wallets page. The Web3 page's trading, shop and mixer use the connected wallet, and coin-paying customers and mining rewards go into it too.¶Payments (shop, mixer, Ponero desk, listing fees) start as an invoice on the terminal; type the payee address on the wallet and hold ✓ to sign. The last two characters of an address are a checksum, so a one-character typo is usually caught; once in a while it happens to be valid and the coins go to an address nobody uses. DEX swaps also need a signature on the wallet.¶Poinbase is a custodial account and can withdraw straight to the connected wallet; depositing from a wallet means sending to Poinbase's deposit address, which takes only CRC and PSC. More hardware wallets are sold by Dr. Jackson; drag one onto the trading terminal to add it, up to {WalletMax}. The shop has cheaper ones. A wallet you no longer want can be destroyed on the Wallets page once its coins are moved out.¶Transfers pay a fee: slow, normal or fast, and gas prices rise and fall over roughly a week; when the network is congested fees rise and slow transactions may be dropped from the mempool. Check the full address before sending.§Staking: CRA staked in the Revolution pool earns a daily rate that compounds into the stake; withdrawing means requesting first and waiting four days, with no interest while waiting and no way to take it early. The pool pays from a subsidy fund; when it runs low the rate is cut and word of big holders pulling out may spread. Treat that as a warning: once it collapses CRA is worthless within three days and four days of unlocking is too slow. The balance token SPARK can be minted and burned against CRA at the going price (with a fee); its price swings hard and crashes with the collapse. Staking, minting and burning are contract calls and need a signature on the wallet.§Miners: RatDigg miners (M1 / M2 / M3) are standalone machines with far more hash than a card and a lower power draw per hash; they need a battery, take modules and use no rig slots. Only the shop's miner dealers sell them, gated by black-market standing (M1 {AsicRepM1}, M2 {AsicRepM2}, M3 {AsicRepM3}), sometimes second-hand. When one burns out, repair it by putting electronic components in its repair slot in order; it comes back {AsicRepairHealthCut} health lower. Somewhere between day {EraMin} and day {EraMax} a ""miner era"" arrives, announced in the paper a few days earlier: the big farms halve their power costs, network hash climbs, GPU miners are diluted and low-end cards barely earn, while miners still do fine.§Perps: the Perps tab on Poinbase uses your account CRC as margin, up to {PerpPscLev}× on PSC and {PerpSparkLev}× on SPARK, one position per product, never long and short at once. Fills are worse than the quote (more so for bigger orders, like the spot pool) and opening and closing both cost a fee. Liquidation is checked only overnight against the day's average price: equity under {PerpMaint:%} of notional wipes the margin. There is also a nightly funding payment; when the price is above its 7-day average, longs pay shorts.¶If a liquidation loses more than the margin, the insurance fund covers the gap; when it runs dry (a SPARK collapse can do that) winning positions are auto-deleveraged and give up half their profit; anything beyond that becomes your debt. Debt grows {PerpDebtInterest:%} a day, is repaid first from CRC in the account every night, blocks new positions and cash-outs, and after {PerpDebtDays} days items in your shop are seized to cover it; whatever is still short is written off and the perp account is banned for {PerpBanDays} days.§Shop: coin only, no CRC, {BmPremium:%} above normal channels, with extra markup on high-tech goods and GPUs; the coin you pay leaves its share of taint with the seller and the goods carry no stolen tag; GPUs may be fake, inspect them yourself.¶Shop purchases: pick a seller on the left, the shelf is on the right, and after 'Buy' the payment panel sets quantity, payment method and coin. Each kind of seller takes different coins: hardware and tech take PSC and CRT; arms, drugs, chemicals, documents, luxury and personal sellers take CRT and the anonymous coin; farming, husbandry, water and brewing take PSC and CRA; platform spot takes PSC, CRT and CRA. ILine truncated
|
||||
courier.odd1,...Package is here.
|
||||
courier.odd2,"(His hand stays in his pocket.) Sign here."
|
||||
courier.sign,Sign
|
||||
|
||||
@@ -266,7 +266,7 @@ black.kind.Tech,高科技物品(加价)
|
||||
nightlog.bm.ready,"黑市:{0} 到货,开店后会有快递员上门。"
|
||||
item.web3guide.name,Web3 手册
|
||||
item.web3guide.desc,终端使用手册,按章节阅读。
|
||||
guide.web3.text,"银行与交易:存入把信用点换成 Poinbase 账户里的 CRC;提取把 CRC 换回信用点,要过合规审查,审查看 Poinbase 账户的污点。¶交易:PSC 全称 Probably Stolen Coin,是显卡和矿机挖出的币。买入按计价币的数量支付,卖出按所交易币的数量卖出。§混币器:选币种、填数量和轮数,每轮扣手续费并降低污点,轮数即等待天数,到期提回同一个地址;存入越多,清洗越差。§硬件钱包:链上的币放在 PLEDGER 硬件钱包里,每个钱包的余额和污点各算各的;在终端的钱包页打开、连接。Web3 页的交易、商店、混币器用已连接的钱包,用币付款的顾客和挖矿收益也进它。¶付款(商店、混币器、Ponero 兑换处、上架费)先在终端开账单,再在钱包里手输收款地址、按住 ✓ 签名;地址末尾两位是校验位,输错一位多半会被拦下,偶尔碰巧合法,币就转进了没人用的地址。DEX 兑换也要在钱包上签名。¶Poinbase 是托管账户,可以直接提到已连接的钱包;从钱包充值要转到 Poinbase 的充值地址,只收 CRC 和 PSC。更多硬件钱包向杰克逊博士购买,拖到交易终端上添加,最多 5 个;商店里也有更便宜的。不要的钱包可以在钱包页销毁,要先把币转走。¶转账要付手续费,分慢、普通、快三档,gas 价格大约一周一个起落;网络拥堵时手续费变贵,慢档可能被挤出内存池。转账前核对完整地址。§质押:把 CRA 质押进革命军质押池每天有日息,利息并入本金;取出要先申请,等四天才到账,等待期间没有利息,也不能提前拿。质押池靠补贴池付息,补贴池见底会降息,有时还会传出大户撤出的消息,那是预兆:一旦崩盘,三天内 CRA 就一文不值,四天的解锁期来不及。平衡代币 SPARK 可以和 CRA 按价格互相铸销(收手续费),价格波动很大,崩盘时会跟着暴跌。质押、铸销都是合约调用,要在钱包上签名。§矿机:RatDigg 矿机(M1 / M2 / M3)是独立的机器,算力比显卡大得多、耗电更省,要放电池才挖,可以放模块,不占矿架槽位;只在商店的矿机商那里有,要黑市声望(M1 40、M2 60、M3 80),偶尔有二手的。暴毙后要往修理槽里放电子元件按顺序修好,修好健康少 20。第 50 到 90 天之间会有一次""矿机时代"",提前几天上报纸预告,之后大矿场的耗电成本砍半,全网算力涨上去,显卡矿工的收益被摊薄,低档显卡几乎不赚钱,矿机还行。§永续合约:Poinbase 的""永续""页,用账户里的 CRC 当保证金,PSC 最高 5 倍、SPARK 最高 3 倍,一个品种只有一个仓位,不能同时多空。成交价比现价差一截(单越大差得越多,和现货池一样),开平仓还收手续费。强平只在夜里按当天均价检查,权益不到名义价值的 10% 就被强平,保证金没了;每晚还有资金费,价格比近 7 天均价高时多头付给空头。¶强平后亏光保证金还不够的缺口,先由保险基金垫,基金见底(SPARK 崩盘这类大行情会抽干它)后盈利的仓位会被自动减仓、少拿一半盈利,再不够就记成你的欠款:欠款每天涨 2%,账户里的 CRC 每晚先拿去还,没还清不能开仓、不能出金,七天不还就没收店里的物品抵债,抵不够的核销并拉黑永续账户 30 天。§商店:只收币,不收 CRC,价格比正常渠道贵 30%,高科技物品和显卡另有加价;付出去的币带着按比例的污点留在卖家那边,货不带赃物标签;显卡不保证真假,自己鉴定。¶商店购买:左边选卖家,右边是货架,点""购买""后在付款面板里定数量、付款方式和币种。每类卖家收的币不同:硬件、技术类收 PSC 和 CRT,军火、药物、化学品、证件、奢侈品、个人卖家收 CRT 和匿名币,农业、养殖、水务、酿酒收 PSC 和 CRA,平台现货收 PSC、CRT、CRA。手里没有它收的币,可以用 Web3 内置的自动换币:从钱包里别的币换出,多付 8% 滑点,签名一次完成;也可以自己先去 DEX 换,滑点小得多,但要多一步。上架费同样在付款时选币。¶商店购物车:点货架上的""购买""是加入购物车,右下角的悬浮购物车显示件数,点开进结算页。结算页左边是购物车详情(按商家分组,可增减数量、删除,接受提前放款的商家可选托管或提前放款),右边是付款:每家商家的收款地址不同,所以逐家付款——选这家收的币,生成账单,在钱包里转账;也可以用钱包里别的币自动换币(多付 8% 滑点)一次签名付清这一家。§托管与订单:订单比现货便宜,要等几天,路上可能被截获;商家按类型卖货Line truncated
|
||||
guide.web3.text,"银行与交易:存入把信用点换成 Poinbase 账户里的 CRC;提取把 CRC 换回信用点,要过合规审查,审查看 Poinbase 账户的污点。¶交易:PSC 全称 Probably Stolen Coin,是显卡和矿机挖出的币。买入按计价币的数量支付,卖出按所交易币的数量卖出。§混币器:选币种、填数量和轮数,每轮扣手续费并降低污点,轮数即等待天数,到期提回同一个地址;存入越多,清洗越差。§硬件钱包:链上的币放在 PLEDGER 硬件钱包里,每个钱包的余额和污点各算各的;在终端的钱包页打开、连接。Web3 页的交易、商店、混币器用已连接的钱包,用币付款的顾客和挖矿收益也进它。¶付款(商店、混币器、Ponero 兑换处、上架费)先在终端开账单,再在钱包里手输收款地址、按住 ✓ 签名;地址末尾两位是校验位,输错一位多半会被拦下,偶尔碰巧合法,币就转进了没人用的地址。DEX 兑换也要在钱包上签名。¶Poinbase 是托管账户,可以直接提到已连接的钱包;从钱包充值要转到 Poinbase 的充值地址,只收 CRC 和 PSC。更多硬件钱包向杰克逊博士购买,拖到交易终端上添加,最多 {WalletMax} 个;商店里也有更便宜的。不要的钱包可以在钱包页销毁,要先把币转走。¶转账要付手续费,分慢、普通、快三档,gas 价格大约一周一个起落;网络拥堵时手续费变贵,慢档可能被挤出内存池。转账前核对完整地址。§质押:把 CRA 质押进革命军质押池每天有日息,利息并入本金;取出要先申请,等四天才到账,等待期间没有利息,也不能提前拿。质押池靠补贴池付息,补贴池见底会降息,有时还会传出大户撤出的消息,那是预兆:一旦崩盘,三天内 CRA 就一文不值,四天的解锁期来不及。平衡代币 SPARK 可以和 CRA 按价格互相铸销(收手续费),价格波动很大,崩盘时会跟着暴跌。质押、铸销都是合约调用,要在钱包上签名。§矿机:RatDigg 矿机(M1 / M2 / M3)是独立的机器,算力比显卡大得多、耗电更省,要放电池才挖,可以放模块,不占矿架槽位;只在商店的矿机商那里有,要黑市声望(M1 {AsicRepM1}、M2 {AsicRepM2}、M3 {AsicRepM3}),偶尔有二手的。暴毙后要往修理槽里放电子元件按顺序修好,修好健康少 {AsicRepairHealthCut}。第 {EraMin} 到 {EraMax} 天之间会有一次""矿机时代"",提前几天上报纸预告,之后大矿场的耗电成本砍半,全网算力涨上去,显卡矿工的收益被摊薄,低档显卡几乎不赚钱,矿机还行。§永续合约:Poinbase 的""永续""页,用账户里的 CRC 当保证金,PSC 最高 {PerpPscLev} 倍、SPARK 最高 {PerpSparkLev} 倍,一个品种只有一个仓位,不能同时多空。成交价比现价差一截(单越大差得越多,和现货池一样),开平仓还收手续费。强平只在夜里按当天均价检查,权益不到名义价值的 {PerpMaint:%} 就被强平,保证金没了;每晚还有资金费,价格比近 7 天均价高时多头付给空头。¶强平后亏光保证金还不够的缺口,先由保险基金垫,基金见底(SPARK 崩盘这类大行情会抽干它)后盈利的仓位会被自动减仓、少拿一半盈利,再不够就记成你的欠款:欠款每天涨 {PerpDebtInterest:%},账户里的 CRC 每晚先拿去还,没还清不能开仓、不能出金,{PerpDebtDays} 天不还就没收店里的物品抵债,抵不够的核销并拉黑永续账户 {PerpBanDays} 天。§商店:只收币,不收 CRC,价格比正常渠道贵 {BmPremium:%},高科技物品和显卡另有加价;付出去的币带着按比例的污点留在卖家那边,货不带赃物标签;显卡不保证真假,自己鉴定。¶商店购买:左边选卖家,右边是货架,点""购买""后在付款面板里定数量、付款方式和币种。每类卖家收的币不同:硬件、技术类收 PSC 和 CRT,军火、药物、化学品、证件、奢侈品、个人卖家收 CRT 和匿名币,农业、养殖、水务、酿酒收 PSC 和 CRA,平台现货收 PSC、CRT、CRA。手里没有它收的币,可以用 Web3 内置的自动换币:从钱包里别的币换出,多付 {BmAutoSwapSlip:%} 滑点,签名一次完成;也可以自己先去 DEX 换,滑点小得多,但要多一步。上架费同样在付款时选币。¶商店购物车:点货架上的""购买""是加入购物车,右下角的悬浮购物车显示件数,点开进结算页。结算页左边是购物车详情(按商家分组,可增减数量、删除,接受提前放款的商家可选托管或提前放款),右边是付款:每家商家的收款地址不同,所以逐家付款——选这家收的币,生成账单,在钱包里转账;也可以用钱包里别的Line truncated
|
||||
courier.odd1,……东西到了。
|
||||
courier.odd2,"(他的手一直放在口袋里)在这儿签个字。"
|
||||
courier.sign,签收
|
||||
|
||||
@@ -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 以上一半");
|
||||
|
||||
Reference in new issue
Block a user