Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
fix(fight): 修复技能实体属性访问问题 - 修改所有技能实体的ID、Power、CritRate、MustHit、Priority等属性访问方式 从直接访问改为通过XML字段访问,确保数据一致性 - 更新多个boss技能效果处理逻辑中的属性引用路径 - 移除已废弃的effect/486文件 - 在New
551 lines
14 KiB
Go
551 lines
14 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"
|
||
)
|
||
|
||
// 483 - -1 -1 -1 -1 -1 -1,后出手时弱化效果翻倍
|
||
type Effect483 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect483) OnSkill() bool {
|
||
if e.Ctx().Our.Speed < e.Ctx().Opp.Speed { // 后出手
|
||
// 这里是标记后出手时弱化效果翻倍的逻辑
|
||
// 实际的翻倍逻辑需要在应用弱化效果的地方实现
|
||
e.Ctx().Our.DoubleNegativeEffects = true
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 485 - 消除对手能力强化状态,若消除成功,则自身恢复所有体力
|
||
type Effect485 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect485) OnSkill() bool {
|
||
if !e.Hit() {
|
||
return true
|
||
}
|
||
|
||
// 检查是否有能力强化状态可以消除
|
||
if e.Ctx().Opp.CurrentPet.HasPositiveBuff() {
|
||
// 消除对手的能力强化状态
|
||
e.Ctx().Opp.RemoveAllPositiveBuffs()
|
||
|
||
// 恢复自身所有体力
|
||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, maxHp)
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 188 - 若对手处于异常状态,则威力翻倍并消除对手相应的防御能力提升效果
|
||
type Effect188 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect188) SkillHit() bool {
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
if e.Ctx().Opp.CurrentPet.HasAnyStatus() { // 对手处于异常状态
|
||
// 威力翻倍
|
||
e.Ctx().SkillEntity.Power *= 2
|
||
|
||
// 消除对手相应的防御能力提升效果
|
||
e.Ctx().Opp.RemovePositiveBuffs()
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 420 - 使用了该技能后,若受到消除强化类技能攻击,则对方则对方攻击和特攻等级+/-n
|
||
type Effect420 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect420) OnSkill() bool {
|
||
// 这里注册监听对手强化消除事件的逻辑
|
||
// 暂时使用一个flag标记
|
||
e.Ctx().Our.TriggerOnBuffRemoved = true
|
||
return true
|
||
}
|
||
|
||
// 407 - 下回合起,每回合XX等级+n,持续m回合
|
||
type Effect407 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect407) OnSkill() bool {
|
||
// 创建一个延迟生效的效果,在下一回合开始生效
|
||
go func() {
|
||
effectType := int(e.Args()[0].IntPart()) // XX类型
|
||
effectValue := int(e.Args()[1].IntPart()) // 等级+n
|
||
duration := int(e.Args()[2].IntPart()) // 持续m回合
|
||
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
|
||
if statusEffect != nil {
|
||
statusEffect.SetArgs(e.Ctx().Our, effectValue)
|
||
statusEffect.Duration(duration)
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
}()
|
||
|
||
return true
|
||
}
|
||
|
||
// 462 - n回合内受攻击时反弹m点固定伤害
|
||
type Effect462 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect462) Skill_Use_ex() bool {
|
||
if !e.Hit() {
|
||
return true
|
||
}
|
||
|
||
// 反弹m点固定伤害
|
||
bounceDamage := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart()))
|
||
damageZone := &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: bounceDamage,
|
||
}
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *Effect462) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||
}
|
||
|
||
// 1044 - 吸取对手能力提升状态,吸取成功则下n回合造成的伤害翻倍
|
||
type Effect1044 struct {
|
||
node.EffectNode
|
||
damageMultiplierActive bool
|
||
multiplierDuration int
|
||
}
|
||
|
||
func (e *Effect1044) OnSkill() bool {
|
||
// 检查对手是否有能力提升状态可以吸取
|
||
if e.Ctx().Opp.CurrentPet.HasPositiveBuff() {
|
||
// 吸取对手的能力提升状态
|
||
e.Ctx().Our.StealPositiveBuffsFrom(e.Ctx().Opp)
|
||
|
||
// 下n回合造成的伤害翻倍
|
||
e.damageMultiplierActive = true
|
||
e.multiplierDuration = int(e.Args()[0].IntPart())
|
||
|
||
// 添加一个临时效果来处理伤害翻倍
|
||
damageDoubleEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.DamageDouble))
|
||
if damageDoubleEffect != nil {
|
||
damageDoubleEffect.Duration(e.multiplierDuration)
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, damageDoubleEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 523 - 若当回合未击败对手,则自身1 1 1 1 1 1能力+1
|
||
type Effect523 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect523) Action_end_ex() bool {
|
||
// 检查对手是否还活着
|
||
if e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
|
||
// 提升自身的全部能力等级
|
||
stats := []int{
|
||
int(info.PetStatus.AtkUp),
|
||
int(info.PetStatus.DefUp),
|
||
int(info.PetStatus.SpAtkUp),
|
||
int(info.PetStatus.SpDefUp),
|
||
int(info.PetStatus.SpeedUp),
|
||
int(info.PetStatus.AccuracyUp),
|
||
}
|
||
|
||
for _, stat := range stats {
|
||
statEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, stat)
|
||
if statEffect != nil {
|
||
statEffect.SetArgs(e.Ctx().Our, 1) // 提升1级
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, statEffect)
|
||
}
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 177 - n回合内,若对手MISS则自身恢复1/m的最大体力值
|
||
type Effect177 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect177) Skill_Use_ex() bool {
|
||
if e.Ctx().Opp.LastAttackMissed {
|
||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
healAmount := maxHp.Div(e.Args()[1]) // 1/m
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect177) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||
}
|
||
|
||
// 178 - 造成伤害的1/n回复自身体力,若属性相同则造成伤害的1/m回复自身体力
|
||
type Effect178 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect178) SkillHit_ex() bool {
|
||
damageDone := e.Ctx().Our.SumDamage
|
||
var healAmount alpacadecimal.Decimal
|
||
|
||
if e.Ctx().Our.CurrentPet.Type == e.Ctx().Opp.CurrentPet.Type {
|
||
// 属性相同,1/m
|
||
healAmount = damageDone.Div(e.Args()[1])
|
||
} else {
|
||
// 属性不同,1/n
|
||
healAmount = damageDone.Div(e.Args()[0])
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
|
||
|
||
return true
|
||
}
|
||
|
||
// 475 - 若造成的伤害不足m,则下n回合的攻击必定致命一击
|
||
type Effect475 struct {
|
||
node.EffectNode
|
||
damageThreshold int
|
||
critDuration int
|
||
}
|
||
|
||
func (e *Effect475) SkillHit_ex() bool {
|
||
damageThreshold := int(e.Args()[0].IntPart())
|
||
damageDone := e.Ctx().Our.SumDamage
|
||
|
||
if damageDone.IntPart() < int64(damageThreshold) {
|
||
critDuration := int(e.Args()[1].IntPart())
|
||
|
||
// 添加必定暴击效果
|
||
critEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.MustCrit))
|
||
if critEffect != nil {
|
||
critEffect.Duration(critDuration)
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, critEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 501 - 若造成的伤害不足m,则对手XX等级-n
|
||
type Effect501 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect501) SkillHit_ex() bool {
|
||
damageThreshold := int(e.Args()[0].IntPart())
|
||
damageDone := e.Ctx().Our.SumDamage
|
||
|
||
if damageDone.IntPart() < int64(damageThreshold) {
|
||
effectType := int(e.Args()[1].IntPart()) // XX类型
|
||
effectValue := int(e.Args()[2].IntPart()) // 等级-n
|
||
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
|
||
if statusEffect != nil {
|
||
statusEffect.SetArgs(e.Ctx().Our, -effectValue) // 负值表示降低
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 440 - n回合内对手使用技能消耗的PP值变为m倍
|
||
type Effect440 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect440) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||
}
|
||
|
||
// 516 - 1 1 1 1 1 1 1 体力低于1/n时强化效果翻倍
|
||
type Effect516 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect516) OnSkill() bool {
|
||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
currentHp := e.Ctx().Our.CurrentPet.GetHP()
|
||
threshold := maxHp.Div(e.Args()[0]) // 1/n
|
||
|
||
if currentHp.Cmp(threshold) < 0 {
|
||
// 体力低于1/n时,设置强化效果翻倍
|
||
e.Ctx().Our.BoostPositiveEffects = true
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 457 - 复制对手释放的技能(组队对战时无效)
|
||
type Effect457 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect457) Skill_Use_ex() bool {
|
||
// 这里需要检查是否在组队对战中
|
||
if !e.Ctx().IsTeamBattle { // 不是组队对战
|
||
if e.Ctx().SkillEntity != nil {
|
||
// 复制对手释放的技能
|
||
e.Ctx().Our.CopySkill(e.Ctx().SkillEntity)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 492 - 2回合内若对手使用属性技能,自身立刻恢复1/m体力且防御+x特防+y
|
||
type Effect492 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect492) Skill_Use_ex() bool {
|
||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
// 恢复1/m体力
|
||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
healAmount := maxHp.Div(e.Args()[0])
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
|
||
|
||
// 防御+x
|
||
defUpEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.DefUp))
|
||
if defUpEffect != nil {
|
||
defUpEffect.SetArgs(e.Ctx().Our, int(e.Args()[1].IntPart())) // x
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, defUpEffect)
|
||
}
|
||
|
||
// 特防+y
|
||
spDefUpEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.SpDefUp))
|
||
if spDefUpEffect != nil {
|
||
spDefUpEffect.SetArgs(e.Ctx().Our, int(e.Args()[2].IntPart())) // y
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, spDefUpEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *Effect492) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(2) // 持续2回合
|
||
}
|
||
|
||
// 138 - 先出手时,n回合自己不会受到对手攻击性技能伤害并反弹对手1/n造成的伤害
|
||
type Effect138 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect138) Skill_Use_ex() bool {
|
||
if e.Ctx().Our.Speed > e.Ctx().Opp.Speed { // 先出手
|
||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||
// 本次受到的攻击伤害无效
|
||
e.Ctx().Our.CancelDamage()
|
||
|
||
// 反弹1/n造成的伤害
|
||
damageToBounce := e.Ctx().Opp.SumDamage.Div(e.Args()[1]) // 1/n
|
||
damageZone := &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: damageToBounce,
|
||
}
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *Effect138) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||
}
|
||
|
||
// 469 - m回合内若对手使用属性技能则n%几率另对手XX
|
||
type Effect469 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect469) Skill_Use_ex() bool {
|
||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
chance := e.Args()[1].IntPart() // n%
|
||
success, _, _ := e.Input.Player.Roll(int(chance), 100)
|
||
if success {
|
||
effectType := int(e.Args()[2].IntPart()) // XX类型
|
||
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
|
||
if statusEffect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *Effect469) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续m回合
|
||
}
|
||
|
||
// 156 - n回合内,使得对手所有能力增强效果失效
|
||
type Effect156 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect156) OnSkill() bool {
|
||
// 使对手的所有能力增强效果失效
|
||
e.Ctx().Opp.DisablePositiveBuffs()
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *Effect156) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||
}
|
||
|
||
// 197 - n回合内若被对方击败,则对手所有能力加强状态消失
|
||
type Effect197 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect197) Skill_Use() bool {
|
||
if e.Ctx().Our.CurrentPet.Info.Hp <= 0 { // 被击败
|
||
// 清除对手的所有能力加强状态
|
||
e.Ctx().Opp.RemoveAllPositiveBuffs()
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *Effect197) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||
}
|
||
|
||
// 170 - 若先出手,则免疫当回合伤害并回复1/n的最大体力值
|
||
type Effect170 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect170) OnSkill() bool {
|
||
if e.Ctx().Our.Speed > e.Ctx().Opp.Speed { // 先出手
|
||
// 免疫当回合伤害
|
||
e.Ctx().Our.ImmuneDamageThisTurn = true
|
||
|
||
// 回复1/n的最大体力值
|
||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
healAmount := maxHp.Div(e.Args()[1]) // 1/n
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 425 - 随机使对手n项属性m,并将该属性附加给自己
|
||
type Effect425 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect425) OnSkill() bool {
|
||
numStats := int(e.Args()[0].IntPart()) // n项属性
|
||
changeValue := int(e.Args()[1].IntPart()) // m
|
||
|
||
// 定义可变化的属性列表
|
||
stats := []int{
|
||
int(info.PetStatus.AtkUp),
|
||
int(info.PetStatus.DefUp),
|
||
int(info.PetStatus.SpAtkUp),
|
||
int(info.PetStatus.SpDefUp),
|
||
int(info.PetStatus.SpeedUp),
|
||
int(info.PetStatus.AccuracyUp),
|
||
}
|
||
|
||
// 随机选择n项属性
|
||
for i := 0; i < numStats && i < len(stats); i++ {
|
||
randomIndex := int(e.Input.FightC.GetRand().Int31n(int32(len(stats))))
|
||
selectedStat := stats[randomIndex]
|
||
|
||
// 对对手施加降低效果
|
||
oppEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, selectedStat)
|
||
if oppEffect != nil {
|
||
oppEffect.SetArgs(e.Ctx().Our, -changeValue) // 负值表示降低
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, oppEffect)
|
||
}
|
||
|
||
// 对自己施加提升效果
|
||
selfEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, selectedStat)
|
||
if selfEffect != nil {
|
||
selfEffect.SetArgs(e.Ctx().Our, changeValue) // 正值表示提升
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, selfEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 412 - 若自身体力小于1/n,则每次攻击不消耗PP值
|
||
type Effect412 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect412) SkillHit() bool {
|
||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
currentHp := e.Ctx().Our.CurrentPet.GetHP()
|
||
threshold := maxHp.Div(e.Args()[0]) // 1/n
|
||
|
||
if currentHp.Cmp(threshold) < 0 {
|
||
// 本次攻击不消耗PP
|
||
e.Ctx().Our.SkipPpConsumption = true
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 199 - 下次被击败后,下一个出场的精灵xx等级+k
|
||
type Effect199 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect199) Skill_Use() bool {
|
||
if e.Ctx().Our.CurrentPet.Info.Hp <= 0 { // 被击败
|
||
// 设置下一个出场精灵的增益效果
|
||
effectType := int(e.Args()[0].IntPart()) // xx类型
|
||
effectValue := int(e.Args()[1].IntPart()) // 等级+k
|
||
|
||
buffEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
|
||
if buffEffect != nil {
|
||
buffEffect.SetArgs(e.Ctx().Our, effectValue)
|
||
e.Ctx().Our.SetNextPetBuff(buffEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|