From 00429c2de06658cdc67927b4386625ce411244d3 Mon Sep 17 00:00:00 2001 From: milimoe Date: Thu, 24 Jul 2025 01:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=A0=E5=85=A5=20User=20=E4=BB=A5=E4=BE=BF?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B7=B2=E8=B4=AD=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Trade/Goods.cs | 15 ++++++++++++++- Entity/Trade/Store.cs | 7 ++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Entity/Trade/Goods.cs b/Entity/Trade/Goods.cs index 355bac7..17d9f41 100644 --- a/Entity/Trade/Goods.cs +++ b/Entity/Trade/Goods.cs @@ -40,6 +40,11 @@ namespace Milimoe.FunGame.Core.Entity } public override string ToString() + { + return ToString(null); + } + + public string ToString(User? user = null) { StringBuilder builder = new(); builder.AppendLine($"{Id}. {Name}"); @@ -48,7 +53,15 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"商品售价:{(Prices.Count > 0 ? string.Join("、", Prices.Select(kv => $"{kv.Value} {kv.Key}")) : "免费")}"); builder.AppendLine($"包含物品:{string.Join("、", Items.Select(i => $"[{ItemSet.GetQualityTypeName(i.QualityType)}|{ItemSet.GetItemTypeName(i.ItemType)}] {i.Name}"))}"); builder.AppendLine($"剩余库存:{(Stock == -1 ? "不限" : Stock)}"); - if (Quota > 0) builder.AppendLine($"限购数量:{Quota}"); + if (Quota > 0) + { + int buyCount = 0; + if (user != null) + { + UsersBuyCount.TryGetValue(user.Id, out buyCount); + } + builder.AppendLine($"限购数量:{Quota}(已购:{buyCount})"); + } return builder.ToString().Trim(); } diff --git a/Entity/Trade/Store.cs b/Entity/Trade/Store.cs index c941432..37db163 100644 --- a/Entity/Trade/Store.cs +++ b/Entity/Trade/Store.cs @@ -31,6 +31,11 @@ namespace Milimoe.FunGame.Core.Entity } public override string ToString() + { + return ToString(null); + } + + public string ToString(User? user = null) { StringBuilder builder = new(); @@ -66,7 +71,7 @@ namespace Milimoe.FunGame.Core.Entity Goods[] goodsValid = [.. Goods.Values.Where(g => !g.ExpireTime.HasValue || g.ExpireTime.Value > DateTime.Now)]; foreach (Goods goods in goodsValid) { - builder.AppendLine(goods.ToString()); + builder.AppendLine(goods.ToString(user)); } builder.AppendLine("提示:使用【商店查看+序号】查看物品详细信息,使用【商店购买+序号】购买物品(指令在 2 分钟内可用)。"); if (AutoRefresh)