Files
bl/logic/service/fight/effect/effect_119_123.go
昔念 85f15a72aa ```
refactor(fight): 统一战斗系统方法命名规范并优化逻辑

- 将所有下划线命名的方法统一为驼峰命名,如 Turn_Start 改为 TurnStart,
  Action_end_ex 改为 ActionEndEx,Turn_End 改为 TurnEnd
- 新增 IsOwner() 方法用于判断当前精灵是否为场上的当前宠物
- 将硬编码的 CatchTime 比较逻辑替换为 IsOwner() 方法调用
- 在 NewSel408 中实现消除对手能力强化效果的具体逻辑
- 修复 effect_74 中衰弱状态的数值引用,使用枚举类型代替硬编码
- 优化 input/fight.go 中的技能选择逻辑,使用伤害值比较代替权重比较
- 移除 shiny.go 中未使用的 utils 导入和相关逻辑
- 修正 NewSel77 从 Turn_End 重命名为 TurnStart 的方法
- 在 input/fight.go 中添加 Damage 方法的注释说明
```
2026-01-05 22:54:41 +08:00

197 lines
5.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
)
// -----------------------------------------------------------
// 效果119若伤害为奇数30%对手疲惫1回合若为偶数30%速度+1
// -----------------------------------------------------------
type Effect119 struct {
node.EffectNode
can bool
}
func (e *Effect119) OnSkill() bool {
e.can = true
return true
}
func (e *Effect119) DamageLock(damageValue *info.DamageZone) bool {
if !e.can {
return true
}
isOdd := damageValue.Damage.IntPart()%2 == 1
if isOdd {
// 奇数30%对手疲惫1回合
ok, _, _ := e.Input.Player.Roll(30, 100)
if ok {
eff := input.Geteffect(input.EffectType.Status, int(info.PetStatus.Tired))
if eff == nil {
return true
}
eff.Duration(1)
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
}
} else {
// 偶数30%速度+1
ok, _, _ := e.Input.Player.Roll(30, 100)
if ok {
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1, info.AbilityOpType.ADD)
}
}
e.can = false
return true
}
func (e *Effect119) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(1)
}
// -----------------------------------------------------------
// 效果12050%概率对方减血1/{0}50%概率自己减血1/{0}
// -----------------------------------------------------------
type Effect120 struct {
node.EffectNode
}
func (e *Effect120) OnSkill() bool {
// 50%概率
ok, _, _ := e.Input.Player.Roll(50, 100)
denominator := int(e.Args()[0].IntPart())
percent := alpacadecimal.NewFromInt(100).Div(alpacadecimal.NewFromInt(int64(denominator)))
if ok {
// 对方减血1/{0}
oppMaxHP := alpacadecimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.MaxHp))
damage := oppMaxHP.Mul(percent).Div(alpacadecimal.NewFromInt(100))
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
} else {
// 自己减血1/{0}
ourMaxHP := alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp))
damage := ourMaxHP.Mul(percent).Div(alpacadecimal.NewFromInt(100))
e.Ctx().Our.Damage(e.Ctx().Opp, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
}
return true
}
// -----------------------------------------------------------
// 效果121属性相同时{0}%概率让对方麻痹
// -----------------------------------------------------------
type Effect121 struct {
node.EffectNode
}
func (e *Effect121) OnSkill() bool {
// 检查属性是否相同
if e.Ctx().Our.CurrentPet.PetInfo.Type == e.Ctx().Opp.CurrentPet.PetInfo.Type {
chance := int(e.Args()[0].IntPart())
ok, _, _ := e.Input.Player.Roll(chance, 100)
if ok {
eff := input.Geteffect(input.EffectType.Status, int(info.PetStatus.Paralysis))
if eff == nil {
return true
}
duration := int(e.Input.FightC.GetRand().Int31n(2))
duration++
eff.Duration(duration)
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
}
}
return true
}
// -----------------------------------------------------------
// 效果122先出手时{1}%改变对方{0}等级{2}
// -----------------------------------------------------------
type Effect122 struct {
node.EffectNode
can bool
}
func (e *Effect122) SkillHit() bool {
if e.Input.FightC.IsFirst(e.Input.Player) {
e.can = true
}
return true
}
func (e *Effect122) OnSkill() bool {
if e.can {
propIndex := int(e.Args()[0].IntPart())
chance := int(e.Args()[1].IntPart())
changeAmount := int(e.Args()[2].IntPart())
ok, _, _ := e.Input.Player.Roll(chance, 100)
if ok {
opType := info.AbilityOpType.ADD
if changeAmount < 0 {
opType = info.AbilityOpType.SUB
}
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(propIndex), int8(changeAmount), opType)
}
e.can = false
}
return true
}
// -----------------------------------------------------------
// 效果123{0}回合内受到任何伤害,自身{1}提高{2}个等级
// -----------------------------------------------------------
type Effect123 struct {
node.EffectNode
roundCount int
can bool
}
func (e *Effect123) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.roundCount = e.EffectNode.SideEffectArgs[0]
}
func (e *Effect123) TurnStart(at, de *action.SelectSkillAction) {
if e.roundCount > 0 {
e.can = true
e.roundCount--
}
}
func (e *Effect123) Be_Damage(at, _ alpacadecimal.Decimal) {
if e.can {
propIndex := int(e.Args()[1].IntPart())
changeAmount := int(e.Args()[2].IntPart())
e.Ctx().Our.SetProp(e.Ctx().Our, int8(propIndex), int8(changeAmount), info.AbilityOpType.ADD)
e.can = false
}
}
// -----------------------------------------------------------
// 初始化
// -----------------------------------------------------------
func init() {
input.InitEffect(input.EffectType.Skill, 119, &Effect119{})
input.InitEffect(input.EffectType.Skill, 120, &Effect120{})
input.InitEffect(input.EffectType.Skill, 121, &Effect121{})
input.InitEffect(input.EffectType.Skill, 122, &Effect122{})
input.InitEffect(input.EffectType.Skill, 123, &Effect123{})
}