Files
bl/logic/service/fight/input/attr.go
昔念 0a1da7d035 ```
refactor(effectarg): 移动EffectArgs初始化逻辑

将EffectArgs的初始化从effectarg.go中的init函数移动到file.go的initfile函数中,
确保在使用前正确加载配置并初始化映射。

refactor(login): 更新Login方法中的Person调用

修改Login方法中对Person函数的调用,传递UserID参数以获取正确的用户信息。

refactor(user): 统一使用Person方法替代PersonOther

在UserSimInfo和UserMoreInfo方法中,将原先调用的PersonOther方法统一替换为
Person方法,保持代码一致性。

refactor(effect_damage): 简化属性获取和伤害计算逻辑

移除deepcopy相关逻辑,简化Effect0的OnSkill方法中的属性获取和伤害计算流程,
直接通过输入参数进行计算。

refactor(fightc): 优化玩家输入处理和战斗逻辑

更新GetInputByPlayer方法中的玩家判断逻辑,使用UserID比较代替对象比较;
在initplayer中添加InitAttackValue调用;
修复battleLoop中打印语句的格式问题;
调整技能攻击处理流程,增加SkillUseEnd回调调用。

refactor(attr): 改进属性获取方法和伤害计算逻辑

将GetProp方法重命名为Prop,并支持传入对方输入参数;
更新CalculatePower方法签名,使用Input类型代替BattlePetEntity;
在属性获取和伤害计算中正确处理双方属性影响。

refactor(playeraction): 简化技能使用逻辑

简化UseSkill方法中获取当前宠物信息的逻辑,去除冗余的条件判断;
在找到对应技能后添加break语句,提高执行效率。

refactor(reg): 更新Person方法实现

合并Person和PersonOther方法为统一的Person方法;
在数据库查询失败时添加错误处理,避免潜在的空指针异常。
```
2025-09-24 12:40:13 +08:00

128 lines
3.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package input
import (
element "blazing/common/data/Element"
"blazing/logic/service/fight/info"
"github.com/mohae/deepcopy"
"github.com/shopspring/decimal"
)
func (u *Input) Death() {
u.CurrentPet.Info.Hp = 0
//todo 待实现死亡effet
}
// 1是添加-1是减少0是清除
func (u *Input) SetProp(prop, level int) {
if level == 0 { //说明是消强
//todo 消强交互
}
//todo 待交互
u.AttackValue.Prop[prop] = u.AttackValue.Prop[prop] + int8(level)
//todo 待交互
}
func (i *Input) GetAction(opp *Input) {
//使用1#技能,实际上要按照四个技能权重去使用
i.FightC.UseSkill(i.Player, int32(i.FightC.GetCurrPET(i.Player).Skills[0].ID))
}
// todo获取属性待实现获取后改回原属性
func (i *Input) Prop(in *Input, f func()) {
oldour := deepcopy.Copy(i.CurrentPet).(*info.BattlePetEntity)
//oldouo := deepcopy.Copy(opp.CurrentPet).(*info.BattlePetEntity)
i.Exec(func(t Effect) bool { //属性获取前
t.BeferAttr(i.CurrentPet) //使XX为XX
return true
})
oldourr := deepcopy.Copy(in.CurrentPet).(*info.BattlePetEntity)
in.Exec(func(t Effect) bool { //属性获取后
t.AfterAttr(i.CurrentPet) //视为xx 需要在里面判断来源
return true
})
f()
in.CurrentPet = oldourr
i.CurrentPet = oldour //恢复
//opp.CurrentPet = oldouo //恢复
}
// 计算技能威力
func (i *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) decimal.Decimal {
//威力+区
//威力*区
//todo 待修复input输入
// 1. 计算等级因子 (level * 0.4 + 2)
levelFactor := decimal.NewFromInt(int64(i.CurrentPet.Info.Level)).
Mul(decimal.NewFromFloat(0.4)).Add(decimal.NewFromInt(2))
var (
attackDec decimal.Decimal //攻击值
defenseDec decimal.Decimal //防御值
)
switch skill.Category() { //判断技能类型
case info.Category.PHYSICAL:
i.Prop(i, func() { //我方取我方攻击
attackDec = decimal.NewFromInt(int64(i.CurrentPet.Info.Prop[0]))
})
deftype.Prop(i, func() { //我方取敌方防御
defenseDec = decimal.NewFromInt(int64(deftype.CurrentPet.Info.Prop[1]))
})
case info.Category.SPECIAL:
i.Prop(i, func() { //我方取我方攻击
attackDec = decimal.NewFromInt(int64(i.CurrentPet.Info.Prop[2]))
})
deftype.Prop(i, func() { //我方取敌方防御
defenseDec = decimal.NewFromInt(int64(deftype.CurrentPet.Info.Prop[3]))
})
default:
return decimal.NewFromInt(0)
}
// 5. 基础伤害公式:等级因子 * 威力因子 * 攻击 / 防御 / 50 + 2
baseDamage := levelFactor.
Mul(decimal.NewFromInt(int64(skill.Power))).
Mul(attackDec).
Div(defenseDec).
Div(decimal.NewFromInt(50)).
Add(decimal.NewFromInt(2))
var typeRate decimal.Decimal
deftype.Prop(i, func() { //我方取敌方属性,得到敌方的实际和我方的视为
t, _ := element.NewElementCalculator().GetOffensiveMultiplier(skill.Type().ID, deftype.CurrentPet.Type().ID)
typeRate = decimal.NewFromFloat(t)
})
damage := baseDamage.
Mul(skill.CriticalsameTypeBonus()). // 同属性加成
Mul(typeRate). // 克制系数
Mul(skill.Criticalrandom()) //随机波动
return damage
}