1
This commit is contained in:
@@ -1,79 +1,102 @@
|
|||||||
package effect
|
package effect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"blazing/logic/service/fight/action"
|
|
||||||
"blazing/logic/service/fight/info"
|
"blazing/logic/service/fight/info"
|
||||||
"blazing/logic/service/fight/input"
|
"blazing/logic/service/fight/input"
|
||||||
"blazing/logic/service/fight/node"
|
"blazing/logic/service/fight/node"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
// -----------------------------------------------------------
|
||||||
* 降低对方 n 点 btl_Max体力
|
// 降低对方最大体力效果
|
||||||
*/
|
// -----------------------------------------------------------
|
||||||
type Effect38 struct {
|
type Effect38 struct {
|
||||||
node.EffectNode
|
node.EffectNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 工厂函数
|
||||||
|
func newEffect38() *Effect38 {
|
||||||
|
return &Effect38{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// 注册降低最大体力效果
|
||||||
|
input.InitEffect(input.EffectType.Skill, 38, newEffect38())
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// 技能触发时调用
|
||||||
|
// -----------------------------------------------------------
|
||||||
func (e *Effect38) OnSkill() bool {
|
func (e *Effect38) OnSkill() bool {
|
||||||
if !e.Hit() {
|
if !e.Hit() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
ee := &Effect38_sub{}
|
// 创建子效果实例
|
||||||
ee.EffectNode.Duration(-1) //给对方挂3回合子buff
|
ee := &Effect38Sub{}
|
||||||
//ee.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID
|
ee.EffectNode.Duration(-1) // 给对方挂3回合子buff
|
||||||
|
|
||||||
|
// 设置子效果ID和捕获时间
|
||||||
tt := e.ID()
|
tt := e.ID()
|
||||||
tt.SetEffectType(input.EffectType.Sub)
|
tt.SetEffectType(input.EffectType.Sub)
|
||||||
tt.SetCatchTime(e.Ctx().Opp.CurrentPet.Info.CatchTime)
|
tt.SetCatchTime(e.Ctx().Opp.CurrentPet.Info.CatchTime)
|
||||||
|
|
||||||
ee.ID(tt)
|
ee.ID(tt)
|
||||||
ee.SetArgs(e.Ctx().Our, e.SideEffectArgs...)
|
ee.SetArgs(e.Ctx().Our, e.SideEffectArgs...)
|
||||||
|
|
||||||
|
// 添加子效果到对方
|
||||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, ee)
|
e.Ctx().Opp.AddEffect(e.Ctx().Our, ee)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 命中之后
|
// -----------------------------------------------------------
|
||||||
func (e *Effect38_sub) Turn_Start(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
// 降低最大体力子效果
|
||||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
// -----------------------------------------------------------
|
||||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
type Effect38Sub struct {
|
||||||
return
|
node.EffectNode
|
||||||
}
|
oldMaxHP uint32 // 记录原始最大体力值
|
||||||
if e.Args()[0].Cmp(e.Ctx().Our.CurrentPet.GetMaxHP()) == -1 {
|
once sync.Once // 确保只执行一次体力修改
|
||||||
|
|
||||||
e.l.Do(func() {
|
|
||||||
e.oldtype = e.Ctx().Our.CurrentPet.Info.MaxHp
|
|
||||||
e.Ctx().Our.CurrentPet.GetMaxHP().Sub(e.Args()[0])
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
func (e *Effect38_sub) Switch(in *input.Input, at info.AttackValue, oldpet *info.BattlePetEntity) bool {
|
|
||||||
|
// 回合开始时触发
|
||||||
|
func (e *Effect38Sub) Turn_Start(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
||||||
|
// 魂印特性不在场判断:捕获时间不匹配则返回
|
||||||
|
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保只执行一次体力扣减
|
||||||
|
e.once.Do(func() {
|
||||||
|
// 获取要扣除的体力值和当前最大体力
|
||||||
|
reduceHP := e.Args()[0]
|
||||||
|
currentMaxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||||||
|
|
||||||
|
// 只在扣除值小于当前最大体力时执行
|
||||||
|
if reduceHP.Cmp(currentMaxHP) == -1 {
|
||||||
|
e.oldMaxHP = e.Ctx().Our.CurrentPet.Info.MaxHp
|
||||||
|
currentMaxHP.Sub(reduceHP)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 精灵切换时触发
|
||||||
|
func (e *Effect38Sub) Switch(in *input.Input, at info.AttackValue, oldpet *info.BattlePetEntity) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
type Effect38_sub struct {
|
// 效果存活状态判断(处理属性还原)
|
||||||
node.EffectNode
|
func (e *Effect38Sub) Alive(t ...bool) bool {
|
||||||
oldtype uint32
|
if len(t) > 0 {
|
||||||
l sync.Once
|
if t[0] == false {
|
||||||
}
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Effect38_sub) Alive(t ...bool) bool {
|
// 回合结束取消节点时还原属性
|
||||||
|
if e.BoolisFalse(t...) {
|
||||||
if e.BoolisFalse(t...) { //说明到了回合结束取消节点,那么就将变化过的属性变化回来
|
e.Ctx().Our.CurrentPet.Info.MaxHp = e.oldMaxHP
|
||||||
//还原属性
|
|
||||||
e.Ctx().Our.CurrentPet.Info.MaxHp = e.oldtype
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return e.EffectNode.Alive(t...)
|
return e.EffectNode.Alive(t...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
ret := &Effect38{}
|
|
||||||
|
|
||||||
input.InitEffect(input.EffectType.Skill, 38, ret)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -121,14 +121,14 @@ func (e *EffectNode) AttackTime(*input.Input, *input.Input) bool {
|
|||||||
func (e *EffectNode) Prop_Befer(in *input.Input, prop int8, level int8, ptype info.EnumAbilityOpType) bool {
|
func (e *EffectNode) Prop_Befer(in *input.Input, prop int8, level int8, ptype info.EnumAbilityOpType) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (e *EffectNode) BoolisFalse(t ...bool) bool {
|
// func (e *EffectNode) BoolisFalse(t ...bool) bool {
|
||||||
|
|
||||||
if len(t) > 0 {
|
// if len(t) > 0 {
|
||||||
if t[0] == false {
|
// if t[0] == false {
|
||||||
return true
|
// return true
|
||||||
|
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user