fix: 修复登录空指针及战斗效果
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-03-21 00:24:34 +08:00
committed by cnb
parent 2dbbc9713c
commit c049bbd5ac
17 changed files with 95 additions and 206 deletions

View File

@@ -41,7 +41,14 @@ func (h Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.L
}
}
currentPlayer := c.Context().(*player.ClientData).GetPlayer(data.Head.UserID)
data1, ok := c.Context().(*player.ClientData)
if !ok {
cool.Logger.Error(context.Background(), "已空指针", data.Head.UserID)
defer c.Close()
return
}
currentPlayer := data1.GetPlayer(data.Head.UserID)
if currentPlayer == nil {
cool.Logger.Error(context.Background(), "获取玩家失败", data.Head.UserID)

View File

@@ -18,7 +18,7 @@ func (w *MyWriter) Write(p []byte) (n int, err error) {
//ctx = context.Background()
)
service.NewBaseSysLogService().RecordFight(w.user, s)
service.NewBaseSysLogService().RecordLog(w.user, s)
return w.logger.Write(p)
}
func init() {

View File

@@ -28,9 +28,7 @@ func (e *NewSel19) ComparePre(fattack *action.SelectSkillAction, sattack *action
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}

View File

@@ -26,9 +26,7 @@ func (e *NewSel405) ComparePre(fattack *action.SelectSkillAction, sattack *actio
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}

View File

@@ -27,9 +27,7 @@ func (e *NewSel42) ComparePre(fattack *action.SelectSkillAction, sattack *action
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}

View File

@@ -36,7 +36,7 @@ func (e *NewSel92) TurnStart(fattack *action.SelectSkillAction, sattack *action.
return
}
e.n1 = e.Ctx().Our.CurrentPet.GetHP()
return
}
func (e *NewSel92) TurnEnd() {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
@@ -44,7 +44,7 @@ func (e *NewSel92) TurnEnd() {
return
}
e.n2 = e.Ctx().Our.CurrentPet.GetHP()
return
}
func (e *NewSel92) DamageFloor(t *info.DamageZone) bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {

View File

@@ -25,9 +25,7 @@ func (e *Effect142) ComparePre(fattack *action.SelectSkillAction, sattack *actio
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}

View File

@@ -27,9 +27,7 @@ func (e *Effect171) ComparePre(fattack *action.SelectSkillAction, sattack *actio
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}

View File

@@ -23,9 +23,7 @@ func (e *Effect454) ComparePre(fattack *action.SelectSkillAction, sattack *actio
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}

View File

@@ -1,76 +0,0 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// {
// "id": 563,
// "argsNum": 1,
// "info": "命中后{0}回合内若对手受到特攻伤害则100%烧伤"
// },
type Effect563 struct {
node.EffectNode
}
func (e *Effect563) OnSkill() bool {
rounds := int(e.Args()[0].IntPart())
// 创建一个临时效果,当对手受到特攻伤害时烧伤
effect := &SpecialAttackBurnEffect{
roundsLeft: rounds,
source: e.Ctx().Our,
target: e.Ctx().Opp,
}
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
return true
}
// SpecialAttackBurnEffect 是一个临时效果,当对手受到特攻伤害时烧伤
type SpecialAttackBurnEffect struct {
node.EffectNode
roundsLeft int
source *input.Input
target *input.Input
}
// OnDamageTaken 在对手受到伤害时触发
func (s *SpecialAttackBurnEffect) OnDamageTaken(damageType info.EnumDamageType) bool {
// 如果是特攻伤害(假设是某种类型的伤害),则造成烧伤
// 这里我们假设特攻伤害是某种特定类型
if damageType == info.DamageType.Red { // 这里假设Red代表物理攻击伤害需要根据实际情况调整
// 实际上需要区分特攻伤害,这可能需要更复杂的判断逻辑
// 暂时简化为只要受到攻击就可能触发
s.target.SetStatus(s.source, info.PetStatusBurn, 1)
}
// 减少剩余回合数
s.roundsLeft--
if s.roundsLeft <= 0 {
return false // 效果结束
}
return true
}
// Duration 设置持续回合数
func (s *SpecialAttackBurnEffect) Duration(rounds int) {
s.roundsLeft = rounds
}
// SetArgs 设置参数
func (s *SpecialAttackBurnEffect) SetArgs(source *input.Input, args ...int) {
s.source = source
if len(args) > 0 {
s.roundsLeft = args[0]
}
}
func init() {
input.InitEffect(input.EffectType.Skill, 563, &Effect563{})
}

View File

@@ -0,0 +1,59 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// {
// "id": 563,
// "argsNum": 1,
// "info": "命中后{0}回合内若对手受到特攻伤害则100%烧伤"
// },
//
// {
// "id": 564,
// "argsNum": 1,
// "info": "命中后{0}回合内若对手受到攻击伤害则100%烧伤"
// },
type Effect563 struct {
node.EffectNode
ptype info.EnumCategory
}
func (e *Effect563) OnSkill() bool {
rounds := int(e.Args()[0].IntPart())
e.Ctx().Opp.AddEffect(e.Ctx().Our, e.GenSub(&Effect563_sub{
ptype: e.ptype,
}, rounds))
return true
}
// SpecialAttackBurnEffect 是一个临时效果,当对手受到特攻伤害时烧伤
type Effect563_sub struct {
node.EffectNode
ptype info.EnumCategory
}
func (e *Effect563_sub) Skill_Use_ex() bool {
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() != e.ptype {
return true
}
burnEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Burned))
if burnEffect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, burnEffect)
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 563, &Effect563{})
input.InitEffect(input.EffectType.Skill, 564, &Effect563{})
}

