You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
11 KiB

1 month ago
using ProtoCSStruct;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TencentCloud.Ame.V20190916.Models;
namespace Sog
{
public class RoleProp
{
public static string PROP_LUCK = "Luck";
private Dictionary<PropertyDef, long> finalProps; //atk 75
private Dictionary<PropertyDef, long> baseProps;//atk 50 atkPct 50%
// private static string PCT = "Pct";
public RoleProp() {
finalProps = new Dictionary<PropertyDef, long>();
baseProps = new Dictionary<PropertyDef, long>();
//if(PropIdForView == null)
//{
// PropIdForView = new List<string>();
// PropIdForView.Add("Atk");
// PropIdForView.Add("Def");
// PropIdForView.Add("TotalHp");
// PropIdForView.Add("MoveSpeed");
//}
}
public RoleProp(RoleProp copy)
{
finalProps = new Dictionary<PropertyDef, long>(copy.finalProps);
baseProps = new Dictionary<PropertyDef, long>(copy.baseProps);
}
public void Clear()
{
finalProps.Clear();
baseProps.Clear();
}
public bool isEmpty()
{
return finalProps.Count == 0 && baseProps.Count == 0;
}
/// <summary>
/// 增加属性
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void AddProp(string key, long value, bool checkValid = false)
{
var conf = CSPropIDTypeDescMgr.Instance.GetConfig(key);
if (checkValid)
{
//if (c.EndsWith(PCT))
//{
// c = c.Replace(PCT, "");
//}
if (conf == null)
{
TraceLog.Error("RoleProp add invalid propid {0} value {1}", key, value);
return;
}
}
if (conf == null)
{
return;
}
if (baseProps.TryGetValue(conf.id, out long v))
{
baseProps[conf.id] = v + value; ;
}
else
{
baseProps[conf.id] = value; ;
}
}
public void AddProp(PropertyDef key, long value)
{
if (baseProps.TryGetValue(key, out long v))
{
baseProps[key] = v + value; ;
}
else
{
baseProps[key] = value; ;
}
}
public void AddProp(int key, long value )
{
AddProp((PropertyDef)key, (long)value);
}
public long GetPropFinal(string key)
{
var conf = CSPropIDTypeDescMgr.Instance.GetConfig(key);
if (finalProps.TryGetValue(conf.id, out long v)) { return v; }
return 0;
}
public long GetPropFinal(PropertyDef key)
{
if (finalProps.TryGetValue(key, out long v)) { return v; }
return 0;
}
/// <summary>
/// 计算最终属性
/// </summary>
/// <returns></returns>
public void CalcFinal(bool calcPct = false)
{
finalProps.Clear();
foreach (var item in baseProps)
{
//if (!item.Key.EndsWith(PCT))
{
finalProps[item.Key] = item.Value;
}
}
if (calcPct)
{
{
if (finalProps.TryGetValue(PropertyDef.AtkPercentIncrease, out long v))
{
var ov = finalProps[PropertyDef.AtkFixedIncrease];
ov = (long)(ov * (1 + v * 1.0F / 10_000F));
finalProps[PropertyDef.AtkFixedIncrease] = ov;
}
else
{
//finalProps[PropertyDef.AtkFixedIncrease] = finalProps[PropertyDef.AtkFixedIncrease];
}
}
{
if (finalProps.TryGetValue(PropertyDef.DefPercentIncrease, out long v))
{
var ov = finalProps[PropertyDef.DefFixedIncrease];
ov = (long)(ov * (1 + v * 1.0F / 10_000F));
finalProps[PropertyDef.DefFixedIncrease] = ov;
}
else
{
//finalProps[PropertyDef.DefFixedIncrease] = finalProps[PropertyDef.DefFixedIncrease];
}
}
{
if (finalProps.TryGetValue(PropertyDef.HpPercentIncrease, out long v))
{
var ov = finalProps[PropertyDef.HpFixedIncrease];
ov = (long)(ov * (1 + v * 1.0F / 10_000F));
finalProps[PropertyDef.HpFixedIncrease] = ov;
}
else
{
//finalProps[PropertyDef.HpFixedIncrease] = finalProps[PropertyDef.HpFixedIncrease];
}
}
{
if (finalProps.TryGetValue(PropertyDef.SpeedPercentIncrease, out long v))
{
var ov = finalProps[PropertyDef.SpeedFixedIncrease];
ov = (long)(ov * (1 + v * 1.0F / 10_000F));
finalProps[PropertyDef.SpeedFixedIncrease] = ov;
}
else
{
//finalProps[PropertyDef.SpeedFixedIncrease] = finalProps[PropertyDef.SpeedFixedIncrease];
}
}
}
}
public void ToClienNotify(ref CSHeroPropChgNotify notify)
{
foreach (var item in finalProps)
{
//var conf = CSPropIDTypeDescMgr.Instance.GetConfig(item.Key);
ID32Value64 id = new ID32Value64();
id.Id = (int)item.Key;
id.Value = item.Value;
notify.ChgProp.Add(ref id);
}
}
public void ToPropView(ref HeroPropView view)
{
view.Clear();
foreach (var item in finalProps)
{
//var conf = CSPropIDTypeDescMgr.Instance.GetConfig(item.Key);
ID32Value64 id = new ID32Value64();
id.Id = (int)item.Key;
id.Value = item.Value;
view.Knight.PropVal.Add(ref id);
}
}
public void SetDefaultValue()
{
foreach (var item in CSPropIDTypeDescMgr.Instance.ItemTable.Values)
{
if (!finalProps.ContainsKey(item.id))
{
finalProps[item.id] = 0;
}
}
}
const double P1W = 10_000D;
public long CalcPower(long weaponAtk, int b1, int b2, int b3, int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, int k9,
int k10, int k11, int b4, int b5)
{
//总战斗力=(攻击部分+防御*4+生命*0.5)*(伤害率+免伤率+(射速加成+弹容量加成+换弹速度加成)*0.3+(物理伤害+火焰伤害+闪电伤害+酸性伤害)*0.1+3)
//*(1+(单个枪械伤害+单个枪械射速+单个枪械弹容量+单个枪械换弹速度加成)*0.05)
//*(8+暴击+暴击伤害*0.4+爆头+爆头伤害*0.4+击晕+击晕加伤*0.4)
//总战斗力=((ATK*(1/Interval)*K1)+DEF*K2+HP*K3)*(DmgRate+NoDmgRate+(AtkSpd+ExtraAmmo+ReloadSpd)*K4+(PhyDmg+FireDmg+PoisonDmg+EleDmg)*K5+B1)
//*(B2+(ARAtkSpd+LMGAtkSpd+SGAtkSpd+SRAtkSpd+RPGAtkSpd+SMGExtraAmmo+ARExtraAmmo+LMGExtraAmmo+SGExtraAmmo+SRExtraAmmo+RPGExtraAmmo+SMGReloadSpd
// +ARReloadSpd+LMGReloadSpd+SGReloadSpd+SRReloadSpd+RPGReloadSpd+SMGDmg+ARDmg+LMGDmg+SGDmg+RPGDmg+SRDmg)*K6)
//*(B3+(CritRate+CritDmgInc*K7+HS_Rate+HS_DmgInc*K8+StunRate+StunDmgInc*K9))
double p3 =b3/P1W + (finalProps[PropertyDef.CriticalRate] / P1W + finalProps[PropertyDef.CriticalDamageIncrease]/P1W * k7/P1W + finalProps[PropertyDef.HS_Rate]/P1W +
finalProps[PropertyDef.HS_DamageIncrease]/P1W * k8/P1W + finalProps[PropertyDef.StunRate]/P1W + finalProps[PropertyDef.StunDamageIncrease]/P1W * k9/P1W);
double p2 = b2/P1W + (finalProps[PropertyDef.ARAttackSpeed] / P1W + finalProps[PropertyDef.LMGAttackSpeed] /P1W + finalProps[PropertyDef.SGAttackSpeed] / P1W +
finalProps[PropertyDef.SRAttackSpeed] / P1W + finalProps[PropertyDef.RPGAttackSpeed] / P1W + finalProps[PropertyDef.SMGExtraAmmo] / P1W +
finalProps[PropertyDef.ARExtraAmmo] / P1W + finalProps[PropertyDef.LMGExtraAmmo] / P1W + finalProps[PropertyDef.SGExtraAmmo] / P1W +
finalProps[PropertyDef.SRExtraAmmo] / P1W + finalProps[PropertyDef.RPGExtraAmmo] / P1W + finalProps[PropertyDef.SMGReloadSpeed] / P1W +
finalProps[PropertyDef.ARReloadSpeed] / P1W + finalProps[PropertyDef.LMGReloadSpeed] / P1W + finalProps[PropertyDef.SGReloadSpeed] / P1W +
finalProps[PropertyDef.SRReloadSpeed] / P1W + finalProps[PropertyDef.RPGReloadSpeed] / P1W + finalProps[PropertyDef.SMGDamage] / P1W +
finalProps[PropertyDef.ARDamage] / P1W + finalProps[PropertyDef.LMGDamage] / P1W + finalProps[PropertyDef.SMGDamage] / P1W + finalProps[PropertyDef.RPGDamage] / P1W + finalProps[PropertyDef.SRDamage] / P1W
) * k6/P1W;
var atk = finalProps[PropertyDef.AtkFixedIncrease];//250
var def = finalProps[PropertyDef.DefFixedIncrease];
var hp = finalProps[PropertyDef.HpFixedIncrease];
double p1 = (weaponAtk / P1W * k1/P1W + +(atk - weaponAtk)/P1W+ def/P1W * k2/P1W + hp/P1W * k3/P1W) *
(finalProps[PropertyDef.DamageRate] / P1W + finalProps[PropertyDef.DamageResistance] / P1W
+ (finalProps[PropertyDef.AttackSpeed] / P1W +finalProps[PropertyDef.ExtraAmmo] / P1W + finalProps[PropertyDef.ReloadSpeed] / P1W) * k4/P1W
+ (finalProps[PropertyDef.PhyDamage] / P1W +finalProps[PropertyDef.FireDamage] / P1W + finalProps[PropertyDef.PoisonDamage] / P1W + finalProps[PropertyDef.ElectricDamage] / P1W) * k5/P1W
+ b1/P1W
);
//((JumpDam+GrenadeDam+UavDam+FistDam+SawDam+AirHitDam+AllHitDam+TsarDam+PaoJieDam)*K10+B4)*(B5+Suppress*K11)
double p4 = ((finalProps[PropertyDef.JumpDam]/P1W + finalProps[PropertyDef.GrenadeDam]/P1W + finalProps[PropertyDef.UavDam]/P1W + finalProps[PropertyDef.FistDam]/P1W
+ finalProps[PropertyDef.SawDam]/P1W + finalProps[PropertyDef.AirHitDam]/P1W + finalProps[PropertyDef.AirHitDam]/P1W
+ finalProps[PropertyDef.AllHitDam] /P1W + finalProps[PropertyDef.TsarDam]/P1W + finalProps[PropertyDef.PaoJieDam] /P1W) * k10/P1W + b4 / P1W)
* (b5/P1W + finalProps[PropertyDef.Suppress]/P1W * k11/P1W);
return (long)(p1 * p2 * p3 * p4);
}
}
}