From 90fdb49b923e2d826aefaccfd3c3d70a807d601b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Fri, 19 Dec 2025 21:12:45 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(logic):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E6=9C=80=E5=A4=A7=E7=94=9F=E5=91=BD=E5=80=BC?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E5=B9=B6=E4=BC=98=E5=8C=96=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增了减少最大生命值的效果实现(opTypeMaxHP),并在 EffectPropSyncReverse 结构体中增加了对目标宠物属性的处理逻辑。同时重构了属性同步与反转相关代码, 改进了效果激活 --- logic/service/fight/effect/effect_attr.go | 132 +++++++++++++++++----- logic/service/fight/node/Turn.go | 1 + logic/service/fight/node/node.go | 11 ++ 3 files changed, 118 insertions(+), 26 deletions(-) diff --git a/logic/service/fight/effect/effect_attr.go b/logic/service/fight/effect/effect_attr.go index 9a36528f1..18f79fdf3 100644 --- a/logic/service/fight/effect/effect_attr.go +++ b/logic/service/fight/effect/effect_attr.go @@ -18,6 +18,7 @@ const ( opAttackSync // 同步攻击力(51) opTypeReverse // 反转属性类型(55) opTypeSync // 同步属性类型(56) + opTypeMaxHP // 减少最大生命值38) ) // 效果上下文:存储属性修改前的原始值(用于还原) @@ -35,8 +36,10 @@ var propOpMap = make(map[int]func() propOpContext) // EffectPropSyncReverse:属性同步/反转效果核心结构体 type EffectPropSyncReverse struct { node.EffectNode - ctx propOpContext // 操作上下文(存储原始值) - bindpet *info.BattlePetEntity + ctx propOpContext // 操作上下文(存储原始值) + ourpet *info.BattlePetEntity + opppet *info.BattlePetEntity + can bool } // 工厂函数:创建属性同步/反转效果实例 @@ -53,6 +56,9 @@ func init() { func registerPropSyncReverseEffects() { // 效果ID与操作配置的映射 effectMap := map[int]func() propOpContext{ + 38: func() propOpContext { // 减少最大生命值 + return propOpContext{opType: opTypeMaxHP} + }, 45: func() propOpContext { // n回合防御力和对手相同 return propOpContext{opType: opDefenseSync, propIndex: 1} }, @@ -87,60 +93,134 @@ func (e *EffectPropSyncReverse) OnSkill() bool { if !e.Hit() { return true } - if e.bindpet != nil { + if e.opppet != nil { return true } - ourPet := e.Ctx().Our.CurrentPet - oppPet := e.Ctx().Opp.CurrentPet + e.ourpet = e.Ctx().Our.CurrentPet + e.opppet = e.Ctx().Opp.CurrentPet switch e.ctx.opType { case opDefenseSync, opAttackSync: // 同步攻防属性:保存我方原始值,覆盖为对方值 - e.ctx.oldOurProp = ourPet.Info.Prop[e.ctx.propIndex] - ourPet.Info.Prop[e.ctx.propIndex] = oppPet.Info.Prop[e.ctx.propIndex] + e.ctx.oldOurProp = e.ourpet.Info.Prop[e.ctx.propIndex] + e.ourpet.Info.Prop[e.ctx.propIndex] = e.opppet.Info.Prop[e.ctx.propIndex] case opTypeReverse: // 反转属性类型:保存双方原始值,交换类型 - e.ctx.oldOurType = ourPet.PetInfo.Type - e.ctx.oldOppType = oppPet.PetInfo.Type - ourPet.PetInfo.Type, oppPet.PetInfo.Type = oppPet.PetInfo.Type, ourPet.PetInfo.Type + e.ctx.oldOurType = e.ourpet.PetInfo.Type + e.ctx.oldOppType = e.opppet.PetInfo.Type + e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type = e.opppet.PetInfo.Type, e.ourpet.PetInfo.Type + + println("Effect55_o", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type) case opTypeSync: // 同步属性类型:保存我方原始值,覆盖为对方值 - e.ctx.oldOurType = ourPet.PetInfo.Type - ourPet.PetInfo.Type = oppPet.PetInfo.Type - } + e.ctx.oldOurType = e.ourpet.PetInfo.Type + e.ourpet.PetInfo.Type = e.opppet.PetInfo.Type + case opTypeMaxHP: // 减少最大生命值 + if e.opppet.GetMaxHP().Cmp(e.Args()[0]) == -1 { + e.opppet.Info.MaxHp -= uint32(e.Args()[0].IntPart()) + + } + + } + e.can = true - //绑定对方精灵 - e.bindpet = e.Ctx().Opp.CurrentPet return true } // Alive:效果存活判定(结束时还原属性) func (e *EffectPropSyncReverse) Alive(t ...bool) bool { - if !e.Hit() { - return true - } + //println("属性类测试", t) - if e.BoolisFalse(t...) { - ourPet := e.Ctx().Our.CurrentPet + if e.BoolisFalse(t...) && e.can { - oppPet := e.bindpet switch e.ctx.opType { case opDefenseSync, opAttackSync: // 还原攻防属性 - ourPet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp + e.ourpet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp case opTypeReverse: // 还原反转的属性类型(恢复双方原始值) - ourPet.PetInfo.Type = e.ctx.oldOurType - oppPet.PetInfo.Type = e.ctx.oldOppType - + e.ourpet.PetInfo.Type = e.ctx.oldOurType + e.ourpet.PetInfo.Type = e.ctx.oldOppType + println("Effect55_o取消效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type) case opTypeSync: // 还原同步的属性类型 - ourPet.PetInfo.Type = e.ctx.oldOurType + e.ourpet.PetInfo.Type = e.ctx.oldOurType + default: + // case opTypeMaxHP: // 减少最大生命值 + // oppPet.Info.MaxHp += uint32(e.Args()[0].IntPart()) } + e.can = false } + if e.BoolisTrue(t...) && e.can { + switch e.ctx.opType { + case opDefenseSync, opAttackSync: + // 同步攻防属性:保存我方原始值,覆盖为对方值 + e.ctx.oldOurProp = e.ourpet.Info.Prop[e.ctx.propIndex] + e.ourpet.Info.Prop[e.ctx.propIndex] = e.opppet.Info.Prop[e.ctx.propIndex] + + case opTypeReverse: + // 反转属性类型:保存双方原始值,交换类型 + e.ctx.oldOurType = e.ourpet.PetInfo.Type + e.ctx.oldOppType = e.opppet.PetInfo.Type + e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type = e.opppet.PetInfo.Type, e.ourpet.PetInfo.Type + println("Effect55_o激活效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type) + case opTypeSync: + // 同步属性类型:保存我方原始值,覆盖为对方值 + e.ctx.oldOurType = e.ourpet.PetInfo.Type + e.ourpet.PetInfo.Type = e.opppet.PetInfo.Type + case opTypeMaxHP: // 减少最大生命值 + if e.opppet.GetMaxHP().Cmp(e.Args()[0]) == -1 { + e.opppet.Info.MaxHp -= uint32(e.Args()[0].IntPart()) + + } + + } + e.can = false + } return e.EffectNode.Alive(t...) } +func (e *EffectPropSyncReverse) Turn_End() { + + if e.Duration() == 0 { // 保留 (负数表示永久) + if e.can { + switch e.ctx.opType { + case opDefenseSync, opAttackSync: + // 还原攻防属性 + e.ourpet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp + + case opTypeReverse: + // 还原反转的属性类型(恢复双方原始值) + e.ourpet.PetInfo.Type = e.ctx.oldOurType + e.ourpet.PetInfo.Type = e.ctx.oldOppType + println("Effect55_o取消效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type) + case opTypeSync: + // 还原同步的属性类型 + e.ourpet.PetInfo.Type = e.ctx.oldOurType + default: + // case opTypeMaxHP: // 减少最大生命值 + // oppPet.Info.MaxHp += uint32(e.Args()[0].IntPart()) + } + e.can = false + } + e.Alive(false) + + } else { + // e.trunl.Do(func() { + + // if !e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) { //如果我方后手,那就给回合+1 + // e.duration++ + // // e.Alive(true) + // } + + if e.Duration() > 0 { + e.Duration(e.Duration() - 1) + } + // }) + + } + +} diff --git a/logic/service/fight/node/Turn.go b/logic/service/fight/node/Turn.go index 43d8bdf5c..49fc93464 100644 --- a/logic/service/fight/node/Turn.go +++ b/logic/service/fight/node/Turn.go @@ -18,6 +18,7 @@ func (e *EffectNode) Turn_Start(fattack, sattack *action.SelectSkillAction) { //panic("not implemented") // TODO: Implement } func (e *EffectNode) Turn_End() { + // println("效果结算", e.id.Suffix(), e.duration) if e.duration == 0 { // 保留 (负数表示永久) diff --git a/logic/service/fight/node/node.go b/logic/service/fight/node/node.go index bc858d695..e6a13f525 100644 --- a/logic/service/fight/node/node.go +++ b/logic/service/fight/node/node.go @@ -132,3 +132,14 @@ func (e *EffectNode) BoolisFalse(t ...bool) bool { } return false } +func (e *EffectNode) BoolisTrue(t ...bool) bool { + + if len(t) > 0 { + if t[0] == true { + return true + + } + return false + } + return false +}