From d52c6cbb791a41135d938d093d8dbbe071e25e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Fri, 14 Nov 2025 04:55:29 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(fight):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=A6=82=E7=8E=87=E5=88=A4=E5=AE=9A=E5=87=BD=E6=95=B0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=B9=B6=E6=96=B0=E5=A2=9E=E7=8A=B6=E6=80=81=E4=B8=8E?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=93=8D=E4=BD=9C=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新 PlayerCaptureContext.Roll 函数注释,明确返回值含义。 新增 PetStatus 枚举值 NULL,表示无效状态。 新增 AbilityOpType.COPY 操作类型,支持复制对手属性值。 ``` --- logic/service/fight/effect/effect_112.go | 41 +++++++++++++++++ logic/service/fight/effect/effect_73.go | 50 ++++++++++++++++++++ logic/service/fight/effect/effect_74.go | 58 ++++++++++++++++++++++++ logic/service/fight/effect/effect_75.go | 58 ++++++++++++++++++++++++ logic/service/fight/effect/effect_89.go | 43 ++++++++++++++++++ logic/service/fight/effect/effect_91.go | 46 +++++++++++++++++++ logic/service/fight/info/ctx.go | 2 +- logic/service/fight/info/info.go | 1 + logic/service/fight/input/fight.go | 8 ++++ 9 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 logic/service/fight/effect/effect_112.go create mode 100644 logic/service/fight/effect/effect_73.go create mode 100644 logic/service/fight/effect/effect_74.go create mode 100644 logic/service/fight/effect/effect_75.go create mode 100644 logic/service/fight/effect/effect_89.go create mode 100644 logic/service/fight/effect/effect_91.go diff --git a/logic/service/fight/effect/effect_112.go b/logic/service/fight/effect/effect_112.go new file mode 100644 index 000000000..d468b1ca1 --- /dev/null +++ b/logic/service/fight/effect/effect_112.go @@ -0,0 +1,41 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" +) + +/** + * 牺牲全部体力造成对手250~300点伤害,造成致命伤害时,对手剩下1点体力 + */ +type Effect112 struct { + node.EffectNode + can bool +} + +func init() { + + input.InitEffect(input.EffectType.Skill, 59, &Effect112{}) + +} + +// 命中之后 +func (e *Effect112) OnSkill() bool { + if !e.Hit() { + return true + } + e.can = true + e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{ + Type: info.DamageType.Fixed, + Damage: decimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)), + }) + n := int64(e.Input.FightC.GetRand().Int31n(int32(50+1))) + 250 + e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ + Type: info.DamageType.Fixed, + Damage: decimal.Min(decimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(decimal.NewFromInt(1))), + }) + return true +} diff --git a/logic/service/fight/effect/effect_73.go b/logic/service/fight/effect/effect_73.go new file mode 100644 index 000000000..f9f861c6d --- /dev/null +++ b/logic/service/fight/effect/effect_73.go @@ -0,0 +1,50 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" +) + +/** + * 如果先出手,则受攻击时反弹200%的伤害给对手,持续n回合 + */ + +func init() { + t := &Effect73{ + EffectNode: node.EffectNode{}, + } + // t.Duration(-1) //设置成无限回合,到回合数就停止 + input.InitEffect(input.EffectType.Skill, 73, t) + +} + +type Effect73 struct { + node.EffectNode +} + +// 默认添加回合 +func (e *Effect73) SetArgs(t *input.Input, a ...int) { + + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) + +} +func (e *Effect73) Skill_Use_ex() bool { + + if !e.Hit() { + return true + } + if !e.Input.FightC.IsFirst(e.Ctx().Our.Player) { + return true + } + + e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ + Type: info.DamageType.Fixed, + Damage: e.Ctx().Opp.DamageZone.Damage.Div(decimal.NewFromInt(2)), + }) + + return true +} diff --git a/logic/service/fight/effect/effect_74.go b/logic/service/fight/effect/effect_74.go new file mode 100644 index 000000000..0e223dc7c --- /dev/null +++ b/logic/service/fight/effect/effect_74.go @@ -0,0 +1,58 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * 10%中毒、10%烧伤、10%冻伤(剩下70%无效果) + */ +type Effect74 struct { + node.EffectNode +} + +func init() { + ret := &Effect74{} + + input.InitEffect(input.EffectType.Skill, 74, ret) + +} + +// 命中之后 +func (e *Effect74) OnSkill() bool { + if !e.Hit() { + return true + } + Status := info.PetStatus.NULL + + // 生成0-99的随机数(共100种可能) + switch t := e.Input.FightC.GetRand().Int31n(100); { + case t < 10: // 0-9(10个数,占10%) + Status = info.PetStatus.Poisoned + case t < 20: // 10-19(10个数,占10%) + // 触发睡眠效果 + Status = info.PetStatus.Burned + case t < 30: // 20-29(10个数,占10%) + // 触发害怕效果 + Status = info.PetStatus.Frozen + default: // 30-99(70个数,占70%) + // 无效果 + + } + if Status == info.PetStatus.NULL { + return true + } + // 获取状态效果 + eff := input.Geteffect(input.EffectType.Status, int(Status)) + if eff == nil { + return true + } + duration := int(e.Input.FightC.GetRand().Int31n(2)) // 默认随机 2~3 回合 + duration++ + eff.Duration(duration) + eff.SetArgs(e.Ctx().Our) //输入参数是对方 + e.Ctx().Opp.AddEffect(e.Ctx().Our, eff) + return true +} diff --git a/logic/service/fight/effect/effect_75.go b/logic/service/fight/effect/effect_75.go new file mode 100644 index 000000000..19c2659d1 --- /dev/null +++ b/logic/service/fight/effect/effect_75.go @@ -0,0 +1,58 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * 10%麻痹、10%睡眠、10%害怕(剩下70%无效果) + */ +type Effect75 struct { + node.EffectNode +} + +func init() { + ret := &Effect75{} + + input.InitEffect(input.EffectType.Skill, 75, ret) + +} + +// 命中之后 +func (e *Effect75) OnSkill() bool { + if !e.Hit() { + return true + } + Status := info.PetStatus.NULL + + // 生成0-99的随机数(共100种可能) + switch t := e.Input.FightC.GetRand().Int31n(100); { + case t < 10: // 0-9(10个数,占10%) + Status = info.PetStatus.Paralysis + case t < 20: // 10-19(10个数,占10%) + // 触发睡眠效果 + Status = info.PetStatus.Sleep + case t < 30: // 20-29(10个数,占10%) + // 触发害怕效果 + Status = info.PetStatus.Fear + default: // 30-99(70个数,占70%) + // 无效果 + + } + if Status == info.PetStatus.NULL { + return true + } + // 获取状态效果 + eff := input.Geteffect(input.EffectType.Status, int(Status)) + if eff == nil { + return true + } + duration := int(e.Input.FightC.GetRand().Int31n(2)) // 默认随机 2~3 回合 + duration++ + eff.Duration(duration) + eff.SetArgs(e.Ctx().Our) //输入参数是对方 + e.Ctx().Opp.AddEffect(e.Ctx().Our, eff) + return true +} diff --git a/logic/service/fight/effect/effect_89.go b/logic/service/fight/effect/effect_89.go new file mode 100644 index 000000000..5879c878c --- /dev/null +++ b/logic/service/fight/effect/effect_89.go @@ -0,0 +1,43 @@ +package effect + +import ( + "blazing/logic/service/fight/action" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" +) + +/** + * n回合内,每次造成伤害的1/m会恢复自己的体力 + */ + +func init() { + t := &Effect89{ + EffectNode: node.EffectNode{}, + } + // t.Duration(-1) //设置成无限回合,到回合数就停止 + input.InitEffect(input.EffectType.Skill, 89, t) + +} + +type Effect89 struct { + node.EffectNode +} + +// 默认添加回合 +func (e *Effect89) SetArgs(t *input.Input, a ...int) { + + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) + +} +func (e *Effect89) Skill_Useed() bool { + if !e.Hit() { + return true + } + + e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.DamageZone.Damage.Mul(decimal.NewFromInt(int64(e.Args()[1])))) + + return true +} diff --git a/logic/service/fight/effect/effect_91.go b/logic/service/fight/effect/effect_91.go new file mode 100644 index 000000000..ad54220a1 --- /dev/null +++ b/logic/service/fight/effect/effect_91.go @@ -0,0 +1,46 @@ +package effect + +import ( + "blazing/logic/service/fight/action" + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * n回合内,对手的状态变化会同时作用在自己身上 + */ + +func init() { + t := &Effect91{ + EffectNode: node.EffectNode{}, + } + // t.Duration(-1) //设置成无限回合,到回合数就停止 + input.InitEffect(input.EffectType.Skill, 91, t) + +} + +type Effect91 struct { + node.EffectNode + can bool +} + +// 默认添加回合 +func (e *Effect91) SetArgs(t *input.Input, a ...int) { + + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) + +} +func (e *Effect91) Turn_Start(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) { + if !e.Hit() { + return + } + + for i, v := range e.Ctx().Opp.Prop { + + e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v, info.AbilityOpType.COPY) + + } + +} diff --git a/logic/service/fight/info/ctx.go b/logic/service/fight/info/ctx.go index 642bdcbc7..a938950c6 100644 --- a/logic/service/fight/info/ctx.go +++ b/logic/service/fight/info/ctx.go @@ -11,7 +11,7 @@ type PlayerCaptureContext struct { Guarantees map[int]int // 按分母分组的保底分子 map[denominator]numerator } -// Roll 通用概率判定(带共享保底) +// Roll 通用概率判定(带共享保底) 返回成功,基础,保底 func (c *PlayerCaptureContext) Roll(numerator, denominator int) (bool, float64, float64) { if denominator <= 0 { return false, 0, 0 diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index cd60ed863..f53f3146f 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -125,6 +125,7 @@ type WeakenedS struct { // 定义战斗状态枚举 var PetStatus = enum.New[struct { + NULL EnumPetStatus `enum:"-1"` Paralysis EnumPetStatus `enum:"0"` // 麻痹 Poisoned EnumPetStatus `enum:"1"` // 中毒 Burned EnumPetStatus `enum:"2"` // 烧伤 diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index bf60bd40d..8828eb37d 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -308,6 +308,14 @@ func (our *Input) SetProp(in *Input, prop, level int8, ptype info.EnumAbilityOpT our.SetProp(our, prop, -1, info.AbilityOpType.RESET) //消除自身弱化 return true } + case info.AbilityOpType.COPY: + temp := our.Opp.AttackValue.Prop[prop] + if temp >= 0 { + our.SetProp(our, prop, temp, info.AbilityOpType.ADD) + } else { + our.SetProp(our, prop, -temp, info.AbilityOpType.SUB) + } + default: //增加减少重置 if abfunc(prop, level, ptype) {