Files
bl/logic/service/fight/battle/effect/effect_stat.go
昔念 c42e392efe refactor(fight): 重构战斗系统
- 移除 Player 结构中的 IsFighting 字段,使用 FightID 替代
- 优化 Move 结构,重新排序字段并添加注释
- 修改 EffectNode 和相关结构,统一使用 Ctx 字段名称
- 重构 Battle 和 BattlePetEntity 结构,简化属性并优化布局
- 更新战斗逻辑,调整效果应用和回合处理机制
2025-09-03 00:37:05 +08:00

52 lines
1.0 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 effect
import (
"blazing/logic/service/fight/battle/node"
"blazing/logic/service/fight/info"
"unsafe"
)
func init() {
//技能使用成功时m%自身XX等级+/-n
info.NodeM.AddEffect(&Effect4{}) //注册4
//技能使用成功时m%对方XX等级+/-n
info.NodeM.AddEffect(&Effect5{}) //注册5
}
type EffectStat struct {
node.EffectNode
etype bool
}
func (this *EffectStat) GetPet() {
ff := this.EffectNode.GetOwnerPet()
offsetC := unsafe.Offsetof(ff.Attack) // c字段的偏移量通常为4+16=20
// 2. 将结构体指针转换为原始内存地址uintptr
baseAddr := uintptr(unsafe.Pointer(&offsetC))
// 3. 计算字段地址并赋值
// 给a字段赋值通过偏移量
addrA := unsafe.Pointer(baseAddr + 4) //根据攻击算其他字段
*(*uint32)(addrA) = 100
}
func (this *EffectStat) TYPE() bool {
return this.etype
}
type Effect4 struct {
EffectStat
}
func (this *Effect4) TYPE() bool {
return true //提升
}
type Effect5 struct {
EffectStat
}
func (this *Effect5) TYPE() bool {
return false //下降
}