177 lines
4.5 KiB
Go
177 lines
4.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"
|
||
)
|
||
|
||
// Effect 886: 下次攻击忽略对手双防值的{0}%
|
||
type Effect886 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect886) Skill_Use() bool {
|
||
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect886Sub{}, -1)
|
||
return true
|
||
}
|
||
|
||
type Effect886Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect886Sub) CalculatePre() bool {
|
||
if len(e.Args()) == 0 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
if !e.IsOwner() {
|
||
return true
|
||
}
|
||
if e.Ctx().Opp == nil || e.Ctx().Opp.CurPet[0] == nil {
|
||
return true
|
||
}
|
||
|
||
percent := e.Args()[0].IntPart()
|
||
if percent <= 0 {
|
||
return true
|
||
}
|
||
if percent > 100 {
|
||
percent = 100
|
||
}
|
||
|
||
remain := alpacadecimal.NewFromInt(100 - percent)
|
||
base := alpacadecimal.NewFromInt(100)
|
||
|
||
if e.Ctx().SkillEntity.Category() == info.Category.PHYSICAL {
|
||
def := alpacadecimal.NewFromInt(int64(e.Ctx().Opp.CurPet[0].Info.Prop[2]))
|
||
e.Ctx().Opp.CurPet[0].Info.Prop[2] = uint32(def.Mul(remain).Div(base).IntPart())
|
||
} else if e.Ctx().SkillEntity.Category() == info.Category.SPECIAL {
|
||
spDef := alpacadecimal.NewFromInt(int64(e.Ctx().Opp.CurPet[0].Info.Prop[4]))
|
||
e.Ctx().Opp.CurPet[0].Info.Prop[4] = uint32(spDef.Mul(remain).Div(base).IntPart())
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 887: 吸收对手能力提升状态,吸收成功则回复满体力并在下回合先制+{0}
|
||
type Effect887 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect887) Skill_Use() bool {
|
||
absorbed := false
|
||
for i, v := range e.Ctx().Opp.Prop[:] {
|
||
if v <= 0 {
|
||
continue
|
||
}
|
||
if !e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0) {
|
||
continue
|
||
}
|
||
absorbed = true
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
|
||
}
|
||
if !absorbed {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurPet[0].GetMaxHP())
|
||
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect887Sub{}, -1)
|
||
return true
|
||
}
|
||
|
||
type Effect887Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect887Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil {
|
||
return true
|
||
}
|
||
current.SkillEntity.XML.Priority += int(e.Args()[0].IntPart())
|
||
return true
|
||
}
|
||
|
||
// Effect 888: 若行动时自身体力低于对手,则回合结束时减少对手1/{0}最大体力
|
||
type Effect888 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect888) Skill_Use() bool {
|
||
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
if e.Ctx().Our.CurPet[0].GetHP().Cmp(e.Ctx().Opp.CurPet[0].GetHP()) >= 0 {
|
||
return true
|
||
}
|
||
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect888Sub{}, -1)
|
||
return true
|
||
}
|
||
|
||
type Effect888Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect888Sub) TurnEnd() {
|
||
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
e.EffectNode.TurnEnd()
|
||
return
|
||
}
|
||
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,
|
||
})
|
||
e.EffectNode.TurnEnd()
|
||
}
|
||
|
||
// Effect 889: 消除对手回合类效果,成功则令对手{0}
|
||
type Effect889 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect889) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
before := activeTurnEffectCount(e.Ctx().Opp)
|
||
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
|
||
if before <= 0 {
|
||
return true
|
||
}
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[0].IntPart()))
|
||
if statusEffect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 890: 自身处于能力提升状态时,造成伤害翻倍
|
||
type Effect890 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect890) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
if !e.Ctx().Our.HasPropADD() {
|
||
return true
|
||
}
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(2))
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 886, &Effect886{})
|
||
input.InitEffect(input.EffectType.Sub, 886, &Effect886Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 887, &Effect887{})
|
||
input.InitEffect(input.EffectType.Sub, 887, &Effect887Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 888, &Effect888{})
|
||
input.InitEffect(input.EffectType.Sub, 888, &Effect888Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 889, &Effect889{})
|
||
input.InitEffect(input.EffectType.Skill, 890, &Effect890{})
|
||
}
|