```
feat(logic): 新增减少最大生命值效果并优化属性同步逻辑 新增了减少最大生命值的效果实现(opTypeMaxHP),并在 EffectPropSyncReverse 结构体中增加了对目标宠物属性的处理逻辑。同时重构了属性同步与反转相关代码, 改进了效果激活
This commit is contained in:
@@ -18,6 +18,7 @@ const (
|
||||
opAttackSync // 同步攻击力(51)
|
||||
opTypeReverse // 反转属性类型(55)
|
||||
opTypeSync // 同步属性类型(56)
|
||||
opTypeMaxHP // 减少最大生命值38)
|
||||
)
|
||||
|
||||
// 效果上下文:存储属性修改前的原始值(用于还原)
|
||||
@@ -35,8 +36,10 @@ var propOpMap = make(map[int]func() propOpContext)
|
||||
// EffectPropSyncReverse:属性同步/反转效果核心结构体
|
||||
type EffectPropSyncReverse struct {
|
||||
node.EffectNode
|
||||
ctx propOpContext // 操作上下文(存储原始值)
|
||||
bindpet *info.BattlePetEntity
|
||||
ctx propOpContext // 操作上下文(存储原始值)
|
||||
ourpet *info.BattlePetEntity
|
||||
opppet *info.BattlePetEntity
|
||||
can bool
|
||||
}
|
||||
|
||||
// 工厂函数:创建属性同步/反转效果实例
|
||||
@@ -53,6 +56,9 @@ func init() {
|
||||
func registerPropSyncReverseEffects() {
|
||||
// 效果ID与操作配置的映射
|
||||
effectMap := map[int]func() propOpContext{
|
||||
38: func() propOpContext { // 减少最大生命值
|
||||
return propOpContext{opType: opTypeMaxHP}
|
||||
},
|
||||
45: func() propOpContext { // n回合防御力和对手相同
|
||||
return propOpContext{opType: opDefenseSync, propIndex: 1}
|
||||
},
|
||||
@@ -87,60 +93,134 @@ func (e *EffectPropSyncReverse) OnSkill() bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
if e.bindpet != nil {
|
||||
if e.opppet != nil {
|
||||
return true
|
||||
}
|
||||
ourPet := e.Ctx().Our.CurrentPet
|
||||
oppPet := e.Ctx().Opp.CurrentPet
|
||||
e.ourpet = e.Ctx().Our.CurrentPet
|
||||
e.opppet = e.Ctx().Opp.CurrentPet
|
||||
switch e.ctx.opType {
|
||||
case opDefenseSync, opAttackSync:
|
||||
// 同步攻防属性:保存我方原始值,覆盖为对方值
|
||||
e.ctx.oldOurProp = ourPet.Info.Prop[e.ctx.propIndex]
|
||||
ourPet.Info.Prop[e.ctx.propIndex] = oppPet.Info.Prop[e.ctx.propIndex]
|
||||
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 = ourPet.PetInfo.Type
|
||||
e.ctx.oldOppType = oppPet.PetInfo.Type
|
||||
ourPet.PetInfo.Type, oppPet.PetInfo.Type = oppPet.PetInfo.Type, ourPet.PetInfo.Type
|
||||
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
|
||||
|
||||
println("Effect55_o", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type)
|
||||
|
||||
case opTypeSync:
|
||||
// 同步属性类型:保存我方原始值,覆盖为对方值
|
||||
e.ctx.oldOurType = ourPet.PetInfo.Type
|
||||
ourPet.PetInfo.Type = oppPet.PetInfo.Type
|
||||
}
|
||||
e.ctx.oldOurType = e.ourpet.PetInfo.Type
|
||||
e.ourpet.PetInfo.Type = e.opppet.PetInfo.Type
|
||||
case opTypeMaxHP: // 减少最大生命值
|
||||
if e.opppet.GetMaxHP().Cmp(e.Args()[0]) == -1 {
|
||||
e.opppet.Info.MaxHp -= uint32(e.Args()[0].IntPart())
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
e.can = true
|
||||
|
||||
//绑定对方精灵
|
||||
e.bindpet = e.Ctx().Opp.CurrentPet
|
||||
return true
|
||||
}
|
||||
|
||||
// Alive:效果存活判定(结束时还原属性)
|
||||
func (e *EffectPropSyncReverse) Alive(t ...bool) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
//println("属性类测试", t)
|
||||
|
||||
if e.BoolisFalse(t...) {
|
||||
ourPet := e.Ctx().Our.CurrentPet
|
||||
if e.BoolisFalse(t...) && e.can {
|
||||
|
||||
oppPet := e.bindpet
|
||||
switch e.ctx.opType {
|
||||
case opDefenseSync, opAttackSync:
|
||||
// 还原攻防属性
|
||||
ourPet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp
|
||||
e.ourpet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp
|
||||
|
||||
case opTypeReverse:
|
||||
// 还原反转的属性类型(恢复双方原始值)
|
||||
ourPet.PetInfo.Type = e.ctx.oldOurType
|
||||
oppPet.PetInfo.Type = e.ctx.oldOppType
|
||||
|
||||
e.ourpet.PetInfo.Type = e.ctx.oldOurType
|
||||
e.ourpet.PetInfo.Type = e.ctx.oldOppType
|
||||
println("Effect55_o取消效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type)
|
||||
case opTypeSync:
|
||||
// 还原同步的属性类型
|
||||
ourPet.PetInfo.Type = e.ctx.oldOurType
|
||||
e.ourpet.PetInfo.Type = e.ctx.oldOurType
|
||||
default:
|
||||
// case opTypeMaxHP: // 减少最大生命值
|
||||
// oppPet.Info.MaxHp += uint32(e.Args()[0].IntPart())
|
||||
}
|
||||
e.can = false
|
||||
}
|
||||
if e.BoolisTrue(t...) && e.can {
|
||||
|
||||
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
|
||||
println("Effect55_o激活效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type)
|
||||
case opTypeSync:
|
||||
// 同步属性类型:保存我方原始值,覆盖为对方值
|
||||
e.ctx.oldOurType = e.ourpet.PetInfo.Type
|
||||
e.ourpet.PetInfo.Type = e.opppet.PetInfo.Type
|
||||
case opTypeMaxHP: // 减少最大生命值
|
||||
if e.opppet.GetMaxHP().Cmp(e.Args()[0]) == -1 {
|
||||
e.opppet.Info.MaxHp -= uint32(e.Args()[0].IntPart())
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
e.can = false
|
||||
}
|
||||
return e.EffectNode.Alive(t...)
|
||||
|
||||
}
|
||||
func (e *EffectPropSyncReverse) Turn_End() {
|
||||
|
||||
if e.Duration() == 0 { // 保留 (负数表示永久)
|
||||
if e.can {
|
||||
switch e.ctx.opType {
|
||||
case opDefenseSync, opAttackSync:
|
||||
// 还原攻防属性
|
||||
e.ourpet.Info.Prop[e.ctx.propIndex] = e.ctx.oldOurProp
|
||||
|
||||
case opTypeReverse:
|
||||
// 还原反转的属性类型(恢复双方原始值)
|
||||
e.ourpet.PetInfo.Type = e.ctx.oldOurType
|
||||
e.ourpet.PetInfo.Type = e.ctx.oldOppType
|
||||
println("Effect55_o取消效果", e.ourpet.PetInfo.Type, e.opppet.PetInfo.Type)
|
||||
case opTypeSync:
|
||||
// 还原同步的属性类型
|
||||
e.ourpet.PetInfo.Type = e.ctx.oldOurType
|
||||
default:
|
||||
// case opTypeMaxHP: // 减少最大生命值
|
||||
// oppPet.Info.MaxHp += uint32(e.Args()[0].IntPart())
|
||||
}
|
||||
e.can = false
|
||||
}
|
||||
e.Alive(false)
|
||||
|
||||
} else {
|
||||
// e.trunl.Do(func() {
|
||||
|
||||
// if !e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) { //如果我方后手,那就给回合+1
|
||||
// e.duration++
|
||||
// // e.Alive(true)
|
||||
// }
|
||||
|
||||
if e.Duration() > 0 {
|
||||
e.Duration(e.Duration() - 1)
|
||||
}
|
||||
// })
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ func (e *EffectNode) Turn_Start(fattack, sattack *action.SelectSkillAction) {
|
||||
//panic("not implemented") // TODO: Implement
|
||||
}
|
||||
func (e *EffectNode) Turn_End() {
|
||||
// println("效果结算", e.id.Suffix(), e.duration)
|
||||
|
||||
if e.duration == 0 { // 保留 (负数表示永久)
|
||||
|
||||
|
||||
@@ -132,3 +132,14 @@ func (e *EffectNode) BoolisFalse(t ...bool) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (e *EffectNode) BoolisTrue(t ...bool) bool {
|
||||
|
||||
if len(t) > 0 {
|
||||
if t[0] == true {
|
||||
return true
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user