207 lines
5.1 KiB
Go
207 lines
5.1 KiB
Go
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"
|
|
)
|
|
|
|
// Effect 1137: 自身体力低于1/{0}时吸取对手最大体力的1/{1}
|
|
type Effect1137 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect1137) OnSkill() bool {
|
|
if len(e.Args()) < 2 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 || e.Args()[1].Cmp(alpacadecimal.Zero) <= 0 {
|
|
return true
|
|
}
|
|
|
|
threshold := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[0])
|
|
if e.Ctx().Our.CurrentPet.GetHP().Cmp(threshold) >= 0 {
|
|
return true
|
|
}
|
|
|
|
drain := e.Ctx().Opp.CurrentPet.GetMaxHP().Div(e.Args()[1])
|
|
if drain.Cmp(alpacadecimal.Zero) <= 0 {
|
|
return true
|
|
}
|
|
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
|
Type: info.DamageType.Percent,
|
|
Damage: drain,
|
|
})
|
|
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, drain)
|
|
return true
|
|
}
|
|
|
|
// Effect 1138: 消除对手回合类效果,消除成功则{0}%令对手{1},未触发则{2}%令对手{3}
|
|
type Effect1138 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect1138) Skill_Use() bool {
|
|
if len(e.Args()) < 4 {
|
|
return true
|
|
}
|
|
|
|
before := activeTurnEffectCount(e.Ctx().Opp)
|
|
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
|
|
if before <= 0 {
|
|
return true
|
|
}
|
|
|
|
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
|
|
applyStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
|
return true
|
|
}
|
|
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100); ok {
|
|
applyStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[3].IntPart()))
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Effect 1139: 消除敌我双方回合类效果并同时进入{0}回合{1},自身{2}状态解除后则恢复自身所有体力
|
|
type Effect1139 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect1139) Skill_Use() bool {
|
|
if len(e.Args()) < 3 {
|
|
return true
|
|
}
|
|
|
|
e.Ctx().Our.CancelTurn(e.Ctx().Our)
|
|
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
|
|
|
|
duration := int(e.Args()[0].IntPart())
|
|
statusID := int(e.Args()[1].IntPart())
|
|
if duration > 0 {
|
|
addTimedStatus(e.Ctx().Our, e.Ctx().Our, statusID, duration)
|
|
addTimedStatus(e.Ctx().Our, e.Ctx().Opp, statusID, duration)
|
|
}
|
|
|
|
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1139, int(e.Args()[2].IntPart()))
|
|
if sub != nil {
|
|
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
|
}
|
|
return true
|
|
}
|
|
|
|
type Effect1139Sub struct {
|
|
node.EffectNode
|
|
statusID int
|
|
}
|
|
|
|
func (e *Effect1139Sub) SetArgs(t *input.Input, a ...int) {
|
|
e.EffectNode.SetArgs(t, a...)
|
|
e.Duration(-1)
|
|
if len(a) > 0 {
|
|
e.statusID = a[0]
|
|
}
|
|
}
|
|
|
|
func (e *Effect1139Sub) TurnEnd() {
|
|
if e.statusID > 0 && !e.Ctx().Our.StatEffect_Exist(info.EnumPetStatus(e.statusID)) {
|
|
missing := e.Ctx().Our.CurrentPet.GetMaxHP().Sub(e.Ctx().Our.CurrentPet.GetHP())
|
|
if missing.Cmp(alpacadecimal.Zero) > 0 {
|
|
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, missing)
|
|
}
|
|
e.Alive(false)
|
|
return
|
|
}
|
|
e.EffectNode.TurnEnd()
|
|
}
|
|
|
|
// Effect 1140: {0}回合内对手使用攻击技能则{1}
|
|
type Effect1140 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect1140) Skill_Use() bool {
|
|
if len(e.Args()) < 2 {
|
|
return true
|
|
}
|
|
|
|
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1140, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
|
|
if sub != nil {
|
|
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
|
}
|
|
return true
|
|
}
|
|
|
|
type Effect1140Sub struct {
|
|
RoundEffectArg0Base
|
|
}
|
|
|
|
func (e *Effect1140Sub) Skill_Use() bool {
|
|
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
|
|
applyStatusByID(e.Ctx().Opp, e.Ctx().Our, int(e.Args()[1].IntPart()))
|
|
return true
|
|
}
|
|
|
|
// Effect 1141: 1回合做{0}~{1}次攻击,每次攻击{2}%令对手{3},攻击低于{4}次则每次攻击{5}%令对手{6}
|
|
type Effect1141 struct {
|
|
node.EffectNode
|
|
hits int
|
|
}
|
|
|
|
func (e *Effect1141) Skill_Use() bool {
|
|
if len(e.Args()) < 7 {
|
|
return true
|
|
}
|
|
|
|
minHits := int(e.Args()[0].IntPart())
|
|
maxHits := int(e.Args()[1].IntPart())
|
|
if maxHits < minHits {
|
|
maxHits = minHits
|
|
}
|
|
if minHits <= 0 {
|
|
minHits = 1
|
|
}
|
|
|
|
e.hits = minHits
|
|
if maxHits > minHits {
|
|
e.hits += grand.Intn(maxHits - minHits + 1)
|
|
}
|
|
if e.Ctx().SkillEntity != nil {
|
|
e.Ctx().SkillEntity.XML.AtkNum = e.hits
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (e *Effect1141) OnSkill() bool {
|
|
if len(e.Args()) < 7 || e.hits <= 0 {
|
|
return true
|
|
}
|
|
|
|
chance := int(e.Args()[2].IntPart())
|
|
statusID := int(e.Args()[3].IntPart())
|
|
if e.hits < int(e.Args()[4].IntPart()) {
|
|
chance = int(e.Args()[5].IntPart())
|
|
statusID = int(e.Args()[6].IntPart())
|
|
}
|
|
|
|
for i := 0; i < e.hits; i++ {
|
|
if ok, _, _ := e.Input.Player.Roll(chance, 100); ok {
|
|
applyStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 1137, &Effect1137{})
|
|
input.InitEffect(input.EffectType.Skill, 1138, &Effect1138{})
|
|
input.InitEffect(input.EffectType.Skill, 1139, &Effect1139{})
|
|
input.InitEffect(input.EffectType.Sub, 1139, &Effect1139Sub{})
|
|
input.InitEffect(input.EffectType.Skill, 1140, &Effect1140{})
|
|
input.InitEffect(input.EffectType.Sub, 1140, &Effect1140Sub{})
|
|
input.InitEffect(input.EffectType.Skill, 1141, &Effect1141{})
|
|
}
|