using System;
using System.Collections.Generic;
namespace ET.Server
{
///
/// 玩家属性工具类
///
public static class AttributeHelper
{
///
/// 将两个属性集合合并到一个集合里面
///
///
///
public static void AddData2AllData(Dictionary src, Dictionary dest)
{
if (src is not { Count: > 0 })
{
Log.Warning($"AddData2AllData src == null");
return;
}
foreach (var keyValue in src)
{
try
{
int value = (dest.TryGetValue(keyValue.Key, out int v)? dest[keyValue.Key] : 0) + keyValue.Value;
dest[keyValue.Key] = value;
}
catch (Exception e)
{
Log.Error($"AttributeHelper AddData2AllData: key={keyValue.Key}, e={e}");
}
}
}
}
}