Files
bl/logic/service/fight/effect/754_758.go
xinian 9c6f3988de
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构 CurrentPet 为 CurPet
2026-04-04 04:34:43 +08:00

226 lines
5.5 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"
"github.com/gogf/gf/v2/util/grand"
)
var oneDecimal = alpacadecimal.NewFromInt(1)
// Effect 754: 消耗自身全部体力,使下只出场精灵前{0}回合必定先手必定暴击必定命中
type Effect754 struct {
node.EffectNode
armed bool
started bool
remaining int
}
func (e *Effect754) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
if len(a) > 0 {
e.remaining = a[0]
}
}
func (e *Effect754) OnSkill() bool {
if e.armed {
return true
}
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Ctx().Our.CurPet[0].GetMaxHP(),
})
e.armed = true
return true
}
func (e *Effect754) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !e.armed || e.remaining <= 0 {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil {
return true
}
e.started = true
current.SkillEntity.XML.Priority += 7
return true
}
func (e *Effect754) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.armed || e.remaining <= 0 || e.Ctx().SkillEntity == nil {
return true
}
e.started = true
e.Ctx().SkillEntity.XML.MustHit = 1
if e.Ctx().SkillEntity.Category() != info.Category.STATUS {
e.Ctx().SkillEntity.XML.CritRate = 16
}
return true
}
func (e *Effect754) TurnEnd() {
if !e.started || e.remaining <= 0 {
return
}
e.remaining--
if e.remaining <= 0 {
e.Alive(false)
}
}
// Effect 755: 比较双方体力后自灭并造成随机固定伤害低体力分支保留对手1点体力并附加状态
type Effect755 struct {
node.EffectNode
}
func (e *Effect755) OnSkill() bool {
if len(e.Args()) < 6 {
return true
}
ourHP := e.Ctx().Our.CurPet[0].GetHP()
oppHP := e.Ctx().Opp.CurPet[0].GetHP()
if ourHP.Cmp(oppHP) > 0 {
e.Ctx().Our.CurPet[0].Info.Hp = 1
damage := randomInRange(int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(damage)),
})
return true
}
e.Ctx().Our.CurPet[0].Info.Hp = 0
damage := alpacadecimal.NewFromInt(int64(randomInRange(int(e.Args()[2].IntPart()), int(e.Args()[3].IntPart()))))
cap := oppHP.Sub(oneDecimal)
if cap.Cmp(alpacadecimal.Zero) < 0 {
cap = alpacadecimal.Zero
}
damage = alpacadecimal.Min(damage, cap)
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
}
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[4].IntPart()))
if statusEffect != nil {
if e.Args()[5].IntPart() != 0 {
statusEffect.SetArgs(e.Ctx().Our, int(e.Args()[5].IntPart()))
}
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
return true
}
// Effect 756: 命中后{0}%令对手{1}
type Effect756 struct {
node.EffectNode
}
func (e *Effect756) OnSkill() bool {
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
if !success {
return true
}
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[1].IntPart()))
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
return true
}
// Effect 757: 当次攻击击败指定状态的对手则对手下只出场精灵{1}%概率{2}
type Effect757 struct {
node.EffectNode
pending bool
}
func (e *Effect757) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
}
func (e *Effect757) Skill_Use() bool {
if len(e.Args()) < 3 || e.Ctx().Opp.CurPet[0].Info.Hp > 0 || !e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) {
e.Alive(false)
return true
}
e.pending = true
return true
}
func (e *Effect757) SwitchIn(in *input.Input) bool {
if !e.pending || in != e.Ctx().Opp {
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
if success {
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[2].IntPart()))
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
e.pending = false
e.Alive(false)
return true
}
// Effect 758: 使用时若有一方处于{0}状态,则必定威力翻倍
type Effect758 struct {
node.EffectNode
}
func (e *Effect758) SkillHit() bool {
if len(e.Args()) == 0 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
statusID := info.EnumPetStatus(e.Args()[0].IntPart())
if !e.Ctx().Our.StatEffect_Exist(statusID) && !e.Ctx().Opp.StatEffect_Exist(statusID) {
return true
}
e.Ctx().SkillEntity.XML.Power *= 2
return true
}
func randomInRange(minValue, maxValue int) int {
if maxValue < minValue {
maxValue = minValue
}
if maxValue == minValue {
return minValue
}
return minValue + grand.Intn(maxValue-minValue+1)
}
func init() {
input.InitEffect(input.EffectType.Skill, 754, &Effect754{})
input.InitEffect(input.EffectType.Skill, 755, &Effect755{})
input.InitEffect(input.EffectType.Skill, 756, &Effect756{})
input.InitEffect(input.EffectType.Skill, 757, &Effect757{})
input.InitEffect(input.EffectType.Skill, 758, &Effect758{})
}