From c42199a57801bc7b01925272ff33dcb05332634d Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Tue, 23 Sep 2025 23:35:53 +0000 Subject: [PATCH] =?UTF-8?q?refactor(fight/effect):=20=E5=B0=86=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E8=87=B3Input.GetProp=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96OnSkill=E6=96=B9=E6=B3=95=E5=B9=B6=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/effect/effect_damage.go | 20 ++---------------- logic/service/fight/input/attr.go | 23 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/logic/service/fight/effect/effect_damage.go b/logic/service/fight/effect/effect_damage.go index e8f3efe0..9d30d719 100644 --- a/logic/service/fight/effect/effect_damage.go +++ b/logic/service/fight/effect/effect_damage.go @@ -35,23 +35,8 @@ func (e *Effect0) TurnEnd(opp *input.Input) { // 使用技能时 func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) { - oldour := deepcopy.Copy(e.Input.CurrentPet).(*info.BattlePetEntity) - oldouo := deepcopy.Copy(opp.CurrentPet).(*info.BattlePetEntity) - e.Input.Exec(func(t input.Effect) bool { //属性获取前 - t.BeferAttr(e.Input.CurrentPet) //使XX为XX - return true - }) - e.Input.Exec(func(t input.Effect) bool { //属性获取后 - - t.AfterAttr(opp.CurrentPet) //视为xx - return true - }) - - //威力+区 - //威力*区 - //todo 待修复input输入 - spower := skill.CalculatePower(opp.CurrentPet) + spower := e.Input.CalculatePower(opp.CurrentPet,skill) e.Input.AttackValue.LostHp = uint32(spower.IntPart()) e.Input.Exec(func(t input.Effect) bool { //计算暴击率加成 @@ -70,8 +55,7 @@ func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) { // } else { // opp.CurrentPet.Info.Hp = opp.CurrentPet.Info.Hp - e.Input.AttackValue.LostHp // } - e.Input.CurrentPet = oldour //恢复 - opp.CurrentPet = oldouo //恢复 + } func (this *Effect0) IsCrit(opp *input.Input, skill *info.SkillEntity) { skill.Crit = 0 diff --git a/logic/service/fight/input/attr.go b/logic/service/fight/input/attr.go index 2647a935..d10b94d2 100644 --- a/logic/service/fight/input/attr.go +++ b/logic/service/fight/input/attr.go @@ -3,7 +3,9 @@ package input import ( element "blazing/common/data/Element" "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "github.com/mohae/deepcopy" "github.com/shopspring/decimal" ) @@ -35,9 +37,30 @@ func (i *Input) GetAction(opp *Input) { } +// todo获取属性,待实现获取后改回原属性 +func (i *Input) GetProp(opp *Input) { + oldour := deepcopy.Copy(e.Input.CurrentPet).(*info.BattlePetEntity) + oldouo := deepcopy.Copy(opp.CurrentPet).(*info.BattlePetEntity) + e.Input.Exec(func(t input.Effect) bool { //属性获取前 + + t.BeferAttr(e.Input.CurrentPet) //使XX为XX + return true + }) + e.Input.Exec(func(t input.Effect) bool { //属性获取后 + + t.AfterAttr(opp.CurrentPet) //视为xx + return true + }) + e.Input.CurrentPet = oldour //恢复 + opp.CurrentPet = oldouo //恢复 +} + // 计算技能威力 func (i *Input) CalculatePower(deftype *info.BattlePetEntity, skill *info.SkillEntity) decimal.Decimal { + //威力+区 + //威力*区 + //todo 待修复input输入 // 1. 计算等级因子 (level * 0.4 + 2) levelFactor := decimal.NewFromInt(int64(i.CurrentPet.Info.Level)). Mul(decimal.NewFromFloat(0.4)).Add(decimal.NewFromInt(2))