``` feat(fight): 新增多种技能效果实现(110/125/128/131/145/151),优化状态判断逻辑并重构随机数生成方式
This commit is contained in:
@@ -19,7 +19,7 @@ func (e *NewSel2) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
if in != e.Ctx().Opp {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().Our.IS_Stat(effEffect) {
|
||||
if input.IS_Stat(effEffect) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ func (e *EffectRandomPower) Skill_Hit() bool {
|
||||
}
|
||||
|
||||
// 如果 FightC 没提供随机器,使用 math/rand 兜底
|
||||
var n int
|
||||
if e.Input != nil && e.Input.FightC != nil {
|
||||
n = int(e.Input.FightC.GetRand().Int31n(int32(e.Max-e.Min+1))) + e.Min
|
||||
} else {
|
||||
n = grand.Intn(e.Max-e.Min+1) + e.Min
|
||||
}
|
||||
|
||||
// var n int
|
||||
// if e.Input != nil && e.Input.FightC != nil {
|
||||
// n = int(e.Input.FightC.GetRand().Int31n(int32(e.Max-e.Min+1))) + e.Min
|
||||
// } else {
|
||||
// n = grand.Intn(e.Max-e.Min+1) + e.Min
|
||||
// }
|
||||
n := grand.N(e.Min, e.Max)
|
||||
e.Ctx().SkillEntity.Power = n
|
||||
return true
|
||||
}
|
||||
|
||||
46
logic/service/fight/effect/effect_110.go
Normal file
46
logic/service/fight/effect/effect_110.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// n 回合内,每次躲避攻击都有m%几率使自身XX等级提升1个等级
|
||||
type Effect110 struct {
|
||||
node.EffectNode
|
||||
can bool
|
||||
}
|
||||
|
||||
// 默认添加回合
|
||||
func (e *Effect110) SetArgs(t *input.Input, a ...int) {
|
||||
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
|
||||
|
||||
}
|
||||
func (e *Effect110) Skill_Use_ex() bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().SkillEntity != nil {
|
||||
if e.Ctx().SkillEntity.AttackTime != 0 { //没有闪避掉
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
chance := e.EffectNode.SideEffectArgs[1]
|
||||
success, _, _ := e.Input.Player.Roll(chance, 100)
|
||||
if !success {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.SideEffectArgs[2]), 1, info.AbilityOpType.ADD)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// ---- 注册所有效果 ----
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 110, &Effect110{})
|
||||
}
|
||||
42
logic/service/fight/effect/effect_125.go
Normal file
42
logic/service/fight/effect/effect_125.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
func init() {
|
||||
t := &Effect125{
|
||||
EffectNode: node.EffectNode{},
|
||||
}
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 125, t)
|
||||
|
||||
}
|
||||
|
||||
type Effect125 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
// 默认添加回合
|
||||
func (e *Effect125) SetArgs(t *input.Input, a ...int) {
|
||||
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
|
||||
|
||||
}
|
||||
func (e *Effect125) DamageLock_ex(t *info.DamageZone) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
if t.Type != info.DamageType.Red {
|
||||
return true
|
||||
}
|
||||
|
||||
if t.Damage.Cmp(e.Args()[1]) == -1 {
|
||||
return true
|
||||
}
|
||||
t.Damage=e.Args()[1]
|
||||
return true
|
||||
}
|
||||
44
logic/service/fight/effect/effect_128.go
Normal file
44
logic/service/fight/effect/effect_128.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
func init() {
|
||||
t := &Effect128{
|
||||
EffectNode: node.EffectNode{},
|
||||
}
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 128, t)
|
||||
|
||||
}
|
||||
|
||||
type Effect128 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
// 默认添加回合
|
||||
func (e *Effect128) SetArgs(t *input.Input, a ...int) {
|
||||
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
|
||||
|
||||
}
|
||||
func (e *Effect128) DamageLock_ex(t *info.DamageZone) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
if t.Type != info.DamageType.Red {
|
||||
return true
|
||||
}
|
||||
|
||||
heal := t.Damage
|
||||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
|
||||
t.Damage = alpacadecimal.Zero
|
||||
return true
|
||||
}
|
||||
48
logic/service/fight/effect/effect_131.go
Normal file
48
logic/service/fight/effect/effect_131.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
/**
|
||||
* 131 对方为X性则免疫当前回合伤害
|
||||
* 参数说明:
|
||||
* Args[0] = X性别的数值定义(例如:0=无性别,1=雄性,2=雌性,根据业务实际枚举值调整)
|
||||
*/
|
||||
|
||||
// 初始化效果注册
|
||||
func init() {
|
||||
// 注册效果类型:Skill(与134保持一致)、效果ID=131、效果实例
|
||||
input.InitEffect(input.EffectType.Skill, 131, &Effect131{})
|
||||
}
|
||||
|
||||
// Effect131 效果131的结构体,嵌入基类获取通用能力
|
||||
type Effect131 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
// Damage_DIV_ex 受击前触发(核心伤害拦截节点)
|
||||
// 该方法在伤害计算前执行,适合修改/清零伤害实现免疫效果
|
||||
func (e *Effect131) DamageLock_ex(t *info.DamageZone) bool {
|
||||
// 1. 检查效果是否命中(未命中则不生效)
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
|
||||
// 3. 获取配置的目标性别X(Args[0]存储X性别的数值)
|
||||
xGender := e.Args()[0].IntPart()
|
||||
|
||||
// 4. 对比对手性别与目标性别,匹配则免疫伤害
|
||||
// 注:需确保BattlePetEntity的Gender字段类型为int/int8,与xGender类型匹配
|
||||
if int(e.Ctx().Opp.CurrentPet.Gender) == int(xGender) {
|
||||
// 将伤害置为0,实现当前回合伤害免疫
|
||||
t.Damage = alpacadecimal.NewFromInt(0)
|
||||
}
|
||||
|
||||
// 返回true表示允许后续流程继续(仅修改伤害值,不阻断流程)
|
||||
return true
|
||||
}
|
||||
34
logic/service/fight/effect/effect_145.go
Normal file
34
logic/service/fight/effect/effect_145.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 攻击中毒的对手时,自身回复1/n最大体力值
|
||||
type Effect145 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 145, &Effect145{})
|
||||
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect145) OnSkill() bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
if e.Ctx().Opp.StatEffect_Exist(info.PetStatus.Poisoned) {
|
||||
heal := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[0])
|
||||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
45
logic/service/fight/effect/effect_151.go
Normal file
45
logic/service/fight/effect/effect_151.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 攻击中毒的对手时,自身回复1/n最大体力值
|
||||
type Effect151 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 151, &Effect151{})
|
||||
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect151) OnSkill() bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
if e.Ctx().Opp.StatEffect_Exist(info.PetStatus.Burned) {
|
||||
chance := e.EffectNode.SideEffectArgs[0]
|
||||
success, _, _ := e.Input.Player.Roll(chance, 100)
|
||||
if !success {
|
||||
return true
|
||||
}
|
||||
|
||||
} else {
|
||||
chance := e.EffectNode.SideEffectArgs[1]
|
||||
success, _, _ := e.Input.Player.Roll(chance, 100)
|
||||
if !success {
|
||||
return true
|
||||
}
|
||||
}
|
||||
r := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Tired))
|
||||
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, r)
|
||||
return true
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func (e *Effect48) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
if in != e.Ctx().Opp {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().Our.IS_Stat(effEffect) {
|
||||
if input.IS_Stat(effEffect) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,19 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
type Effect129 struct {
|
||||
node.EffectNode
|
||||
StatusID int
|
||||
}
|
||||
|
||||
func (e *Effect129) Skill_Hit() bool {
|
||||
if e.Ctx().Opp.CurrentPet.Gender != e.SideEffectArgs[0] {
|
||||
return true
|
||||
}
|
||||
e.Ctx().SkillEntity.Power *= 2
|
||||
return true
|
||||
}
|
||||
|
||||
// 小助手函数,让注册看起来更自然
|
||||
func registerStatusFunc(id int, fn func(*input.Input, *input.Input) bool) {
|
||||
statusFuncRegistry.Register(id, fn)
|
||||
|
||||
@@ -61,7 +61,7 @@ type SkillEntity struct {
|
||||
Pet *BattlePetEntity
|
||||
//MaxValue func(ahp, bhp uint32) decimal.Decimal
|
||||
Crit uint32
|
||||
AttackTime uint32
|
||||
AttackTime uint32 //记录技能实际是否命中
|
||||
Side bool
|
||||
}
|
||||
|
||||
|
||||
@@ -128,29 +128,52 @@ type WeakenedS struct {
|
||||
}
|
||||
|
||||
// 定义战斗状态枚举
|
||||
// EnumPetStatus:宠物战斗异常/增益状态枚举,值范围 0-255
|
||||
var PetStatus = enum.New[struct {
|
||||
NULL EnumPetStatus `enum:"255"`
|
||||
Paralysis EnumPetStatus `enum:"0"` // 麻痹
|
||||
Poisoned EnumPetStatus `enum:"1"` // 中毒
|
||||
Burned EnumPetStatus `enum:"2"` // 烧伤
|
||||
DrainHP EnumPetStatus `enum:"3"` // 吸取对方的体力
|
||||
DrainedHP EnumPetStatus `enum:"4"` // 被对方吸取体力
|
||||
Frozen EnumPetStatus `enum:"5"` // 冻伤
|
||||
Fear EnumPetStatus `enum:"6"` // 害怕
|
||||
Tired EnumPetStatus `enum:"7"` // 疲惫
|
||||
Sleep EnumPetStatus `enum:"8"` // 睡眠
|
||||
Petrified EnumPetStatus `enum:"9"` // 石化
|
||||
Confused EnumPetStatus `enum:"10"` // 混乱
|
||||
Weakened EnumPetStatus `enum:"11"` // 衰弱
|
||||
MountainGodGuard EnumPetStatus `enum:"12"` // 山神守护
|
||||
Flammable EnumPetStatus `enum:"13"` // 易燃
|
||||
Berserk EnumPetStatus `enum:"14"` // 狂暴
|
||||
IceBound EnumPetStatus `enum:"15"` // 冰封
|
||||
Bleeding EnumPetStatus `enum:"16"` // 流血
|
||||
ImmuneToStatDrop EnumPetStatus `enum:"17"` // 免疫能力下降
|
||||
ImmuneToAbnormal EnumPetStatus `enum:"18"` // 免疫异常状态
|
||||
Paralyzed EnumPetStatus `enum:"19"` // 瘫痪
|
||||
// Blind EnumBattleStatus `enum:"20"` // 失明(预留)
|
||||
// 无状态(默认值)
|
||||
NULL EnumPetStatus `enum:"255"`
|
||||
// 麻痹:行动概率降低,有概率无法出手
|
||||
Paralysis EnumPetStatus `enum:"0"`
|
||||
// 中毒:每回合损失一定比例体力,持续至解除
|
||||
Poisoned EnumPetStatus `enum:"1"`
|
||||
// 烧伤:每回合损失体力,物理攻击威力降低50%
|
||||
Burned EnumPetStatus `enum:"2"`
|
||||
// 吸血:攻击时吸取对方体力回复自身(比例生效)
|
||||
DrainHP EnumPetStatus `enum:"3"`
|
||||
// 被吸血:自身体力被对方攻击时按比例被吸取
|
||||
DrainedHP EnumPetStatus `enum:"4"`
|
||||
// 冻伤:每回合损失体力,有概率无法行动,火系攻击可解除
|
||||
Frozen EnumPetStatus `enum:"5"`
|
||||
// 害怕:本回合完全无法进行攻击类操作
|
||||
Fear EnumPetStatus `enum:"6"`
|
||||
// 疲惫:连续使用同一技能后触发,暂时无法使用该技能
|
||||
Tired EnumPetStatus `enum:"7"`
|
||||
// 睡眠:无法行动,持续1-3回合后苏醒,受攻击可提前解除
|
||||
Sleep EnumPetStatus `enum:"8"`
|
||||
// 石化:无法行动,受到攻击时有概率解除,否则持续至回合结束
|
||||
Petrified EnumPetStatus `enum:"9"`
|
||||
// 混乱:行动时有概率攻击自身,持续若干回合后解除
|
||||
Confused EnumPetStatus `enum:"10"`
|
||||
// 衰弱:全属性降低,伤害输出减少,受治疗效果降低
|
||||
Weakened EnumPetStatus `enum:"11"`
|
||||
// 山神守护:免疫大部分异常状态,受到的所有伤害降低
|
||||
MountainGodGuard EnumPetStatus `enum:"12"`
|
||||
// 易燃:受到火系伤害翻倍,持续3回合或被火系攻击命中后解除
|
||||
Flammable EnumPetStatus `enum:"13"`
|
||||
// 狂暴:攻击属性提升,防御属性降低,无法自主选择攻击目标
|
||||
Berserk EnumPetStatus `enum:"14"`
|
||||
// 冰封:完全无法行动,持续固定回合数,仅特定技能可解除
|
||||
IceBound EnumPetStatus `enum:"15"`
|
||||
// 流血:每回合损失固定比例体力,无视部分防御效果
|
||||
Bleeding EnumPetStatus `enum:"16"`
|
||||
// 免疫能力下降:不会被敌方技能降低攻击/防御/速度等属性
|
||||
ImmuneToStatDrop EnumPetStatus `enum:"17"`
|
||||
// 免疫异常状态:不会被附加麻痹/中毒/烧伤等所有异常状态
|
||||
ImmuneToAbnormal EnumPetStatus `enum:"18"`
|
||||
// 瘫痪:完全无法行动,比麻痹效果更强,无概率解除
|
||||
Paralyzed EnumPetStatus `enum:"19"`
|
||||
// 失明(预留):命中概率大幅降低,技能命中率下降
|
||||
// Blind EnumBattleStatus `enum:"20"`
|
||||
}]()
|
||||
|
||||
// 枚举类型别名(根据实际枚举库要求定义)
|
||||
|
||||
@@ -154,7 +154,7 @@ func (our *Input) StatEffect_Exist_all() bool {
|
||||
}
|
||||
|
||||
// 判断是否是状态技能
|
||||
func (our *Input) IS_Stat(v Effect) bool {
|
||||
func IS_Stat(v Effect) bool {
|
||||
t := v.ID()
|
||||
if t.GetEffectType() == EffectType.Status {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user