488 lines
15 KiB
Go
488 lines
15 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/common/data/xmlres"
|
||
"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"
|
||
)
|
||
|
||
func clearOppTurnEffects(owner, target *input.Input) bool {
|
||
if owner == nil || target == nil {
|
||
return false
|
||
}
|
||
cleared := false
|
||
for _, eff := range target.Effects {
|
||
if eff != nil && eff.Alive() {
|
||
eff.Alive(false)
|
||
cleared = true
|
||
}
|
||
}
|
||
return cleared
|
||
}
|
||
|
||
func addStatus(owner, target *input.Input, statusID int) bool {
|
||
if owner == nil || target == nil {
|
||
return false
|
||
}
|
||
eff := owner.InitEffect(input.EffectType.Status, statusID)
|
||
if eff == nil {
|
||
return false
|
||
}
|
||
target.AddEffect(owner, eff)
|
||
return true
|
||
}
|
||
|
||
// Effect 1970: 若自身未持有回体则为自身附加持续{0}回合的回体,若自身已持有回体则将回体数刷新至{1}回合
|
||
type Effect1970 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1970) Skill_Use() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1970, e.SideEffectArgs...)
|
||
if eff != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1970Sub struct {
|
||
RoundEffectArg0Base
|
||
}
|
||
|
||
func (e *Effect1970Sub) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if len(e.Args()) < 2 {
|
||
return
|
||
}
|
||
if e.Duration() <= 0 {
|
||
e.Duration(int(e.Args()[0].IntPart()))
|
||
return
|
||
}
|
||
e.Duration(int(e.Args()[1].IntPart()))
|
||
}
|
||
|
||
// Effect 1971: 未击败对手则解放自身回体和对手当前持有的失体,解放成功任意一项则令对手下回合无法主动切换精灵且先制效果失效
|
||
type Effect1971 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1971) Skill_Use() bool {
|
||
cleared := clearOppTurnEffects(e.Ctx().Our, e.Ctx().Opp)
|
||
if cleared {
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1971)
|
||
if eff != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1971Sub struct{ node.EffectNode }
|
||
|
||
func (e *Effect1971Sub) SwitchOut(in *input.Input) bool {
|
||
return in != e.Ctx().Opp
|
||
}
|
||
|
||
func (e *Effect1971Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if current := actionByPlayer(fattack, sattack, e.Ctx().Opp.UserID); current != nil && current.SkillEntity != nil {
|
||
current.SkillEntity.XML.Priority = 0
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1972: 对方场下每死亡一只精灵则附加给对手{0}点固定伤害
|
||
type Effect1972 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1972) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
dead := 0
|
||
for _, pet := range e.Ctx().Opp.AllPet {
|
||
if pet != nil && !pet.Alive() {
|
||
dead++
|
||
}
|
||
}
|
||
if dead > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: alpacadecimal.NewFromInt(int64(dead) * e.Args()[0].IntPart()),
|
||
})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1973: 若自身未持有拥君之瞳则开启拥君之瞳,若自身未持有绝缘之僵则开启绝缘之僵
|
||
type Effect1973 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1973) Skill_Use() bool {
|
||
e.Ctx().Our.AddShield(alpacadecimal.NewFromInt(0))
|
||
return true
|
||
}
|
||
|
||
// Effect 1974: 消除对手能力提升状态,消除成功则恢复自身所有技能PP值
|
||
type Effect1974 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1974) Skill_Use() bool {
|
||
removed := false
|
||
for _, eff := range e.Ctx().Opp.Effects {
|
||
if eff != nil && eff.Alive() {
|
||
eff.Alive(false)
|
||
removed = true
|
||
}
|
||
}
|
||
if !removed {
|
||
return true
|
||
}
|
||
for i := range e.Ctx().Our.CurPet[0].Info.SkillList {
|
||
if skill, ok := xmlres.SkillMap[int(e.Ctx().Our.CurPet[0].Info.SkillList[i].ID)]; ok {
|
||
e.Ctx().Our.CurPet[0].Info.SkillList[i].PP = uint32(skill.MaxPP)
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1975: {0}回合内每回合{1}%闪避对手攻击,若对手攻击技能命中则令对手随机进入{2}或{3}中的1种异常状态
|
||
type Effect1975 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1975) Skill_Use() bool {
|
||
if len(e.Args()) < 4 {
|
||
return true
|
||
}
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1975, e.SideEffectArgs...)
|
||
if eff != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1975Sub struct{ RoundEffectArg0Base }
|
||
|
||
func (e *Effect1975Sub) SkillHit_ex() bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
|
||
e.Ctx().SkillEntity.SetMiss()
|
||
return true
|
||
}
|
||
statuses := []int{int(e.Args()[2].IntPart()), int(e.Args()[3].IntPart())}
|
||
addStatus(e.Ctx().Our, e.Ctx().Opp, statuses[grand.Intn(len(statuses))])
|
||
return true
|
||
}
|
||
|
||
// Effect 1976: 自身持有拥君之瞳时先制+1且造成的攻击伤害翻倍
|
||
type Effect1976 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1976) SkillHit() bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
e.Ctx().SkillEntity.XML.Priority++
|
||
e.Ctx().SkillEntity.XML.Power *= 2
|
||
return true
|
||
}
|
||
|
||
// Effect 1977: 自身持有绝缘之僵时先制+1且附加自身最大体力1/{0}的百分比伤害
|
||
type Effect1977 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1977) OnSkill() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
damage := e.Ctx().Our.CurPet[0].GetMaxHP().Div(e.Args()[0])
|
||
if damage.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Percent, Damage: damage})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1978: 消除对手能力提升状态,消除成功则{0}%令对手{1},未触发则附加自身最大体力1/{2}的百分比伤害
|
||
type Effect1978 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1978) Skill_Use() bool {
|
||
if len(e.Args()) < 3 {
|
||
return true
|
||
}
|
||
removed := clearOppTurnEffects(e.Ctx().Our, e.Ctx().Opp)
|
||
if removed && grand.N(1, 101) <= int(e.Args()[0].IntPart()) {
|
||
addStatus(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
||
return true
|
||
}
|
||
damage := e.Ctx().Our.CurPet[0].GetMaxHP().Div(e.Args()[2])
|
||
if damage.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Percent, Damage: damage})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1979: 消耗自身全部体力,消除对手回合类效果,消除成功则恢复己方下只出场精灵全体力并恢复所有技能PP值
|
||
type Effect1979 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1979) Skill_Use() bool {
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.Ctx().Our.CurPet[0].GetHP()})
|
||
if !clearOppTurnEffects(e.Ctx().Our, e.Ctx().Opp) {
|
||
return true
|
||
}
|
||
for _, pet := range e.Ctx().Our.AllPet {
|
||
if pet == nil || pet.Alive() {
|
||
continue
|
||
}
|
||
pet.Info.Hp = pet.Info.MaxHp
|
||
for i := range pet.Info.SkillList {
|
||
if skill, ok := xmlres.SkillMap[int(pet.Info.SkillList[i].ID)]; ok {
|
||
pet.Info.SkillList[i].PP = uint32(skill.MaxPP)
|
||
}
|
||
}
|
||
break
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1980: 造成的攻击伤害若低于{0}则免疫并反弹自身受到的异常状态
|
||
type Effect1980 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1980) DamageDivEx(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
if zone.Damage.Cmp(e.Args()[0]) < 0 {
|
||
zone.Damage = alpacadecimal.Zero
|
||
addStatus(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1981: 若对手处于{0}状态则{1}回合内攻击技能无法造成伤害且命中效果失效
|
||
type Effect1981 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1981) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || !e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) {
|
||
return true
|
||
}
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1981, e.SideEffectArgs...)
|
||
if eff != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1981Sub struct{ RoundEffectArg0Base }
|
||
|
||
func (e *Effect1981Sub) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone != nil && zone.Type == info.DamageType.Red {
|
||
zone.Damage = alpacadecimal.Zero
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1982: 双方6项能力等级状态全部相同时造成的攻击伤害翻倍
|
||
type Effect1982 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1982) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
for i := 0; i < 6; i++ {
|
||
if e.Ctx().Our.Prop[i] != e.Ctx().Opp.Prop[i] {
|
||
return true
|
||
}
|
||
}
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(2))
|
||
return true
|
||
}
|
||
|
||
// Effect 1983: 每回合使用技能吸取对手{1}点体力
|
||
type Effect1983 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1983) OnSkill() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
drain := e.Args()[1]
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: drain})
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, drain)
|
||
return true
|
||
}
|
||
|
||
// Effect 1984: 自身受到的攻击伤害额外减少{1}%
|
||
type Effect1984 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1984) DamageDivEx(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(100 - int64(e.Args()[1].IntPart()))).Div(alpacadecimal.NewFromInt(100))
|
||
return true
|
||
}
|
||
|
||
// Effect 1985: 造成的攻击伤害提升{0}%,若自身持有红色或白色龙鳞则增伤效果翻倍
|
||
type Effect1985 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1985) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(100 + int64(e.Args()[0].IntPart()))).Div(alpacadecimal.NewFromInt(100))
|
||
return true
|
||
}
|
||
|
||
// Effect 1986: 附加{0}点固定伤害,若自身持有红色或白色龙鳞则附加的固定伤害翻倍
|
||
type Effect1986 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1986) OnSkill() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.Args()[0]})
|
||
return true
|
||
}
|
||
|
||
// Effect 1987: 附加自身最大体力{0}%的百分比伤害
|
||
type Effect1987 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1987) OnSkill() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
damage := e.Ctx().Our.CurPet[0].GetMaxHP().Mul(e.Args()[0]).Div(alpacadecimal.NewFromInt(100))
|
||
if damage.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Percent, Damage: damage})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1988: 令对手随机进入{0}种异常状态,若自身持有黄色或白色龙鳞则进入的异常状态必定为控制类异常状态
|
||
type Effect1988 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1988) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
statuses := []int{int(info.PetStatus.Paralysis), int(info.PetStatus.Fear), int(info.PetStatus.Sleep), int(info.PetStatus.Petrified), int(info.PetStatus.Blind)}
|
||
count := int(e.Args()[0].IntPart())
|
||
if count > len(statuses) {
|
||
count = len(statuses)
|
||
}
|
||
for _, idx := range grand.Perm(len(statuses))[:count] {
|
||
addStatus(e.Ctx().Our, e.Ctx().Opp, statuses[idx])
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1989: 消除对手护盾、护罩类效果
|
||
type Effect1989 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1989) Skill_Use() bool {
|
||
clearOppTurnEffects(e.Ctx().Our, e.Ctx().Opp)
|
||
return true
|
||
}
|
||
|
||
// Effect 1990: 令对手全属性-{0},若自身持有蓝色或白色龙鳞则弱化效果翻倍
|
||
type Effect1990 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1990) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
for i := 0; i < 6; i++ {
|
||
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), -int8(e.Args()[0].IntPart()))
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1991: 全属性+{0},自身持有龙鳞时强化效果翻倍
|
||
type Effect1991 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1991) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
for i := 0; i < 6; i++ {
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), int8(e.Args()[0].IntPart()))
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1992: 若自身当前未持有龙鳞,则为自身附加三色龙鳞
|
||
type Effect1992 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1992) Skill_Use() bool {
|
||
for i := 0; i < 3; i++ {
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), 1)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1993: {0}回合内每回合使用技能附加给对手{1}点真实伤害
|
||
type Effect1993 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1993) OnSkill() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.True, Damage: e.Args()[1]})
|
||
return true
|
||
}
|
||
|
||
// Effect 1994: 自身当前每持有一种三色龙鳞则令自身下{0}回合所有技能先制+{1}
|
||
type Effect1994 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1994) Skill_Use() bool {
|
||
if len(e.Args()) < 3 {
|
||
return true
|
||
}
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1994, e.SideEffectArgs...)
|
||
if eff != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1994Sub struct{ RoundEffectArg0Base }
|
||
|
||
func (e *Effect1994Sub) 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()[1].IntPart())
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1970, &Effect1970{})
|
||
input.InitEffect(input.EffectType.Sub, 1970, &Effect1970Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1971, &Effect1971{})
|
||
input.InitEffect(input.EffectType.Sub, 1971, &Effect1971Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1972, &Effect1972{})
|
||
input.InitEffect(input.EffectType.Skill, 1973, &Effect1973{})
|
||
input.InitEffect(input.EffectType.Skill, 1974, &Effect1974{})
|
||
input.InitEffect(input.EffectType.Skill, 1975, &Effect1975{})
|
||
input.InitEffect(input.EffectType.Sub, 1975, &Effect1975Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1976, &Effect1976{})
|
||
input.InitEffect(input.EffectType.Skill, 1977, &Effect1977{})
|
||
input.InitEffect(input.EffectType.Skill, 1978, &Effect1978{})
|
||
input.InitEffect(input.EffectType.Skill, 1979, &Effect1979{})
|
||
input.InitEffect(input.EffectType.Skill, 1980, &Effect1980{})
|
||
input.InitEffect(input.EffectType.Skill, 1981, &Effect1981{})
|
||
input.InitEffect(input.EffectType.Sub, 1981, &Effect1981Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1982, &Effect1982{})
|
||
input.InitEffect(input.EffectType.Skill, 1983, &Effect1983{})
|
||
input.InitEffect(input.EffectType.Skill, 1984, &Effect1984{})
|
||
input.InitEffect(input.EffectType.Skill, 1985, &Effect1985{})
|
||
input.InitEffect(input.EffectType.Skill, 1986, &Effect1986{})
|
||
input.InitEffect(input.EffectType.Skill, 1987, &Effect1987{})
|
||
input.InitEffect(input.EffectType.Skill, 1988, &Effect1988{})
|
||
input.InitEffect(input.EffectType.Skill, 1989, &Effect1989{})
|
||
input.InitEffect(input.EffectType.Skill, 1990, &Effect1990{})
|
||
input.InitEffect(input.EffectType.Skill, 1991, &Effect1991{})
|
||
input.InitEffect(input.EffectType.Skill, 1992, &Effect1992{})
|
||
input.InitEffect(input.EffectType.Skill, 1993, &Effect1993{})
|
||
input.InitEffect(input.EffectType.Skill, 1994, &Effect1994{})
|
||
input.InitEffect(input.EffectType.Sub, 1994, &Effect1994Sub{})
|
||
}
|