97 lines
2.4 KiB
Go
97 lines
2.4 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/action"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// Effect 615: {0}回合内使用技能恢复{1}点体力,体力低于1/{2}时恢复至满
|
||
type Effect615 struct {
|
||
RoundEffectArg0Base
|
||
}
|
||
|
||
func (e *Effect615) OnSkill() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
|
||
healAmount := e.Args()[1]
|
||
if len(e.Args()) > 2 && e.Args()[2].Cmp(alpacadecimal.Zero) > 0 {
|
||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
threshold := maxHP.Div(e.Args()[2])
|
||
if e.Ctx().Our.CurrentPet.GetHP().Cmp(threshold) < 0 {
|
||
healAmount = maxHP
|
||
}
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
|
||
return true
|
||
}
|
||
|
||
// Effect 616: 当自身血量少于1/3时先制+2
|
||
type Effect616 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect616) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if len(e.Args()) < 2 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
if e.Ctx().Our.CurrentPet.GetHP().Mul(e.Args()[0]).Cmp(maxHP) >= 0 {
|
||
return true
|
||
}
|
||
|
||
current.SkillEntity.XML.Priority += int(e.Args()[1].IntPart())
|
||
return true
|
||
}
|
||
|
||
// Effect 619: 下{0}回合令对手所有技能先制-{1}
|
||
type Effect619 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect619) Skill_Use() bool {
|
||
effect := e.Ctx().Our.InitEffect(
|
||
input.EffectType.Sub,
|
||
619,
|
||
e.SideEffectArgs...,
|
||
)
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect619Sub struct {
|
||
RoundEffectArg0Base
|
||
}
|
||
|
||
func (e *Effect619Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
priorityDown := int(e.Args()[1].IntPart())
|
||
|
||
if fattack != nil && fattack.PlayerID == e.Ctx().Opp.UserID && fattack.SkillEntity != nil {
|
||
fattack.SkillEntity.XML.Priority -= priorityDown
|
||
}
|
||
if sattack != nil && sattack.PlayerID == e.Ctx().Opp.UserID && sattack.SkillEntity != nil {
|
||
sattack.SkillEntity.XML.Priority -= priorityDown
|
||
}
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 615, &Effect615{})
|
||
input.InitEffect(input.EffectType.Skill, 616, &Effect616{})
|
||
input.InitEffect(input.EffectType.Skill, 619, &Effect619{})
|
||
input.InitEffect(input.EffectType.Sub, 619, &Effect619Sub{})
|
||
}
|