feat(fight): 重构战斗效果触发机制与ID管理
- 统一将 Skill_Hit_Pre 和 Skill_Hit_Pre_ex 方法重命名为 Action_start 和 Action_start_ex - 新增 Action_end 和 Action_end_ex 接口方法,完善行动周期控制 - 修改效果ID生成逻辑,使用 EffectIDCombiner 替代简单整数运算,提升扩展性 - 调整状态类效果判断方式,通过前缀匹配识别状态类型 - 增加随机持续时间和参数设置功能,增强部分效果的表现力 - 优化战斗流程中效果执行时机,确保行为前后逻辑完整闭环
This commit is contained in:
@@ -9,35 +9,50 @@ import (
|
||||
"blazing/modules/blazing/model"
|
||||
|
||||
"github.com/brunoga/deep"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/tnnmigga/enum"
|
||||
)
|
||||
|
||||
// 战斗结束原因枚举
|
||||
type EnumEffectType int
|
||||
type EnumEffectType uint16
|
||||
|
||||
var EffectType = enum.New[struct {
|
||||
Skill EnumEffectType `enum:"1000000"` //技能
|
||||
NewSel EnumEffectType `enum:"2000000"` //特性
|
||||
Status EnumEffectType `enum:"3000000"` //状态
|
||||
Sub EnumEffectType `enum:"4000000"` //子效果
|
||||
Skill EnumEffectType `enum:"1"` //技能
|
||||
NewSel EnumEffectType `enum:"2"` //特性
|
||||
Status EnumEffectType `enum:"3"` //状态
|
||||
Sub EnumEffectType `enum:"4"` //子效果
|
||||
|
||||
}]()
|
||||
var NodeM = make(map[int]Effect, 0)
|
||||
|
||||
var NodeM = make(map[int64]Effect, 0)
|
||||
|
||||
func InitEffect(etype EnumEffectType, id int, t Effect) {
|
||||
t.ID(id + int(etype)) //设置ID
|
||||
ids, err := NewEffectCombined(etype, 0, gconv.Uint16(id))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
NodeM[id+int(etype)] = t
|
||||
}
|
||||
t.ID(ids.effectID) //设置ID
|
||||
|
||||
NodeM[ids.effectID] = t
|
||||
}
|
||||
func Geteffect[T int | byte](etype EnumEffectType, id T) Effect {
|
||||
|
||||
// 这里的catchtime为0,取出来之后如果是魂印,要重新赋值
|
||||
func Geteffect[T int | byte](etype EnumEffectType, id T) Effect {
|
||||
ids, err := NewEffectCombined(etype, 0, gconv.Uint16(id))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
}
|
||||
//todo 获取前GetEffect
|
||||
ret, ok := NodeM[int(id)+int(etype)]
|
||||
ret, ok := NodeM[ids.effectID]
|
||||
if ok {
|
||||
//todo 获取前GetEffect
|
||||
|
||||
eff := deep.MustCopy(ret)
|
||||
if eff.ID() >= int(EffectType.Status) && eff.ID() < int(EffectType.Sub) {
|
||||
combiner := EffectIDCombiner{}
|
||||
prefix, _, _ := combiner.Split(eff.ID())
|
||||
if prefix == EffectType.Status {
|
||||
eff.CanStack(true) //状态类不能被覆盖,只能无限叠加
|
||||
|
||||
}
|
||||
@@ -76,8 +91,12 @@ func (our *Input) GetProp(id int, istue bool) int {
|
||||
|
||||
func (our *Input) GetEffect(etype EnumEffectType, id int) Effect {
|
||||
var ret []Effect
|
||||
ids, err := NewEffectCombined(etype, 0, gconv.Uint16(id))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
eid := id + int(etype)
|
||||
}
|
||||
eid := ids.effectID
|
||||
for _, v := range our.Effects {
|
||||
if v.ID() == eid && v.Alive() {
|
||||
ret = append(ret, v)
|
||||
@@ -99,7 +118,9 @@ func (our *Input) StatEffect_Exist(id info.EnumPetStatus) bool {
|
||||
}
|
||||
func (our *Input) StatEffect_Exist_all() bool {
|
||||
for _, v := range our.Effects {
|
||||
if v.ID() >= int(EffectType.Status) && v.ID() < int(EffectType.Sub) && v.Alive() {
|
||||
combiner := EffectIDCombiner{}
|
||||
prefix, _, _ := combiner.Split(v.ID())
|
||||
if prefix == EffectType.Status && v.Alive() {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -107,8 +128,11 @@ func (our *Input) StatEffect_Exist_all() bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 判断是否是状态技能
|
||||
func (our *Input) IS_Stat(v Effect) bool {
|
||||
if v.ID() >= int(EffectType.Status) && v.ID() < int(EffectType.Sub) && v.Alive() {
|
||||
em, _, _ := EffectIDCombiner{}.Split(v.ID())
|
||||
if em == EffectType.Status && v.Alive() {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user