164 lines
3.5 KiB
Go
164 lines
3.5 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"
|
||
)
|
||
|
||
func activeTurnEffectCount(in *input.Input) int {
|
||
if in == nil {
|
||
return 0
|
||
}
|
||
|
||
count := 0
|
||
for _, effect := range in.Effects {
|
||
if effect == nil || !effect.Alive() {
|
||
continue
|
||
}
|
||
if effect.Duration() > 0 {
|
||
count++
|
||
}
|
||
}
|
||
return count
|
||
}
|
||
|
||
func totalOppPropDownLevels(in *input.Input) int64 {
|
||
if in == nil {
|
||
return 0
|
||
}
|
||
|
||
total := int64(0)
|
||
for _, v := range in.Prop[:] {
|
||
if v < 0 {
|
||
total += int64(-v)
|
||
}
|
||
}
|
||
return total
|
||
}
|
||
|
||
// Effect 856: 消除对手回合类效果,消除成功则恢复自身最大体力的1/{0}
|
||
type Effect856 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect856) Skill_Use() bool {
|
||
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
before := activeTurnEffectCount(e.Ctx().Opp)
|
||
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
|
||
if before <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Heal(
|
||
e.Ctx().Our,
|
||
&action.SelectSkillAction{},
|
||
e.Ctx().Our.CurPet[0].GetMaxHP().Div(e.Args()[0]),
|
||
)
|
||
return true
|
||
}
|
||
|
||
// Effect 857: {0}%使对手全属性-{1},若先出手则{2}%使对手全属性-{3}
|
||
type Effect857 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect857) Skill_Use() bool {
|
||
if len(e.Args()) < 4 {
|
||
return true
|
||
}
|
||
|
||
success, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
|
||
if success {
|
||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[1].IntPart()))
|
||
}
|
||
|
||
if e.IsFirst() {
|
||
firstSuccess, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100)
|
||
if firstSuccess {
|
||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[3].IntPart()))
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 858: 造成的伤害提升,伤害提升的倍数等于对手能力下降等级总和乘以{0}%
|
||
type Effect858 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect858) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
|
||
totalDown := totalOppPropDownLevels(e.Ctx().Opp)
|
||
if totalDown <= 0 {
|
||
return true
|
||
}
|
||
|
||
percent := e.Args()[0].Mul(alpacadecimal.NewFromInt(totalDown))
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(100).Add(percent)).Div(alpacadecimal.NewFromInt(100))
|
||
return true
|
||
}
|
||
|
||
// Effect 859: 吸收对手能力提升,吸收成功减少对手1/{0}最大体力
|
||
type Effect859 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect859) OnSkill() bool {
|
||
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
canSteal := false
|
||
for i, v := range e.Ctx().Opp.Prop[:] {
|
||
if v <= 0 {
|
||
continue
|
||
}
|
||
if e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0) {
|
||
canSteal = true
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
|
||
}
|
||
}
|
||
if !canSteal {
|
||
return true
|
||
}
|
||
|
||
damage := e.Ctx().Opp.CurPet[0].GetMaxHP().Div(e.Args()[0])
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
return true
|
||
}
|
||
|
||
// Effect 860: 获得{0}层神耀能量
|
||
type Effect860 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect860) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.AddDivineEnergy(int(e.Args()[0].IntPart()))
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 856, &Effect856{})
|
||
input.InitEffect(input.EffectType.Skill, 857, &Effect857{})
|
||
input.InitEffect(input.EffectType.Skill, 858, &Effect858{})
|
||
input.InitEffect(input.EffectType.Skill, 859, &Effect859{})
|
||
input.InitEffect(input.EffectType.Skill, 860, &Effect860{})
|
||
}
|