292 lines
6.7 KiB
Go
292 lines
6.7 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 800: {0}回合内若对手使用属性技能,则下{1}回合自身受到的伤害不超过{2}
|
||
type Effect800 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect800) Skill_Use() bool {
|
||
if len(e.Args()) < 3 {
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 800, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect800Sub struct {
|
||
node.EffectNode
|
||
watchRounds int
|
||
capRounds int
|
||
capDamage alpacadecimal.Decimal
|
||
}
|
||
|
||
func (e *Effect800Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
if len(a) > 0 {
|
||
e.watchRounds = a[0]
|
||
}
|
||
if len(a) > 1 {
|
||
e.capRounds = 0
|
||
}
|
||
if len(a) > 2 {
|
||
e.capDamage = alpacadecimal.NewFromInt(int64(a[2]))
|
||
}
|
||
}
|
||
|
||
func (e *Effect800Sub) Skill_Use_ex() bool {
|
||
if e.watchRounds <= 0 || len(e.Args()) < 3 || e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
e.capRounds = int(e.Args()[1].IntPart())
|
||
return true
|
||
}
|
||
|
||
func (e *Effect800Sub) DamageLockEx(zone *info.DamageZone) bool {
|
||
if e.capRounds <= 0 || zone == nil || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
if zone.Damage.Cmp(e.capDamage) <= 0 {
|
||
return true
|
||
}
|
||
|
||
zone.Damage = e.capDamage
|
||
return true
|
||
}
|
||
|
||
func (e *Effect800Sub) TurnEnd() {
|
||
if e.watchRounds > 0 {
|
||
e.watchRounds--
|
||
}
|
||
if e.capRounds > 0 {
|
||
e.capRounds--
|
||
}
|
||
if e.watchRounds <= 0 && e.capRounds <= 0 {
|
||
e.Alive(false)
|
||
}
|
||
}
|
||
|
||
// Effect 801: 消除对手能力提升,消除成功则下{0}回合必定先出手、下{1}回合造成的伤害恢复自身体力
|
||
type Effect801 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect801) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || !clearPositiveProps(e.Ctx().Opp, e.Ctx().Our) {
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 801, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect801Sub struct {
|
||
node.EffectNode
|
||
priorityRounds int
|
||
drainRounds int
|
||
}
|
||
|
||
func (e *Effect801Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
if len(a) > 0 {
|
||
e.priorityRounds = a[0]
|
||
}
|
||
if len(a) > 1 {
|
||
e.drainRounds = a[1]
|
||
}
|
||
}
|
||
|
||
func (e *Effect801Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if e.priorityRounds <= 0 {
|
||
return true
|
||
}
|
||
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil {
|
||
return true
|
||
}
|
||
current.SkillEntity.XML.Priority = 999999
|
||
return true
|
||
}
|
||
|
||
func (e *Effect801Sub) Action_end() bool {
|
||
if e.drainRounds <= 0 || e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage)
|
||
return true
|
||
}
|
||
|
||
func (e *Effect801Sub) TurnEnd() {
|
||
if e.priorityRounds > 0 {
|
||
e.priorityRounds--
|
||
}
|
||
if e.drainRounds > 0 {
|
||
e.drainRounds--
|
||
}
|
||
if e.priorityRounds <= 0 && e.drainRounds <= 0 {
|
||
e.Alive(false)
|
||
}
|
||
}
|
||
|
||
// Effect 802: {0}回合内免疫控制类异常状态
|
||
type Effect802 struct {
|
||
RoundEffectArg0Base
|
||
}
|
||
|
||
func (e *Effect802) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||
if in != e.Ctx().Opp || !input.IS_Stat(effEffect) {
|
||
return true
|
||
}
|
||
if !isControlStatus800(statusIDFromEffect800(effEffect)) {
|
||
return true
|
||
}
|
||
return false
|
||
}
|
||
|
||
func statusIDFromEffect800(eff input.Effect) int {
|
||
if eff == nil {
|
||
return 0
|
||
}
|
||
return int(eff.ID().Suffix())
|
||
}
|
||
|
||
func isControlStatus800(statusID int) bool {
|
||
switch info.EnumPetStatus(statusID) {
|
||
case info.PetStatus.Paralysis,
|
||
info.PetStatus.Tired,
|
||
info.PetStatus.Fear,
|
||
info.PetStatus.Petrified,
|
||
info.PetStatus.Sleep:
|
||
return true
|
||
default:
|
||
return false
|
||
}
|
||
}
|
||
|
||
// Effect 803: 命中后{0}%令对手{1},未触发则恢复自身最大体力的1/{2}体力且{3}回合内自身受到的伤害不超过{4}
|
||
type Effect803 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect803) OnSkill() bool {
|
||
if len(e.Args()) < 5 {
|
||
return true
|
||
}
|
||
|
||
success, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
|
||
if success {
|
||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
||
return true
|
||
}
|
||
if e.Args()[2].Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurPet[0].GetMaxHP().Div(e.Args()[2]))
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 803, int(e.Args()[3].IntPart()), int(e.Args()[4].IntPart()))
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect803Sub struct {
|
||
RoundEffectArg0Base
|
||
}
|
||
|
||
func (e *Effect803Sub) DamageLockEx(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
if zone.Damage.Cmp(e.Args()[1]) <= 0 {
|
||
return true
|
||
}
|
||
zone.Damage = e.Args()[1]
|
||
return true
|
||
}
|
||
|
||
// Effect 804: {0}回合内自身能力提升状态被消除或吸取时,令对手全属性-{1}
|
||
type Effect804 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect804) Skill_Use() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 804, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect804Sub struct {
|
||
RoundEffectArg0Base
|
||
triggered bool
|
||
}
|
||
|
||
func (e *Effect804Sub) PropBefer(in *input.Input, prop int8, level int8) bool {
|
||
if len(e.Args()) < 2 || in != e.Ctx().Our || e.triggered {
|
||
return true
|
||
}
|
||
if int(prop) < 0 || int(prop) >= len(e.Ctx().Our.Prop) {
|
||
return true
|
||
}
|
||
if level > 0 || e.Ctx().Our.Prop[prop] <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.triggered = true
|
||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[1].IntPart()))
|
||
return true
|
||
}
|
||
|
||
func (e *Effect804Sub) Action_end() bool {
|
||
e.triggered = false
|
||
return true
|
||
}
|
||
|
||
func (e *Effect804Sub) Action_end_ex() bool {
|
||
e.triggered = false
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 800, &Effect800{})
|
||
input.InitEffect(input.EffectType.Sub, 800, &Effect800Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 801, &Effect801{})
|
||
input.InitEffect(input.EffectType.Sub, 801, &Effect801Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 802, &Effect802{})
|
||
input.InitEffect(input.EffectType.Skill, 803, &Effect803{})
|
||
input.InitEffect(input.EffectType.Sub, 803, &Effect803Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 804, &Effect804{})
|
||
input.InitEffect(input.EffectType.Sub, 804, &Effect804Sub{})
|
||
}
|