Files
bl/logic/service/fight/effect/2020_2044.go
xinian 9c6f3988de
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构 CurrentPet 为 CurPet
2026-04-04 04:34:43 +08:00

513 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"
)
func totalLostPP(in *input.Input) int64 {
if in == nil || in.CurPet[0] == nil {
return 0
}
total := int64(0)
for _, s := range in.CurPet[0].Info.SkillList {
if skill, ok := xmlres.SkillMap[int(s.ID)]; ok {
total += int64(skill.MaxPP) - int64(s.PP)
}
}
return total
}
// Effect 2020: 若自身处于异常状态则先制+3
type Effect2020 struct{ node.EffectNode }
func (e *Effect2020) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !e.Ctx().Our.StatEffect_Exist_all() {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current != nil && current.SkillEntity != nil {
current.SkillEntity.XML.Priority += 3
}
return true
}
// Effect 2021: 每回合使用技能恢复自身体力,并在低血时转为吸血
type Effect2021 struct{ node.EffectNode }
func (e *Effect2021) Skill_Use() bool {
if len(e.Args()) < 4 || e.Ctx().Our.CurPet[0] == nil || e.Ctx().Opp.CurPet[0] == nil {
return true
}
heal := e.Args()[1]
if e.Ctx().Our.CurPet[0].GetHP().Cmp(e.Ctx().Our.CurPet[0].GetMaxHP().Div(e.Args()[2])) < 0 {
heal = e.Args()[3]
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: heal})
return true
}
// Effect 2022: 若对手处于异常状态则{1}回合内属性技能命中失效
type Effect2022 struct{ node.EffectNode }
func (e *Effect2022) Skill_Use() bool {
if len(e.Args()) < 2 || !e.Ctx().Opp.StatEffect_Exist_all() {
return true
}
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 2022, int(e.Args()[1].IntPart()))
if eff != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
}
return true
}
type Effect2022Sub struct{ RoundEffectArg0Base }
func (e *Effect2022Sub) SkillHit_ex() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetMiss()
return true
}
// Effect 2023: 双方当前每损失{0}点技能PP值则造成的攻击伤害提升{1}%
type Effect2023 struct{ node.EffectNode }
func (e *Effect2023) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
return true
}
lost := totalLostPP(e.Ctx().Our) + totalLostPP(e.Ctx().Opp)
if lost <= 0 {
return true
}
step := int64(e.Args()[0].IntPart())
if step <= 0 {
return true
}
mul := lost / step
if mul <= 0 {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1].Mul(alpacadecimal.NewFromInt(mul)))).Div(hundred)
return true
}
// Effect 2024: 附加双方当前已损失技能PP总和x{0}的固定伤害
type Effect2024 struct{ node.EffectNode }
func (e *Effect2024) OnSkill() bool {
if len(e.Args()) == 0 {
return true
}
total := totalLostPP(e.Ctx().Our) + totalLostPP(e.Ctx().Opp)
if total <= 0 {
return true
}
damage := alpacadecimal.NewFromInt(total).Mul(e.Args()[0])
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: damage})
return true
}
// Effect 2025: 若自身不处于异常状态则先制+1
type Effect2025 struct{ node.EffectNode }
func (e *Effect2025) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if e.Ctx().Our.StatEffect_Exist_all() {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current != nil && current.SkillEntity != nil {
current.SkillEntity.XML.Priority += 1
}
return true
}
// Effect 2026: 对手不处于异常状态则{0}%令自身进入{1}
type Effect2026 struct{ node.EffectNode }
func (e *Effect2026) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().Opp.StatEffect_Exist_all() {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Our, int(e.Args()[1].IntPart()))
}
return true
}
// Effect 2027: 击败对手则对方下只精灵出战时降低所有技能PP
type Effect2027 struct{ node.EffectNode }
func (e *Effect2027) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp.CurPet[0] == nil || e.Ctx().Opp.CurPet[0].Info.Hp > 0 {
return true
}
e.Ctx().Opp.DelPP(int(e.Args()[0].IntPart()))
return true
}
// Effect 2028: 若自身为对手天敌则必定命中
type Effect2028 struct{ node.EffectNode }
func (e *Effect2028) SkillHit_ex() bool {
if e.ISNaturalEnemy() && e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() != info.Category.STATUS {
e.Ctx().SkillEntity.XML.MustHit = 1
}
return true
}
// Effect 2029: 若自身为对手天敌则对手下次使用的攻击技能MISS
type Effect2029 struct{ node.EffectNode }
func (e *Effect2029) Skill_Use() bool {
if !e.ISNaturalEnemy() {
return true
}
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 2029)
if eff != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
}
return true
}
type Effect2029Sub struct{ node.EffectNode }
func (e *Effect2029Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetMiss()
e.Alive(false)
return true
}
// Effect 2030: 若本次技能为微弱对手则先制+1
type Effect2030 struct{ node.EffectNode }
func (e *Effect2030) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current != nil && current.SkillEntity != nil && e.Ctx().Opp.CurPet[0] != nil && e.Ctx().Our.CurPet[0] != nil {
if e.Ctx().Our.CurPet[0].GetHP().Cmp(e.Ctx().Opp.CurPet[0].GetHP()) > 0 {
current.SkillEntity.XML.Priority += 1
}
}
return true
}
// Effect 2031: 双方所有技能PP值等于本技能剩余PP值时按条件附加效果
type Effect2031 struct{ node.EffectNode }
func (e *Effect2031) Skill_Use() bool {
if len(e.Args()) < 4 {
return true
}
oppPP := e.Ctx().Opp.CurPet[0].Info.SkillList
ourPP := e.Ctx().Our.CurPet[0].Info.SkillList
if len(oppPP) > 0 && int(oppPP[0].PP) == int(e.Ctx().SkillEntity.Info.PP) {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
}
if len(ourPP) > 0 && int(ourPP[0].PP) == int(e.Ctx().SkillEntity.Info.PP) {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[3].IntPart()))
}
return true
}
// Effect 2032: 全属性+{0},对方场下每死亡一只精灵则{1}%概率强化效果翻倍
type Effect2032 struct{ node.EffectNode }
func (e *Effect2032) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
boost := int8(e.Args()[0].IntPart())
dead := 0
for _, pet := range e.Ctx().Opp.AllPet {
if pet != nil && !pet.Alive() {
dead++
}
}
ok := false
if dead > 0 {
ok, _, _ = e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
}
if ok {
boost *= 2
}
for i := range e.Ctx().Our.Prop[:] {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), boost)
}
return true
}
// Effect 2033: 未击败对手则降低对手所有技能PP值
type Effect2033 struct{ node.EffectNode }
func (e *Effect2033) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp.CurPet[0] == nil || e.Ctx().Opp.CurPet[0].Info.Hp <= 0 {
return true
}
e.Ctx().Opp.DelPP(int(e.Args()[0].IntPart()))
return true
}
// Effect 2034: 消除对手回合类效果,消除成功则{0}%令对手{1},未触发则{2}回合内自身受到的攻击伤害减少{3}%
type Effect2034 struct{ node.EffectNode }
func (e *Effect2034) Skill_Use() bool {
if len(e.Args()) < 4 {
return true
}
cleared := false
for _, eff := range e.Ctx().Opp.Effects {
if eff != nil && eff.Alive() {
eff.Alive(false)
cleared = true
}
}
if cleared {
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
}
return true
}
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 2034, int(e.Args()[2].IntPart()), int(e.Args()[3].IntPart()))
if eff != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, eff)
}
return true
}
type Effect2034Sub struct{ RoundEffectArg0Base }
func (e *Effect2034Sub) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Sub(e.Args()[1])).Div(hundred)
return true
}
// Effect 2035: 当回合命中时消耗技能PP并令对手属性变化
type Effect2035 struct{ node.EffectNode }
func (e *Effect2035) OnSkill() bool {
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().Our.DelPP(int(e.Args()[1].IntPart()))
applyStatusByID := addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[2].IntPart()))
_ = applyStatusByID
return true
}
// Effect 2036: 若对手不处于能力下降状态则令对手全属性+{0}
type Effect2036 struct{ node.EffectNode }
func (e *Effect2036) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp.HasPropSub() {
return true
}
for i := range e.Ctx().Opp.Prop[:] {
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), int8(e.Args()[0].IntPart()))
}
return true
}
// Effect 2037: 双方能力总段数达到阈值时附加真实伤害/夜幕联动
type Effect2037 struct{ node.EffectNode }
func (e *Effect2037) OnSkill() bool {
if len(e.Args()) < 3 {
return true
}
total := int64(0)
for _, v := range e.Ctx().Our.Prop[:] {
if v > 0 {
total += int64(v)
}
}
for _, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
total += int64(v)
}
}
if total <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.True, Damage: e.Args()[1]})
return true
}
// Effect 2038: 消除对手回合类效果,消除成功则对手{0},若对手不处于回合类效果则令自身{1}并恢复自身全部体力
type Effect2038 struct{ node.EffectNode }
func (e *Effect2038) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
cleared := false
for _, eff := range e.Ctx().Opp.Effects {
if eff != nil && eff.Alive() {
eff.Alive(false)
cleared = true
}
}
if cleared {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[0].IntPart()))
return true
}
addStatusByID(e.Ctx().Our, e.Ctx().Our, int(e.Args()[1].IntPart()))
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurPet[0].GetMaxHP())
return true
}
// Effect 2039: {0}回合内若自身能力提升状态被消除或吸取则{1}%令对手{2},未触发则免疫下{3}次受到的攻击
type Effect2039 struct{ node.EffectNode }
func (e *Effect2039) Skill_Use() bool {
if len(e.Args()) < 4 {
return true
}
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 2039, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()), int(e.Args()[3].IntPart()))
if eff != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, eff)
}
return true
}
type Effect2039Sub struct{ RoundEffectArg0Base }
func (e *Effect2039Sub) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
if in != e.Ctx().Our || !input.IS_Stat(effEffect) {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[2].IntPart()))
}
return true
}
// Effect 2040: 每次对手主动切换下场则对方下只精灵出战时触发异常
type Effect2040 struct{ node.EffectNode }
func (e *Effect2040) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
eff := e.Ctx().Our.InitEffect(input.EffectType.Sub, 2040, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if eff != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
}
return true
}
type Effect2040Sub struct{ RoundEffectArg0Base }
func (e *Effect2040Sub) SwitchOut(in *input.Input) bool {
if in != e.Ctx().Opp {
return true
}
e.Alive(false)
return true
}
func (e *Effect2040Sub) SwitchIn(in *input.Input) bool {
if in != e.Ctx().Opp || len(e.Args()) < 3 {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[2].IntPart()))
}
return true
}
// Effect 2041: 自身能力提升状态被吸取时令该效果无效
type Effect2041 struct{ node.EffectNode }
func (e *Effect2041) Skill_Use() bool { return true }
// Effect 2042: 消除对手回合类效果,消除成功则对手{0},若对手不处于回合类效果则为对手施加{1}道诅咒
type Effect2042 struct{ node.EffectNode }
func (e *Effect2042) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
cleared := false
for _, eff := range e.Ctx().Opp.Effects {
if eff != nil && eff.Alive() {
eff.Alive(false)
cleared = true
}
}
if cleared {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[0].IntPart()))
return true
}
e.Ctx().Opp.SetProp(e.Ctx().Our, 0, int8(e.Args()[1].IntPart()))
return true
}
// Effect 2043: 若对手被施加的诅咒数量>=2道则先制+1
type Effect2043 struct{ node.EffectNode }
func (e *Effect2043) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current != nil && current.SkillEntity != nil {
current.SkillEntity.XML.Priority += 1
}
return true
}
// Effect 2044: 若对手不处于异常状态则为对手施加{0}道诅咒
type Effect2044 struct{ node.EffectNode }
func (e *Effect2044) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp.StatEffect_Exist_all() {
return true
}
e.Ctx().Opp.SetProp(e.Ctx().Our, 0, int8(e.Args()[0].IntPart()))
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 2020, &Effect2020{})
input.InitEffect(input.EffectType.Skill, 2021, &Effect2021{})
input.InitEffect(input.EffectType.Skill, 2022, &Effect2022{})
input.InitEffect(input.EffectType.Sub, 2022, &Effect2022Sub{})
input.InitEffect(input.EffectType.Skill, 2023, &Effect2023{})
input.InitEffect(input.EffectType.Skill, 2024, &Effect2024{})
input.InitEffect(input.EffectType.Skill, 2025, &Effect2025{})
input.InitEffect(input.EffectType.Skill, 2026, &Effect2026{})
input.InitEffect(input.EffectType.Skill, 2027, &Effect2027{})
input.InitEffect(input.EffectType.Skill, 2028, &Effect2028{})
input.InitEffect(input.EffectType.Skill, 2029, &Effect2029{})
input.InitEffect(input.EffectType.Sub, 2029, &Effect2029Sub{})
input.InitEffect(input.EffectType.Skill, 2030, &Effect2030{})
input.InitEffect(input.EffectType.Skill, 2031, &Effect2031{})
input.InitEffect(input.EffectType.Skill, 2032, &Effect2032{})
input.InitEffect(input.EffectType.Skill, 2033, &Effect2033{})
input.InitEffect(input.EffectType.Skill, 2034, &Effect2034{})
input.InitEffect(input.EffectType.Sub, 2034, &Effect2034Sub{})
input.InitEffect(input.EffectType.Skill, 2035, &Effect2035{})
input.InitEffect(input.EffectType.Skill, 2036, &Effect2036{})
input.InitEffect(input.EffectType.Skill, 2037, &Effect2037{})
input.InitEffect(input.EffectType.Skill, 2038, &Effect2038{})
input.InitEffect(input.EffectType.Skill, 2039, &Effect2039{})
input.InitEffect(input.EffectType.Sub, 2039, &Effect2039Sub{})
input.InitEffect(input.EffectType.Skill, 2040, &Effect2040{})
input.InitEffect(input.EffectType.Sub, 2040, &Effect2040Sub{})
input.InitEffect(input.EffectType.Skill, 2041, &Effect2041{})
input.InitEffect(input.EffectType.Skill, 2042, &Effect2042{})
input.InitEffect(input.EffectType.Skill, 2043, &Effect2043{})
input.InitEffect(input.EffectType.Skill, 2044, &Effect2044{})
}