Files
bl/logic/service/fight/effect/effect_119_123.go
xinian 3dd2d40c50
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
feat: 新增多个战斗技能效果实现
2026-03-08 10:34:23 +08:00

162 lines
4.3 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 := e.Ctx().Our.InitEffect(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.Percent,
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.Percent,
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 := e.Ctx().Our.InitEffect(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
}
// -----------------------------------------------------------
// 效果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, 123, &Effect123{})
}