mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
传入 User 以便获取已购数量
This commit is contained in:
parent
742936e260
commit
00429c2de0
@ -40,6 +40,11 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return ToString(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToString(User? user = null)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new();
|
StringBuilder builder = new();
|
||||||
builder.AppendLine($"{Id}. {Name}");
|
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($"商品售价:{(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($"包含物品:{string.Join("、", Items.Select(i => $"[{ItemSet.GetQualityTypeName(i.QualityType)}|{ItemSet.GetItemTypeName(i.ItemType)}] {i.Name}"))}");
|
||||||
builder.AppendLine($"剩余库存:{(Stock == -1 ? "不限" : Stock)}");
|
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();
|
return builder.ToString().Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,11 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return ToString(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToString(User? user = null)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new();
|
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)];
|
Goods[] goodsValid = [.. Goods.Values.Where(g => !g.ExpireTime.HasValue || g.ExpireTime.Value > DateTime.Now)];
|
||||||
foreach (Goods goods in goodsValid)
|
foreach (Goods goods in goodsValid)
|
||||||
{
|
{
|
||||||
builder.AppendLine(goods.ToString());
|
builder.AppendLine(goods.ToString(user));
|
||||||
}
|
}
|
||||||
builder.AppendLine("提示:使用【商店查看+序号】查看物品详细信息,使用【商店购买+序号】购买物品(指令在 2 分钟内可用)。");
|
builder.AppendLine("提示:使用【商店查看+序号】查看物品详细信息,使用【商店购买+序号】购买物品(指令在 2 分钟内可用)。");
|
||||||
if (AutoRefresh)
|
if (AutoRefresh)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user