```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

fix(fight/boss): 修复技能实体空指针问题并优化必定秒杀效果实现

- 修复NewSeIdx_148中sks映射为空时的panic问题,在访问前进行nil检查并初始化
- 重构NewSeIdx_223必定秒杀效果的实现,将原有的ComparePre和DamageFloor方法
  合并为OnSkill方法,简化逻辑并提高代码可读性
- 更新注释描述,使功能说明更加准确清晰
```
This commit is contained in:
昔念
2026-03-06 21:55:54 +08:00
parent 2461ed1aa4
commit 87ad01bea9
3 changed files with 34 additions and 41 deletions

View File

@@ -26,6 +26,9 @@ func (e *NewSel148) DamageDivEx(t *info.DamageZone) bool {
if t.Type != info.DamageType.Red {
return true
}
if e.sks == nil {
e.sks = make(map[int]info.SkillEntity)
}
old, ok := e.sks[e.Ctx().SkillEntity.ID]
if !ok {
e.sks[e.Ctx().SkillEntity.ID] = *e.Ctx().SkillEntity

View File

@@ -1,62 +1,25 @@
package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"math"
"github.com/alpacahq/alpacadecimal"
)
// 223. , 每次(针对多宠)攻击必定秒杀对方, 且必定先手;
// 223. 必定秒杀
type NewSel223 struct {
NewSel0
}
func (e *NewSel223) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
func (e *NewSel223) OnSkill() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true
}
if fattack == nil {
return true
}
//先手是自己
if fattack.PlayerID == e.Ctx().Our.UserID {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}
//full32 := int(e.Args()[0])<<16 | int(e.Args()[1])
if int(e.Ctx().Opp.CurrentPet.Type) == int(e.Args()[0].IntPart()) {
sattack.SkillEntity.Priority = math.MaxInt
}
return true
}
func (e *NewSel223) DamageFloor(t *info.DamageZone) bool {
if t.Type != info.DamageType.Red {
return true
}
if int(e.Ctx().Opp.CurrentPet.Type) == int(e.Args()[0].IntPart()) {
// e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
// Type: info.DamageType.Red,
// Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Opp.GetPetInfo().Info.MaxHp)),
// })
t.Damage = alpacadecimal.NewFromInt(int64(e.Ctx().Opp.GetPetInfo().Info.MaxHp))
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Opp.GetPetInfo().Info.MaxHp))})
}
return true

View File

@@ -0,0 +1,27 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"github.com/alpacahq/alpacadecimal"
)
// 323. 每损失N*100血就出手增加M点固伤
type NewSel323 struct {
NewSel0
}
func (e *NewSel323) OnSkill() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true
}
r := e.Ctx().Our.CurrentPet.GetMaxHP().Sub(e.Ctx().Our.CurrentPet.GetHP().Div(e.Ctx().Our.CurrentPet.GetMaxHP())).Div(alpacadecimal.NewFromInt(100))
dug := r.Mul(e.Args()[1])
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed,
Damage: dug})
return true
}
func init() {
input.InitEffect(input.EffectType.NewSel, 323, &NewSel323{})
}