From a2aaf7fff81c4828a04f85d022d2724ea5bb189f Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Thu, 25 Sep 2025 18:13:16 +0000 Subject: [PATCH] =?UTF-8?q?refactor(fight/effect):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=91=BD=E4=B8=AD=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8OnHit/OnM?= =?UTF-8?q?iss=E6=8E=A5=E5=8F=A3=E5=B9=B6=E6=96=B0=E5=A2=9EEffect85?= =?UTF-8?q?=E5=81=B7=E5=8F=96=E5=BC=BA=E5=8C=96=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/effect/effect_4_5.go | 8 ++-- logic/service/fight/effect/effect_62.go | 4 +- logic/service/fight/effect/effect_85.go | 28 ++++++++++++++ logic/service/fight/input/attr.go | 49 ++++++++++++++++++++++-- logic/service/fight/input/effecti.go | 2 +- logic/service/fight/node/attr.go | 2 +- logic/service/fight/node/skill.go | 18 +++++++++ 7 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 logic/service/fight/effect/effect_85.go diff --git a/logic/service/fight/effect/effect_4_5.go b/logic/service/fight/effect/effect_4_5.go index 93b30f4e..460ac2b9 100644 --- a/logic/service/fight/effect/effect_4_5.go +++ b/logic/service/fight/effect/effect_4_5.go @@ -39,10 +39,10 @@ type EffectStat struct { // addrA := unsafe.Pointer(baseAddr + 4) //根据攻击算其他字段 // *(*uint32)(addrA) = 100 // } -func (e *EffectStat) AfterSkill(opp *input.Input, skill *info.SkillEntity) { +func (e *EffectStat) OnHit(opp *input.Input, skill *info.SkillEntity) { t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100) - if !t { + if !t { //没触发 return } ptype := info.AbilityOpType.AbilityOpIncrease @@ -50,10 +50,10 @@ func (e *EffectStat) AfterSkill(opp *input.Input, skill *info.SkillEntity) { ptype = info.AbilityOpType.AbilityOpDecrease } if !e.Etype { //自身 - e.Input.SetProp(e.Input, e.EffectNode.SideEffectArgs[0], e.EffectNode.SideEffectArgs[2], ptype) + e.Input.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype) } else { //对方 - opp.SetProp(e.Input, e.EffectNode.SideEffectArgs[0], e.EffectNode.SideEffectArgs[2], ptype) + opp.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype) } } diff --git a/logic/service/fight/effect/effect_62.go b/logic/service/fight/effect/effect_62.go index b425cfff..2b50ed36 100644 --- a/logic/service/fight/effect/effect_62.go +++ b/logic/service/fight/effect/effect_62.go @@ -24,14 +24,14 @@ func init() { } -func (e *Effect62) AfterSkill(*input.Input, *info.SkillEntity) { +func (e *Effect62) OnHit(*input.Input, *info.SkillEntity) { if e.Duration() != 1 { //说明还没到生效节点 e.Hide = true //隐藏效果 } else { e.Hide = false } - if !e.Hide && e.Hit() { //说明是自身回合//如果还在隐藏,就直接返回 + if !e.Hide { //说明是自身回合//如果还在隐藏,就直接返回 //defer e.EffectNode.NotALive() //失效 //应该是对方固定伤害等于自身血量 diff --git a/logic/service/fight/effect/effect_85.go b/logic/service/fight/effect/effect_85.go new file mode 100644 index 00000000..a206116e --- /dev/null +++ b/logic/service/fight/effect/effect_85.go @@ -0,0 +1,28 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * 使对手的能力提升效果转化到自己身上 + */ +type Effect85 struct { + node.EffectNode +} + +func init() { + input.InitEffect(input.EffectType.Skill, 85, &Effect85{ + EffectNode: node.EffectNode{}, + }) + +} + +func (e *Effect85) OnHit(opp *input.Input, skill *info.SkillEntity) { + for i := 0; i < 6; i++ { + e.Input.SetProp(opp, int8(i), 1, info.AbilityOpType.AbilityOpStealStrengthen) + } + +} diff --git a/logic/service/fight/input/attr.go b/logic/service/fight/input/attr.go index 2662ab9e..677d21d5 100644 --- a/logic/service/fight/input/attr.go +++ b/logic/service/fight/input/attr.go @@ -2,7 +2,9 @@ package input import ( element "blazing/common/data/Element" + "blazing/common/utils" "blazing/logic/service/fight/info" + "fmt" "github.com/mohae/deepcopy" "github.com/shopspring/decimal" @@ -16,17 +18,56 @@ func (u *Input) Death() { } -// 1是添加,-1是减少,0是清除 -func (u *Input) SetProp(in *Input, prop, level int, ptype info.EnumAbilityOpType) { +// 施加方,类型,等级,操作类别,是否成功 +func (u *Input) SetProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) (ret bool) { canuseskill := u.Exec(func(t Effect) bool { //这个是能否使用技能 //结算状态 return t.BeferProp(in, prop, level, ptype) //返回本身结算,如果false,说明不能使用技能了 }) if canuseskill { - u.AttackValue.Prop[prop] = u.AttackValue.Prop[prop] + int8(level) - } + switch ptype { + case info.AbilityOpType.AbilityOpIncrease: + newValue := utils.Min(u.AttackValue.Prop[prop]+int8(level), 6) + if newValue > u.AttackValue.Prop[prop] { + fmt.Println("属性值会增加") + ret = true + } else { + fmt.Println("属性值不会增加") + ret = false + } + + // 执行赋值 + u.AttackValue.Prop[prop] = newValue + + case info.AbilityOpType.AbilityOpDecrease: + u.AttackValue.Prop[prop] = utils.Max(u.AttackValue.Prop[prop]+int8(level), -6) + case info.AbilityOpType.AbilityOpClearWeaken: + u.AttackValue.Prop[prop] = utils.Max(u.AttackValue.Prop[prop], 0) + case info.AbilityOpType.AbilityOpClearStrengthen: + u.AttackValue.Prop[prop] = utils.Min(u.AttackValue.Prop[prop], 0) + case info.AbilityOpType.AbilityOpStealStrengthen: + + if in.AttackValue.Prop[prop] > 0 { + u.SetProp(u, prop, in.AttackValue.Prop[prop], info.AbilityOpType.AbilityOpClearStrengthen) + + in.SetProp(u, prop, 0, info.AbilityOpType.AbilityOpClearStrengthen) //消除对面 + } + case info.AbilityOpType.AbilityOpReverse: + if level > 0 && u.AttackValue.Prop[prop] > 0 { //反转强化,实际上是附带2倍的反转强化 + + u.SetProp(u, prop, u.AttackValue.Prop[prop]*2, info.AbilityOpType.AbilityOpDecrease) + + } + if level < 0 && u.AttackValue.Prop[prop] < 0 { + u.SetProp(u, prop, -u.AttackValue.Prop[prop]*2, info.AbilityOpType.AbilityOpIncrease) + } + + } + + } + return } func (i *Input) GetAction(opp *Input) { //使用1#技能,实际上要按照四个技能权重去使用 diff --git a/logic/service/fight/input/effecti.go b/logic/service/fight/input/effecti.go index acd1d7c6..cf822436 100644 --- a/logic/service/fight/input/effecti.go +++ b/logic/service/fight/input/effecti.go @@ -17,7 +17,7 @@ type Effect interface { // OnSkillPP() bool //技能PP减少节点 AfterProp(t *Input) - BeferProp(in *Input, prop, level int, ptype info.EnumAbilityOpType) bool + BeferProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) bool AfterAttr(t *info.BattlePetEntity) //在获取属性前,比如重写对方属性AfterAttr BeferAttr(t *info.BattlePetEntity) //在获取属性后,比如视为对方属性 SetArgs(input *Input, param ...int) diff --git a/logic/service/fight/node/attr.go b/logic/service/fight/node/attr.go index 93ee1484..2e31e1de 100644 --- a/logic/service/fight/node/attr.go +++ b/logic/service/fight/node/attr.go @@ -52,6 +52,6 @@ func (this *EffectNode) OnDefeat() bool { func (this *EffectNode) AfterProp(t *input.Input) { } -func (this *EffectNode) BeferProp(in *input.Input, prop, level int, ptype info.EnumAbilityOpType) bool { +func (this *EffectNode) BeferProp(in *input.Input, prop, level int8, ptype info.EnumAbilityOpType) bool { return true } diff --git a/logic/service/fight/node/skill.go b/logic/service/fight/node/skill.go index 68da2fdb..8de3dd25 100644 --- a/logic/service/fight/node/skill.go +++ b/logic/service/fight/node/skill.go @@ -27,6 +27,24 @@ func (e *EffectNode) BeforeSkill(opp *input.Input, skill *info.SkillEntity) { // 使用技能时 func (e *EffectNode) OnSkill(opp *input.Input, skill *info.SkillEntity) { + if e.Hit() { //没命中 + e.OnHit(opp,skill) + }else{ + e.OnMiss(opp,skill) + } + +} +// miss +func (e *EffectNode) OnMiss(opp *input.Input, skill *info.SkillEntity) { + + + +} +// 命中 +func (e *EffectNode) OnHit(opp *input.Input, skill *info.SkillEntity) { + + + } func (e *EffectNode) AfterSkill(opp *input.Input, skill *info.SkillEntity) {