diff --git a/src/Decentralized.Domain/CoinPayment.cs b/src/Decentralized.Domain/CoinPayment.cs index b49a1f5..a31ee99 100644 --- a/src/Decentralized.Domain/CoinPayment.cs +++ b/src/Decentralized.Domain/CoinPayment.cs @@ -33,11 +33,11 @@ namespace Decentralized.Domain } } - /// 收款:返回收到的币数。heatPct 是物品的赃物热度(0–100)。 + /// 收款:返回收到的币数。heatPct 是物品的赃物热度(0–100)。多付的溢价是顾客给的额外收入,不带污点。 public static double Receive(Wallet w, string asset, double credits, double price, double heatPct) { if (credits <= 0 || price <= 0) return 0; - double qty = credits / price; + double qty = credits * (1 + Tuning.CoinPayPremium) / price; // 溢价只加在币数上,污点与成本仍按货值算 w.Add(asset, qty); w.Taint += credits * Math.Max(0, Math.Min(100, heatPct)) / 100.0; w.Basis += credits; diff --git a/src/Decentralized.Domain/Tuning.cs b/src/Decentralized.Domain/Tuning.cs index 2f26d39..95f684f 100644 --- a/src/Decentralized.Domain/Tuning.cs +++ b/src/Decentralized.Domain/Tuning.cs @@ -65,6 +65,8 @@ namespace Decentralized.Domain public const int MixerMaxRounds = 5, MixerSanctionDays = 5; /// 各派系顾客用币付款的概率。 public const double CoinPayCrc = 0.30, CoinPayCrt = 0.50, CoinPayCra = 0.50, CoinPayPsc = 0.25; + /// 用币付款的溢价:顾客多付的比例,补偿持币的污点与兑出的手续费。 + public const double CoinPayPremium = 0.12; /// 单个金融违规事件记入的罪证上限。 public const double CrimeEventCap = 400; diff --git a/tests/Decentralized.Domain.Tests/Program.cs b/tests/Decentralized.Domain.Tests/Program.cs index 1a985a7..e8c3b05 100644 --- a/tests/Decentralized.Domain.Tests/Program.cs +++ b/tests/Decentralized.Domain.Tests/Program.cs @@ -493,8 +493,8 @@ internal static class Program var w = new Wallet { Address = "t" }; Check(CoinPayment.AssetFor("FACTION_BLACK_MARKET") == Assets.CRT && CoinPayment.AssetFor("FACTION_SECURITY") == null, "派系对应的币"); double q = CoinPayment.Receive(w, Assets.CRT, 200, 0.5, 40); - Check(Near(q, 400, 1e-9) && Near(w.Get(Assets.CRT), 400, 1e-9), "按币价换算数量"); - Check(Near(w.Taint, 80, 1e-9) && Near(w.Basis, 200, 1e-9), "污点 = 货值 × 热度%,成本 = 货值"); + Check(Near(q, 400 * (1 + Tuning.CoinPayPremium), 1e-9) && Near(w.Get(Assets.CRT), q, 1e-9), "按币价换算数量,含溢价"); + Check(Near(w.Taint, 80, 1e-9) && Near(w.Basis, 200, 1e-9), "污点 = 货值 × 热度%,成本 = 货值(溢价不带污点)"); Check(CoinPayment.Receive(w, Assets.CRC, 0, 1, 10) == 0, "零金额不收"); });