From fb835a017f75159bf576ce3ceb784f202fe2875d Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Thu, 18 Dec 2025 13:10:40 +0000 Subject: [PATCH] 1 --- logic/service/fight/effect/effect_attr.go | 105 +++++++++++++--------- logic/service/fight/node/node.go | 18 ++-- 2 files changed, 73 insertions(+), 50 deletions(-) diff --git a/logic/service/fight/effect/effect_attr.go b/logic/service/fight/effect/effect_attr.go index 882206679..d56fa424c 100644 --- a/logic/service/fight/effect/effect_attr.go +++ b/logic/service/fight/effect/effect_attr.go @@ -1,79 +1,102 @@ package effect import ( - "blazing/logic/service/fight/action" "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" "sync" ) -/** - * 降低对方 n 点 btl_Max体力 - */ +// ----------------------------------------------------------- +// 降低对方最大体力效果 +// ----------------------------------------------------------- type Effect38 struct { node.EffectNode } +// 工厂函数 +func newEffect38() *Effect38 { + return &Effect38{} +} + +func init() { + // 注册降低最大体力效果 + input.InitEffect(input.EffectType.Skill, 38, newEffect38()) +} + +// ----------------------------------------------------------- +// 技能触发时调用 +// ----------------------------------------------------------- func (e *Effect38) OnSkill() bool { if !e.Hit() { return true } - ee := &Effect38_sub{} - ee.EffectNode.Duration(-1) //给对方挂3回合子buff - //ee.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID + // 创建子效果实例 + ee := &Effect38Sub{} + ee.EffectNode.Duration(-1) // 给对方挂3回合子buff + // 设置子效果ID和捕获时间 tt := e.ID() tt.SetEffectType(input.EffectType.Sub) tt.SetCatchTime(e.Ctx().Opp.CurrentPet.Info.CatchTime) ee.ID(tt) ee.SetArgs(e.Ctx().Our, e.SideEffectArgs...) + + // 添加子效果到对方 e.Ctx().Opp.AddEffect(e.Ctx().Our, ee) return true } -// 命中之后 -func (e *Effect38_sub) Turn_Start(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) { - //魂印特性有不在场的情况,绑定时候将精灵和特性绑定 - if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { - return - } - if e.Args()[0].Cmp(e.Ctx().Our.CurrentPet.GetMaxHP()) == -1 { - - e.l.Do(func() { - e.oldtype = e.Ctx().Our.CurrentPet.Info.MaxHp - e.Ctx().Our.CurrentPet.GetMaxHP().Sub(e.Args()[0]) - - }) - - } - +// ----------------------------------------------------------- +// 降低最大体力子效果 +// ----------------------------------------------------------- +type Effect38Sub struct { + node.EffectNode + oldMaxHP uint32 // 记录原始最大体力值 + once sync.Once // 确保只执行一次体力修改 } -func (e *Effect38_sub) Switch(in *input.Input, at info.AttackValue, oldpet *info.BattlePetEntity) bool { + +// 回合开始时触发 +func (e *Effect38Sub) Turn_Start(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) { + // 魂印特性不在场判断:捕获时间不匹配则返回 + if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { + return + } + + // 确保只执行一次体力扣减 + e.once.Do(func() { + // 获取要扣除的体力值和当前最大体力 + reduceHP := e.Args()[0] + currentMaxHP := e.Ctx().Our.CurrentPet.GetMaxHP() + + // 只在扣除值小于当前最大体力时执行 + if reduceHP.Cmp(currentMaxHP) == -1 { + e.oldMaxHP = e.Ctx().Our.CurrentPet.Info.MaxHp + currentMaxHP.Sub(reduceHP) + } + }) +} + +// 精灵切换时触发 +func (e *Effect38Sub) Switch(in *input.Input, at info.AttackValue, oldpet *info.BattlePetEntity) bool { return true } -type Effect38_sub struct { - node.EffectNode - oldtype uint32 - l sync.Once -} +// 效果存活状态判断(处理属性还原) +func (e *Effect38Sub) Alive(t ...bool) bool { + if len(t) > 0 { + if t[0] == false { + return true + } + return false + } -func (e *Effect38_sub) Alive(t ...bool) bool { - - if e.BoolisFalse(t...) { //说明到了回合结束取消节点,那么就将变化过的属性变化回来 - //还原属性 - e.Ctx().Our.CurrentPet.Info.MaxHp = e.oldtype + // 回合结束取消节点时还原属性 + if e.BoolisFalse(t...) { + e.Ctx().Our.CurrentPet.Info.MaxHp = e.oldMaxHP } return e.EffectNode.Alive(t...) } - -func init() { - ret := &Effect38{} - - input.InitEffect(input.EffectType.Skill, 38, ret) - -} diff --git a/logic/service/fight/node/node.go b/logic/service/fight/node/node.go index bc858d695..2d5cf8bf3 100644 --- a/logic/service/fight/node/node.go +++ b/logic/service/fight/node/node.go @@ -121,14 +121,14 @@ func (e *EffectNode) AttackTime(*input.Input, *input.Input) bool { func (e *EffectNode) Prop_Befer(in *input.Input, prop int8, level int8, ptype info.EnumAbilityOpType) bool { return true } -func (e *EffectNode) BoolisFalse(t ...bool) bool { +// func (e *EffectNode) BoolisFalse(t ...bool) bool { - if len(t) > 0 { - if t[0] == false { - return true +// if len(t) > 0 { +// if t[0] == false { +// return true - } - return false - } - return false -} +// } +// return false +// } +// return false +// }