View File

@@ -1,86 +0,0 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// {
// "id": 564,
// "argsNum": 1,
// "info": "命中后{0}回合内若对手受到攻击伤害则100%烧伤"
// },
type Effect564 struct {
node.EffectNode
}
func (e *Effect564) OnSkill() bool {
if !e.Hit() {
return true
}
rounds := int(e.Args()[0].IntPart())
// 设置一个状态使对手在接下来的回合中受到攻击时100%烧伤
effect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatusBurn))
if effect != nil {
effect.SetArgs(e.Ctx().Our, 1) // 设置烧伤等级为1
effect.Duration(rounds) // 持续回合数
// 添加一个监听对手受到攻击伤害的回调
// 这里我们创建一个临时效果来监听伤害
burnOnAttackEffect := &BurnOnAttackEffect{
roundsLeft: rounds,
source: e.Ctx().Our,
target: e.Ctx().Opp,
}
// 将效果添加到对手身上,持续指定回合数
e.Ctx().Opp.AddEffect(e.Ctx().Our, burnOnAttackEffect)
}
return true
}
// BurnOnAttackEffect 是一个临时效果,用于监听对手受到攻击伤害
type BurnOnAttackEffect struct {
node.EffectNode
roundsLeft int
source *input.Input
target *input.Input
}
// OnDamageTaken 在对手受到攻击伤害时触发
func (b *BurnOnAttackEffect) OnDamageTaken(damageType info.EnumDamageType) bool {
// 如果是攻击伤害,则造成烧伤
if damageType == info.DamageType.Red || damageType == info.DamageType.Percent {
// 100%让对手烧伤
b.target.SetStatus(b.source, info.PetStatusBurn, 1)
}
// 减少剩余回合数
b.roundsLeft--
if b.roundsLeft <= 0 {
return false // 效果结束
}
return true
}
// Duration 设置持续回合数
func (b *BurnOnAttackEffect) Duration(rounds int) {
b.roundsLeft = rounds
}
// SetArgs 设置参数
func (b *BurnOnAttackEffect) SetArgs(source *input.Input, args ...int) {
b.source = source
if len(args) > 0 {
b.roundsLeft = args[0]
}
}
func init() {
input.InitEffect(input.EffectType.Skill, 564, &Effect564{})
}

View File

@@ -13,30 +13,32 @@ import (
// },
type Effect571 struct {
node.EffectNode
duy int
}
func (e *Effect571) Skill_Use() bool {
// 创建一个延时伤害效果,在指定回合后对对手造成固定伤害
turns := int(e.Args()[0].IntPart()) // 回合数
damage := e.Args()[1] // 固定伤害值
func (e *Effect571) TurnEnd() {
if turns <= 0 {
e.duy--
}
// 这个实际上在对方回合执行的
func (e *Effect571) Skill_Use() bool {
//fmt.Println("镇魂歌剩余回合", e.duy)
//defer e.Alive(false)
damage := e.Args()[1] // 固定伤害值
if e.duy <= 0 { //说明对方没有切换精灵
// 如果回合数为0或负数立即造成伤害
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
} else {
// 延迟执行效果,目前简化为立即执行
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
e.Alive(false)
}
return true
}
func init() {
input.InitEffect(inpu t.EffectType.Skill, 571, &Effect571{})
input.InitEffect(input.EffectType.Skill, 571, &Effect571{})
}

View File

@@ -14,10 +14,7 @@ import (
*/
type Effect62 struct {
node.EffectNode
// Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用
// opp *input.Input
// e *Effect62_sub
//l sync.Once
}
type Effect62_sub struct {
node.EffectNode

View File

@@ -109,11 +109,11 @@ func (s *BaseSysLogService) Record(ctx g.Ctx) {
"params": baseSysLog.Params,
})
}
func (s *BaseSysLogService) RecordFight(userid uint32, desc string) {
func (s *BaseSysLogService) RecordLog(userid uint32, desc string) {
baseSysLog := model.NewBaseSysLog()
baseSysLog.UserID = uint(userid)
baseSysLog.Action = "fight"
baseSysLog.Action = "panic"
baseSysLog.Params = desc
m := cool.DBM(s.Model)

View File

@@ -58,8 +58,6 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 {
return 0
}
return 0
}
func (s *PetFusionService) getData(p1, p2 uint32) []model.PetFusion {

View File

@@ -156,7 +156,7 @@ func (s *EggService) GetEgg() *model.PetInfo {
return nil
}
mpets, isshiny := service.NewEggService().GetResult(tt.CurEgg.MalePetID, tt.CurEgg.FeMalePetID,tt.CurEgg.EggID+tt.Data.Intimacy)
mpets, isshiny := service.NewEggService().GetResult(tt.CurEgg.MalePetID, tt.CurEgg.FeMalePetID, tt.CurEgg.EggID)
if mpets == 0 {
return nil
}