refactor(fight): 重构战斗系统属性计算逻辑

- 移除 BattlePetEntity 中的冗余方法
- 优化属性计算逻辑,使用统一的 CalculateRealValue 方法
- 调整 SkillEntity 中的攻击命中计算
- 重构 AttackValue 结构,使用数组替代字典
- 优化 Input 结构,添加 GetProp 和 GetStatusEffect 方法
- 更新 PetInfo 结构,使用数组存储属性值
This commit is contained in:
2025-09-17 00:38:15 +08:00
parent a33f108f98
commit 29ac99c860
6 changed files with 130 additions and 113 deletions

View File

@@ -20,6 +20,7 @@ type Effect interface {
// OnDamage() bool // 造成伤害时触发
//使用技能 可以取消用技能节点
SetInput(input *Input)
SetArgs(param []int)
IsCrit(opp *Input, skill *info.SkillEntity) //是否暴击
CalculateDamage(opp *Input, skill *info.SkillEntity) //击判定成功且伤害计算前触发
@@ -85,10 +86,36 @@ func InitPropEffect(id int, t Effect) {
NodeM[id+2000000] = t
}
// * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5)
func (c *Input) GetProp(id int) uint32 {
//todo 插入获取前
t, ok := NodeM[id+2000000]
if ok {
if id < 5 {
return info.CalculateRealValue(c.CurrentPet.Info.Prop[id], t.GetMaxStack())
}
}
//todo 插入获取后函数
return 0
}
func InitStatusEffect(id int, t Effect) {
NodeM[id+3000000] = t
}
func (c *Input) GetStatusEffect(id int) (Effect, bool) {
//todo 获取前GetEffect
ret, ok := NodeM[id+3000000]
return ret, ok
//todo 获取后GetEffect
}
func getTypeName(v interface{}) string {
// 获取类型信息
t := reflect.TypeOf(v)
@@ -113,7 +140,7 @@ func (c *Input) AddEffect(e Effect) {
for _, eff := range c.Effects {
if eff.ID() == e.ID() {
//设置输入源
if eff.Stack(0) < eff.MaxStack() { //如果小于最大叠层
if eff.Stack(0) < eff.GetMaxStack() { //如果小于最大叠层
eff.Stack(eff.Stack(0)) //获取到当前叠层数然后叠加
} else {