From b24dd8b9f2c7990d89eaa70c448ad7e7267f7d62 Mon Sep 17 00:00:00 2001 From: ZHU MINCHAO <48154958+MinchaoZhu@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:20:58 +0800 Subject: [PATCH] Coin customers: buyer says the coin amount on deal; test entry spawns buyer through the bell queue Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- src/Decentralized/CoinCustomers.cs | 23 +++++++++++++++---- .../ModFiles/Localization/en.csv | 1 + .../ModFiles/Localization/zh.csv | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcfb603..39307c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### 第二阶段(进行中) -- 用币付款的顾客:排队的买家里,上层付 CRC(12%)、黑市付 CRT(25%)、革命派付 CRA(25%)、下层付 PSC(10%)。成交时扣回信用点,按当日币价换成币进热钱包;赃物款项不记销赃,改成币带污点(货值 × 赃物热度%);夜间日志汇总当天用币结算的额度。开发者模式 F9 有测试入口。游戏内成交流程尚未实测(测试存档里顾客不上柜台),机制本身在技术验证里通过。 +- 用币付款的顾客:排队的买家里,上层付 CRC(12%)、黑市付 CRT(25%)、革命派付 CRA(25%)、下层付 PSC(10%)。成交时扣回信用点(现金不变),按当日币价换成币进热钱包,顾客当场说一句"成交,N CRT 已转入热钱包";赃物款项不记销赃,改成币带污点(货值 × 赃物热度%);夜间日志汇总当天用币结算的额度。开发者模式 F9 有测试入口(Coin buyer)。已在游戏里实测:成交后现金不变,四笔种子按币价记入 CRT,顾客对话显示。 ### 第一阶段完成(入门、挖矿、显卡鉴定、终端) diff --git a/src/Decentralized/CoinCustomers.cs b/src/Decentralized/CoinCustomers.cs index 228c4d0..bc8a7ba 100644 --- a/src/Decentralized/CoinCustomers.cs +++ b/src/Decentralized/CoinCustomers.cs @@ -24,12 +24,15 @@ namespace Decentralized canClientExposeFeature = ClientCanExposeFunc.BasicClientExposeCapacity, }; c.SetBudget(5000); - c.clientBuyingTagList.Add("WATER"); c.clientBuyingTagList.Add("BREVAGE"); + c.clientBuyingTagList.Add("SEED"); c.mainDialogue.SetText(c.displayName, "CRT.").SetEndAction(() => { }); c.AddBasicDialog(); c.CompleteClientCreation(); Mark(c, Assets.CRT); - PlayerStore.Instance.currentClientInstance = StoreClientInstance.CreateClientInstance(c); // 测试:直接换成这位顾客 + Log.Info($"用币付款顾客(测试)已设置,当前顾客 {PlayerStore.Instance.currentClientInstance?.GetClientBlueprint()?.identifier},队列 {PlayerStore.Instance.storeClientManager.clientStack.Count} 人"); + PlayerStore.Instance.currentClientInstance = null; // 测试:丢掉在场的顾客(开局的高利贷者不可遣散) + PlayerStore.Instance.storeClientManager.clientStack.Insert(0, c); + PlayerStore.Instance.TryCallNextClient(); })); } public static void Unsubscribe() => ModHook.OnGenerateCustomerLate -= OnGenerate; @@ -55,24 +58,34 @@ namespace Decentralized private static void Mark(StoreClient c, string asset) { var before = c.onItemBought; + double total = 0; // 这位顾客这一单一共付了多少币 c.isNoContributeToEvidence = true; c.onItemBought = (item, cost) => { before?.Invoke(item, cost); - Log.Guard("用币付款成交", () => Pay(asset, item, cost)); + Log.Guard("用币付款成交", () => { total += Pay(c, asset, item, cost); Say(c, asset, total); }); }; } - private static void Pay(string asset, GameItem item, int cost) + /// 成交后顾客说的话:告诉玩家这单是币到账,不是信用点。 + private static void Say(StoreClient client, string asset, double total) + { + client.acceptDealDialogue = new Dialogue().SetText(client.displayName, L.T("coinpay.line", Fmt.Num(total), asset)); + client.acceptDealDialogue.priority = 4; + client.acceptDealDialoguePlayed = false; + } + + private static double Pay(StoreClient client, string asset, GameItem item, int cost) { var d = Session.Data; double price = Session.Price(asset); - if (cost <= 0 || price <= 0) return; + if (cost <= 0 || price <= 0) return 0; int heat = item.IsTag("STOLEN_VALUE_INT") ? item.GetTagReadonly("STOLEN_VALUE_INT").GetInt() : 0; ModHelper.AddCredit(-cost, false); double qty = CoinPayment.Receive(d.Hot, asset, cost, price, heat); d.CoinSalesToday += cost; Log.Info($"用币付款:{item.name} {cost} 信用点 → {qty:0.####} {asset},污点 +{cost * heat / 100.0:0}"); + return qty; } } } diff --git a/src/Decentralized/ModFiles/Localization/en.csv b/src/Decentralized/ModFiles/Localization/en.csv index a264b66..1478c65 100644 --- a/src/Decentralized/ModFiles/Localization/en.csv +++ b/src/Decentralized/ModFiles/Localization/en.csv @@ -50,6 +50,7 @@ report.burnt,Cards burnt out: {0} report.price,PSC price: {0} credits nightlog.mined,Mining rigs produced {0} PSC. nightlog.burnt,A {0} burnt out. +coinpay.line,Deal. {0} {1} sent to your hot wallet. nightlog.coinpay,Customers paying in coin settled {0} credits; the coins went to the hot wallet. nightlog.unpowered,{0} mining rig(s) had no power. news.open.title,Poinbase Lists PSC diff --git a/src/Decentralized/ModFiles/Localization/zh.csv b/src/Decentralized/ModFiles/Localization/zh.csv index 3c44446..0b4addc 100644 --- a/src/Decentralized/ModFiles/Localization/zh.csv +++ b/src/Decentralized/ModFiles/Localization/zh.csv @@ -49,6 +49,7 @@ report.burnt,烧毁的显卡:{0} report.price,PSC 价格:{0} 信用点 nightlog.mined,矿架挖出 {0} PSC。 nightlog.burnt,一张 {0} 烧毁了。 +coinpay.line,成交,{0} {1} 已转入热钱包。 nightlog.coinpay,用币付款的顾客共结算 {0} 信用点,已换成币进了热钱包。 nightlog.unpowered,{0} 个矿架没有电。 news.open.title,Poinbase 上架 PSC