2025-11-14 06:14:49 +08:00
|
|
|
|
package effect
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
|
"blazing/logic/service/fight/input"
|
|
|
|
|
|
"blazing/logic/service/fight/node"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-18 13:10:40 +00:00
|
|
|
|
// -----------------------------------------------------------
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 通用效果:属性同步/反转类效果(45/51/55/56)
|
2025-12-18 13:10:40 +00:00
|
|
|
|
// -----------------------------------------------------------
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
|
|
|
|
|
// 操作类型定义:区分不同的属性操作
|
|
|
|
|
|
type propOpType int
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
opDefenseSync propOpType = iota // 同步防御力(45)
|
|
|
|
|
|
opAttackSync // 同步攻击力(51)
|
|
|
|
|
|
opTypeReverse // 反转属性类型(55)
|
|
|
|
|
|
opTypeSync // 同步属性类型(56)
|
2025-12-19 21:12:45 +08:00
|
|
|
|
opTypeMaxHP // 减少最大生命值38)
|
2025-12-18 23:57:17 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 效果上下文:存储属性修改前的原始值(用于还原)
|
|
|
|
|
|
type propOpContext struct {
|
|
|
|
|
|
oldOurProp uint32 // 我方原始属性值(45/51)
|
|
|
|
|
|
oldOurType int // 我方原始类型值(56)
|
|
|
|
|
|
oldOppType int // 对方原始类型值(55)
|
|
|
|
|
|
propIndex int // 属性索引(0=攻击,1=防御)
|
|
|
|
|
|
opType propOpType
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-04 09:26:57 +08:00
|
|
|
|
type propOpConfig struct {
|
|
|
|
|
|
newContext func() propOpContext
|
|
|
|
|
|
initDuration bool
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 全局映射:关联效果ID与对应的操作配置
|
2026-04-04 09:26:57 +08:00
|
|
|
|
var propOpMap = make(map[int]propOpConfig)
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
|
|
|
|
|
// EffectPropSyncReverse:属性同步/反转效果核心结构体
|
|
|
|
|
|
type EffectPropSyncReverse struct {
|
2025-11-14 06:14:49 +08:00
|
|
|
|
node.EffectNode
|
2025-12-19 21:12:45 +08:00
|
|
|
|
ctx propOpContext // 操作上下文(存储原始值)
|
|
|
|
|
|
ourpet *info.BattlePetEntity
|
|
|
|
|
|
opppet *info.BattlePetEntity
|
2026-01-22 16:01:52 +00:00
|
|
|
|
|
|
|
|
|
|
isactive bool
|
|
|
|
|
|
can bool
|
2025-11-14 06:14:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 工厂函数:创建属性同步/反转效果实例
|
|
|
|
|
|
func newEffectPropSyncReverse() *EffectPropSyncReverse {
|
|
|
|
|
|
return &EffectPropSyncReverse{}
|
2025-12-18 13:10:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 初始化:批量注册所有属性同步/反转类效果
|
2025-12-18 13:10:40 +00:00
|
|
|
|
func init() {
|
2025-12-18 23:57:17 +08:00
|
|
|
|
registerPropSyncReverseEffects()
|
2025-12-18 13:10:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 批量注册:绑定效果ID与对应的操作配置
|
|
|
|
|
|
func registerPropSyncReverseEffects() {
|
|
|
|
|
|
// 效果ID与操作配置的映射
|
2026-04-04 09:26:57 +08:00
|
|
|
|
effectMap := map[int]propOpConfig{
|
|
|
|
|
|
38: {
|
|
|
|
|
|
newContext: func() propOpContext { // 减少最大生命值
|
|
|
|
|
|
return propOpContext{opType: opTypeMaxHP}
|
|
|
|
|
|
},
|
2025-12-19 21:12:45 +08:00
|
|
|
|
},
|
2026-04-04 09:26:57 +08:00
|
|
|
|
45: {
|
|
|
|
|
|
newContext: func() propOpContext { // n回合防御力和对手相同
|
|
|
|
|
|
return propOpContext{opType: opDefenseSync, propIndex: 1}
|
|
|
|
|
|
},
|
|
|
|
|
|
initDuration: true,
|
2025-12-18 23:57:17 +08:00
|
|
|
|
},
|
2026-04-04 09:26:57 +08:00
|
|
|
|
51: {
|
|
|
|
|
|
newContext: func() propOpContext { // n回合攻击力和对手相同
|
|
|
|
|
|
return propOpContext{opType: opAttackSync, propIndex: 0}
|
|
|
|
|
|
},
|
|
|
|
|
|
initDuration: true,
|
2025-12-18 23:57:17 +08:00
|
|
|
|
},
|
2026-04-04 09:26:57 +08:00
|
|
|
|
55: {
|
|
|
|
|
|
newContext: func() propOpContext { // n回合反转属性类型
|
|
|
|
|
|
return propOpContext{opType: opTypeReverse}
|
|
|
|
|
|
},
|
|
|
|
|
|
initDuration: true,
|
2025-12-18 23:57:17 +08:00
|
|
|
|
},
|
2026-04-04 09:26:57 +08:00
|
|
|
|
56: {
|
|
|
|
|
|
newContext: func() propOpContext { // n回合同步属性类型
|
|
|
|
|
|
return propOpContext{opType: opTypeSync}
|
|
|
|
|
|
},
|
|
|
|
|
|
initDuration: true,
|
2025-12-18 23:57:17 +08:00
|
|
|
|
},
|
2025-11-14 06:14:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 注册到全局映射,并初始化效果
|
2026-04-04 09:26:57 +08:00
|
|
|
|
for effectID, config := range effectMap {
|
|
|
|
|
|
propOpMap[effectID] = config
|
2025-12-18 23:57:17 +08:00
|
|
|
|
input.InitEffect(input.EffectType.Skill, effectID, newEffectPropSyncReverse())
|
|
|
|
|
|
}
|
2025-11-14 06:14:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// SetArgs:设置效果参数(回合数)
|
|
|
|
|
|
func (e *EffectPropSyncReverse) SetArgs(t *input.Input, a ...int) {
|
|
|
|
|
|
e.EffectNode.SetArgs(t, a...)
|
2026-04-04 09:26:57 +08:00
|
|
|
|
config, ok := propOpMap[int(e.ID().Suffix())]
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if config.initDuration && len(e.EffectNode.SideEffectArgs) > 0 {
|
|
|
|
|
|
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
|
|
|
|
|
|
}
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// 初始化操作上下文
|
2026-04-04 09:26:57 +08:00
|
|
|
|
e.ctx = config.newContext()
|
2025-12-18 13:10:40 +00:00
|
|
|
|
}
|
2025-12-18 23:57:17 +08:00
|
|
|
|
func (e *EffectPropSyncReverse) OnSkill() bool {
|
2025-11-17 13:37:08 +08:00
|
|
|
|
|
2025-12-19 21:12:45 +08:00
|
|
|
|
if e.opppet != nil {
|
2025-12-18 23:57:17 +08:00
|
|
|
|
return true
|
|
|
|
|
|
}
|
2026-04-04 07:22:28 +08:00
|
|
|
|
e.ourpet = e.CarrierInput().CurPet[0]
|
2026-04-05 02:25:44 +08:00
|
|
|
|
e.opppet = e.TargetInput().CurPet[0]
|
2026-01-22 16:01:52 +00:00
|
|
|
|
e.can = true
|
|
|
|
|
|
e.active(true)
|
2026-03-04 14:45:52 +08:00
|
|
|
|
|
2026-01-22 16:01:52 +00:00
|
|
|
|
return true
|
|
|
|
|
|
}
|
2025-12-19 21:12:45 +08:00
|
|
|
|
|
2026-01-22 16:01:52 +00:00
|
|
|
|
// Alive:效果存活判定(结束时还原属性)
|
|
|
|
|
|
func (e *EffectPropSyncReverse) Alive(t ...bool) bool {
|
|
|
|
|
|
if len(t) > 0 {
|
|
|
|
|
|
if t[0] {
|
|
|
|
|
|
e.active(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.active(false)
|
2025-12-19 21:12:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 06:14:49 +08:00
|
|
|
|
}
|
2026-01-22 16:01:52 +00:00
|
|
|
|
return e.EffectNode.Alive(t...)
|
2025-11-14 06:14:49 +08:00
|
|
|
|
|
2025-11-15 00:15:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
// Alive:效果存活判定(结束时还原属性)
|
2026-01-22 16:01:52 +00:00
|
|
|
|
func (e *EffectPropSyncReverse) active(is bool) {
|
2025-12-19 21:12:45 +08:00
|
|
|
|
//println("属性类测试", t)
|
2026-01-22 16:01:52 +00:00
|
|
|
|
if !e.can {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-11-17 19:31:51 +00:00
|
|
|
|
|
2026-01-22 16:01:52 +00:00
|
|
|
|
if !is && e.isactive { //取消反转
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
2026-01-22 16:01:52 +00:00
|
|
|
|
e.isactive = false
|
2025-12-18 23:57:17 +08:00
|
|
|
|
switch e.ctx.opType {
|
|
|
|
|
|
case opDefenseSync, opAttackSync:
|
|
|
|
|
|
// 还原攻防属性
|
2025-12-19 21:12:45 +08:00
|
|
|
|
e.ourpet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
|
|
|
|
|
case opTypeReverse:
|
|
|
|
|
|
// 还原反转的属性类型(恢复双方原始值)
|
2025-12-19 21:12:45 +08:00
|
|
|
|
e.ourpet.PetInfo.Type = e.ctx.oldOurType
|
|
|
|
|
|
e.ourpet.PetInfo.Type = e.ctx.oldOppType
|
2026-03-04 14:45:52 +08:00
|
|
|
|
// println("Effect55_o取消效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type)
|
2025-12-18 23:57:17 +08:00
|
|
|
|
case opTypeSync:
|
|
|
|
|
|
// 还原同步的属性类型
|
2025-12-19 21:12:45 +08:00
|
|
|
|
e.ourpet.PetInfo.Type = e.ctx.oldOurType
|
|
|
|
|
|
default:
|
|
|
|
|
|
// case opTypeMaxHP: // 减少最大生命值
|
|
|
|
|
|
// oppPet.Info.MaxHp += uint32(e.Args()[0].IntPart())
|
2025-12-18 23:57:17 +08:00
|
|
|
|
}
|
2025-11-16 20:30:17 +00:00
|
|
|
|
|
2026-01-22 16:01:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
if is && !e.isactive { //激活
|
|
|
|
|
|
e.isactive = true
|
2025-12-19 21:12:45 +08:00
|
|
|
|
switch e.ctx.opType {
|
|
|
|
|
|
case opDefenseSync, opAttackSync:
|
|
|
|
|
|
// 同步攻防属性:保存我方原始值,覆盖为对方值
|
|
|
|
|
|
e.ctx.oldOurProp = e.ourpet.Info.Prop[e.ctx.propIndex]
|
|
|
|
|
|
e.ourpet.Info.Prop[e.ctx.propIndex] = e.opppet.Info.Prop[e.ctx.propIndex]
|
|
|
|
|
|
|
|
|
|
|
|
case opTypeReverse:
|
|
|
|
|
|
// 反转属性类型:保存双方原始值,交换类型
|
|
|
|
|
|
e.ctx.oldOurType = e.ourpet.PetInfo.Type
|
|
|
|
|
|
e.ctx.oldOppType = e.opppet.PetInfo.Type
|
|
|
|
|
|
e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type = e.opppet.PetInfo.Type, e.ourpet.PetInfo.Type
|
2026-03-04 14:45:52 +08:00
|
|
|
|
// println("Effect55_o激活效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type)
|
2025-12-19 21:12:45 +08:00
|
|
|
|
case opTypeSync:
|
|
|
|
|
|
// 同步属性类型:保存我方原始值,覆盖为对方值
|
|
|
|
|
|
e.ctx.oldOurType = e.ourpet.PetInfo.Type
|
|
|
|
|
|
e.ourpet.PetInfo.Type = e.opppet.PetInfo.Type
|
2025-12-23 13:53:34 +00:00
|
|
|
|
// case opTypeMaxHP: // 减少最大生命值
|
|
|
|
|
|
// if e.opppet.GetMaxHP().Cmp(e.Args()[0]) == -1 {
|
|
|
|
|
|
// e.opppet.Info.MaxHp -= uint32(e.Args()[0].IntPart())
|
2025-12-19 21:12:45 +08:00
|
|
|
|
|
2025-12-23 13:53:34 +00:00
|
|
|
|
// }
|
2025-12-19 21:12:45 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|