CTT/Server/Hotfix/Game/Common/Bag/OpenMainStoryBossChestGoods...

46 lines
1.6 KiB
C#
Raw Normal View History

2023-09-07 00:06:37 +08:00
using System.Collections.Generic;
using Cal.DataTable;
namespace ET;
public class OpenMainStoryBossChestGoodsEffect: GoodsEffect
{
public override string Init(Unit unit, GoodsBase goodsBase, bool isLock = false)
{
base.unit = unit;
this.GoodsBase = goodsBase;
IsLock = isLock;
Execute().Coroutine();
return string.Empty;
}
public override async ETVoid Execute()
{
int parentSetId = this.GoodsBase.CommonIncrease;
if (parentSetId == 0) return;
PlayerData data = unit.GetComponent<PlayerData>();
if (!data)
{
Log.Error($"玩家Id=【{unit.Parent.Id}】 Name=【{UserComponent.Instance.Get(unit.Parent.Id).NickName}】 playerData is invalid!");
return;
}
using (UnOrderMultiMapComponent<long, (int, int)> rewordMapComponent = UnOrderMultiMapComponent<long, (int, int)>.Create())
{
DropHelper.Drop(unit, data, BattleType.None, parentSetId, rewordMapComponent.MultiMap, dropProperbility: 1, "领主宝箱", isLock: false);
using ListComponent<string> listComponent = ListComponent<string>.Create();
foreach (KeyValuePair<long, List<(int, int)>> kp in rewordMapComponent.MultiMap.GetDictionary())
{
foreach ((int id, int count) in kp.Value)
{
listComponent.List.Add($"[color=#ffff00][/color]获得了[color=#226655]{BagHelper.GetName(id)}x{count}[/color]");
}
}
Chat.Instance.SendSystemCahtNoBrocast(unit, listComponent.List);
}
await ETTask.CompletedTask;
}
}