From e568de237922c82daf8fc93ee1f1e92ad120c54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Thu, 12 Mar 2026 19:33:56 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(fight):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E6=95=88=E6=9E=9C4=E5=92=8C5=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除旧的EffectStat通用结构体 - 为技能4和5创建独立的Effect4和Effect5结构体 - 简化技能触发逻辑,直接使用SideEffectArgs参数 - 技能4现在只影响自身属性,技能5只影响对方属性 - 移除targetOpponent布尔类型判断逻辑 fix(pet): 添加宠物上架数量限制 - 在UPdatePrice方法中增加销售宠物数量检查 - 当is_sale为1时检查 --- logic/service/fight/effect/effect_4_5.go | 66 ++++++++++-------------- modules/player/service/pet.go | 7 +++ 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/logic/service/fight/effect/effect_4_5.go b/logic/service/fight/effect/effect_4_5.go index a71778341..1f9ca6c9a 100644 --- a/logic/service/fight/effect/effect_4_5.go +++ b/logic/service/fight/effect/effect_4_5.go @@ -1,7 +1,6 @@ package effect import ( - "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" ) @@ -9,65 +8,52 @@ import ( // 注册 // ----------------------------------------------------------- func init() { - initskill(4, newEffectStat(false)) - initskill(5, newEffectStat(true)) + initskill(4, &Effect4{}) + initskill(5, &Effect5{}) } // ----------------------------------------------------------- // 构造 // ----------------------------------------------------------- -func newEffectStat(targetOpponent bool) input.Effect { - e := &EffectStat{ - Etype: targetOpponent, - } - //e.CanStack(-1) // 无限叠加 - return e -} // ----------------------------------------------------------- // 主体结构 // ----------------------------------------------------------- -type EffectStat struct { +type Effect4 struct { node.EffectNode - Etype bool // false: 作用自身, true: 作用对方 } // ----------------------------------------------------------- // 技能触发时调用 // ----------------------------------------------------------- -func (e *EffectStat) Skill_Use() bool { - - // 参数解构 (防止 SideEffectArgs 长度不足) - var ( - statIndex int // 哪个属性 - chance int // 触发概率 - level int // 增减值 - ) - if len(e.SideEffectArgs) > 0 { - statIndex = e.SideEffectArgs[0] - } - if len(e.SideEffectArgs) > 1 { - chance = e.SideEffectArgs[1] - } - if len(e.SideEffectArgs) > 2 { - level = e.SideEffectArgs[2] - } - - // 概率判定 - ok, _, _ := e.Input.Player.Roll(chance, 100) +func (e *Effect4) Skill_Use() bool { + ok, _, _ := e.Input.Player.Roll(e.SideEffectArgs[0], 100) if !ok { return true } - // 执行属性变化 - if e.Etype { - // 对方属性变化 - e.Ctx().Opp.SetProp(e.Ctx().Our, int8(statIndex), int8(level)) - } else { - // 自身属性变化 - e.Ctx().Our.SetProp(e.Ctx().Our, int8(statIndex), int8(level)) - } + e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.SideEffectArgs[1]), int8(e.SideEffectArgs[2])) + + return true +} + +type Effect5 struct { + node.EffectNode +} + +// ----------------------------------------------------------- +// 技能触发时调用 +// ----------------------------------------------------------- +func (e *Effect5) Skill_Use() bool { + + // 概率判定 + ok, _, _ := e.Input.Player.Roll(e.SideEffectArgs[0], 100) + if !ok { + return true + } + + e.Ctx().Opp.SetProp(e.Ctx().Our, int8(e.SideEffectArgs[1]), int8(e.SideEffectArgs[2])) return true } diff --git a/modules/player/service/pet.go b/modules/player/service/pet.go index e7cd7ff62..3416f6c34 100644 --- a/modules/player/service/pet.go +++ b/modules/player/service/pet.go @@ -50,6 +50,13 @@ func (s *PetService) UPdateFree(ctime uint32, free uint32) { } func (s *PetService) UPdatePrice(ctime uint32, Price uint32, is_sale uint32) error { + if is_sale == 1 { + t, _ := s.dbm(s.Model).Where("is_sale", 1).Count() + if t > 3 { + return fmt.Errorf("精灵数量已满") + } + } + res0, err := s.dbm(s.Model). Where("catch_time", ctime). // 限定 ctime,避免全表更新 Where("sale_price = ?", 0). // 只筛选 sale_price=0 的记录