refactor(fight/info): 简化技能威力计算逻辑,移除无用变量并优化伤害公式
This commit is contained in:
@@ -246,43 +246,29 @@ func (s *SkillEntity) CalculatePower(deftype *BattlePetEntity) decimal.Decimal {
|
||||
levelFactor := decimal.NewFromInt(int64(s.Pet.Info.Level)).
|
||||
Mul(decimal.NewFromFloat(0.4)).Add(decimal.NewFromInt(2))
|
||||
|
||||
// 2. 计算威力因子 (基础威力 + 加算) * 乘算
|
||||
|
||||
//powerAdd := decimal.NewFromFloat(s.GetAddValue(EnumCategory., true)) //威力加算区
|
||||
|
||||
|
||||
var (
|
||||
powerAdd_p decimal.Decimal //威力加算
|
||||
powerMul_p decimal.Decimal //威力乘算
|
||||
attackDec decimal.Decimal //攻击值
|
||||
defenseDec decimal.Decimal //防御值
|
||||
//damageReduction decimal.Decimal //伤害百分比减免
|
||||
|
||||
)
|
||||
switch s.Category() { //判断技能类型
|
||||
case Category.PHYSICAL:
|
||||
|
||||
|
||||
attackDec = decimal.NewFromInt(int64(s.Pet.Info.Prop[0]))
|
||||
defenseDec = decimal.NewFromInt(int64(s.Pet.Info.Prop[1]))
|
||||
//damageReduction = decimal.NewFromFloat(s.DamageZone[DamageMultiplierZoneEnum.ATK_RESISTANCE])
|
||||
|
||||
case Category.SPECIAL:
|
||||
|
||||
|
||||
attackDec = decimal.NewFromInt(int64(s.Pet.Info.Prop[2]))
|
||||
defenseDec = decimal.NewFromInt(int64(s.Pet.Info.Prop[3]))
|
||||
//damageReduction = decimal.NewFromFloat(s.DamageZone[DamageMultiplierZoneEnum.SP_ATK_RESISTANCE])
|
||||
|
||||
default:
|
||||
return decimal.NewFromInt(0)
|
||||
}
|
||||
|
||||
if powerMul_p.IntPart() == 0 {
|
||||
powerMul_p = decimal.NewFromInt(1)
|
||||
}
|
||||
powerZone := decimal.NewFromInt(int64(s.Power)).Add(powerAdd_p).Mul(powerMul_p)
|
||||
// 5. 基础伤害公式:等级因子 * 威力因子 * 攻击 / 防御 / 50 + 2
|
||||
baseDamage := levelFactor.
|
||||
Mul(powerZone).
|
||||
Mul(decimal.NewFromInt(int64(s.Power))).
|
||||
Mul(attackDec).
|
||||
Div(defenseDec).
|
||||
Div(decimal.NewFromInt(50)).
|
||||
|
||||
Reference in New Issue
Block a user