From c049bbd5acc2ac5d58391cd2acbefef06b8225a1 Mon Sep 17 00:00:00 2001 From: xinian Date: Sat, 21 Mar 2026 00:24:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E5=8F=8A=E6=88=98=E6=96=97=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/login_main.go | 9 +- logic/service/common/log.go | 2 +- logic/service/fight/boss/NewSeIdx_19.go | 4 +- logic/service/fight/boss/NewSeIdx_405.go | 4 +- logic/service/fight/boss/NewSeIdx_42.go | 4 +- logic/service/fight/boss/NewSeIdx_92.go | 4 +- logic/service/fight/effect/142.go | 4 +- logic/service/fight/effect/171.go | 4 +- logic/service/fight/effect/454.go | 4 +- logic/service/fight/effect/563.go未实装 | 76 ---------------- logic/service/fight/effect/563_564.go | 59 +++++++++++++ logic/service/fight/effect/564.go未实装 | 86 ------------------- .../fight/effect/{571.go未实装 => 571.go} | 28 +++--- logic/service/fight/effect/effect_62.go | 5 +- modules/base/service/base_sys_log.go | 4 +- modules/config/service/pet_fusion_service.go | 2 - modules/player/service/egg.go | 2 +- 17 files changed, 95 insertions(+), 206 deletions(-) delete mode 100644 logic/service/fight/effect/563.go未实装 create mode 100644 logic/service/fight/effect/563_564.go delete mode 100644 logic/service/fight/effect/564.go未实装 rename logic/service/fight/effect/{571.go未实装 => 571.go} (57%) diff --git a/logic/controller/login_main.go b/logic/controller/login_main.go index 100eb3b2a..9480c8396 100644 --- a/logic/controller/login_main.go +++ b/logic/controller/login_main.go @@ -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) diff --git a/logic/service/common/log.go b/logic/service/common/log.go index e3f008926..d18956bfc 100644 --- a/logic/service/common/log.go +++ b/logic/service/common/log.go @@ -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() { diff --git a/logic/service/fight/boss/NewSeIdx_19.go b/logic/service/fight/boss/NewSeIdx_19.go index e4248b598..9c6fd5900 100644 --- a/logic/service/fight/boss/NewSeIdx_19.go +++ b/logic/service/fight/boss/NewSeIdx_19.go @@ -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 } diff --git a/logic/service/fight/boss/NewSeIdx_405.go b/logic/service/fight/boss/NewSeIdx_405.go index dbff1ff36..ef6dccbdb 100644 --- a/logic/service/fight/boss/NewSeIdx_405.go +++ b/logic/service/fight/boss/NewSeIdx_405.go @@ -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 } diff --git a/logic/service/fight/boss/NewSeIdx_42.go b/logic/service/fight/boss/NewSeIdx_42.go index c9e31e675..33f0661e0 100644 --- a/logic/service/fight/boss/NewSeIdx_42.go +++ b/logic/service/fight/boss/NewSeIdx_42.go @@ -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 } diff --git a/logic/service/fight/boss/NewSeIdx_92.go b/logic/service/fight/boss/NewSeIdx_92.go index 1e0c1d179..c9737def5 100644 --- a/logic/service/fight/boss/NewSeIdx_92.go +++ b/logic/service/fight/boss/NewSeIdx_92.go @@ -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 { diff --git a/logic/service/fight/effect/142.go b/logic/service/fight/effect/142.go index 2fa9dcfdf..23af20f5a 100644 --- a/logic/service/fight/effect/142.go +++ b/logic/service/fight/effect/142.go @@ -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 } diff --git a/logic/service/fight/effect/171.go b/logic/service/fight/effect/171.go index 400c239be..ca513cf4a 100644 --- a/logic/service/fight/effect/171.go +++ b/logic/service/fight/effect/171.go @@ -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 } diff --git a/logic/service/fight/effect/454.go b/logic/service/fight/effect/454.go index e4709f0a8..78420105b 100644 --- a/logic/service/fight/effect/454.go +++ b/logic/service/fight/effect/454.go @@ -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 } diff --git a/logic/service/fight/effect/563.go未实装 b/logic/service/fight/effect/563.go未实装 deleted file mode 100644 index f4cc2a96a..000000000 --- a/logic/service/fight/effect/563.go未实装 +++ /dev/null @@ -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{}) -} diff --git a/logic/service/fight/effect/563_564.go b/logic/service/fight/effect/563_564.go new file mode 100644 index 000000000..dd6c3bc85 --- /dev/null +++ b/logic/service/fight/effect/563_564.go @@ -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{}) +} diff --git a/logic/service/fight/effect/564.go未实装 b/logic/service/fight/effect/564.go未实装 deleted file mode 100644 index a1636efc3..000000000 --- a/logic/service/fight/effect/564.go未实装 +++ /dev/null @@ -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{}) -} \ No newline at end of file diff --git a/logic/service/fight/effect/571.go未实装 b/logic/service/fight/effect/571.go similarity index 57% rename from logic/service/fight/effect/571.go未实装 rename to logic/service/fight/effect/571.go index c49911fe4..0095e5800 100644 --- a/logic/service/fight/effect/571.go未实装 +++ b/logic/service/fight/effect/571.go @@ -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{}) } diff --git a/logic/service/fight/effect/effect_62.go b/logic/service/fight/effect/effect_62.go index 23aa41e50..2208b4282 100644 --- a/logic/service/fight/effect/effect_62.go +++ b/logic/service/fight/effect/effect_62.go @@ -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 diff --git a/modules/base/service/base_sys_log.go b/modules/base/service/base_sys_log.go index ce504a305..6fbb9ce62 100644 --- a/modules/base/service/base_sys_log.go +++ b/modules/base/service/base_sys_log.go @@ -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) diff --git a/modules/config/service/pet_fusion_service.go b/modules/config/service/pet_fusion_service.go index 91f783e01..6e5a68f49 100644 --- a/modules/config/service/pet_fusion_service.go +++ b/modules/config/service/pet_fusion_service.go @@ -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 { diff --git a/modules/player/service/egg.go b/modules/player/service/egg.go index 1eb211fa6..62c92be83 100644 --- a/modules/player/service/egg.go +++ b/modules/player/service/egg.go @@ -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 }