refactor(fight): 统一技能使用方法命名规范 将多个战斗相关的结构体中的技能使用方法名从不一致的命名 (SkillUseed, OnSkill)统一改为Skill_Use,提高代码一致性。 同时优化了Effect3效果处理逻辑,简化了属性遍历方式, 并修复了先手控制逻辑中的EffectCache处理方式。 BREAKING CHANGE: 技能使用
This commit is contained in:
@@ -9,7 +9,7 @@ type NewSel183 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel183) SkillUseed() bool {
|
||||
func (e *NewSel183) Skill_Use() bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -14,7 +14,7 @@ type NewSel224 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel224) SkillUseed() bool {
|
||||
func (e *NewSel224) Skill_Use() bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ type NewSel283 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel283) SkillUseed() bool {
|
||||
func (e *NewSel283) Skill_Use() bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -13,7 +13,7 @@ type NewSel32 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel32) OnSkill() bool {
|
||||
func (e *NewSel32) Skill_Use() bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type NewSel700 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel700) SkillUseed() bool {
|
||||
func (e *NewSel700) Skill_Use() bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ type NewSel72 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel72) SkillUseed() bool {
|
||||
func (e *NewSel72) Skill_Use() bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -12,7 +12,7 @@ type NewSel73 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel73) SkillUseed() bool {
|
||||
func (e *NewSel73) Skill_Use() bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -10,7 +10,7 @@ type NewSel80 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel80) SkillUseed() bool {
|
||||
func (e *NewSel80) Skill_Use() bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -12,7 +12,7 @@ type NewSel83 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel83) SkillUseed() bool {
|
||||
func (e *NewSel83) Skill_Use() bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -15,50 +15,47 @@ type Effect3 struct {
|
||||
// ----------------------
|
||||
// 执行时逻辑
|
||||
// ----------------------
|
||||
func (e *Effect3) OnSkill() bool {
|
||||
func (e *Effect3) Skill_Use() bool {
|
||||
|
||||
// 遍历六项能力值(攻击、防御、速度等)
|
||||
for i := 0; i < 6; i++ {
|
||||
if e.Reverse&&i>0 {
|
||||
// 对对手生效
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), e.Level)
|
||||
for i, v := range e.Ctx().Our.Prop[:] {
|
||||
if v < 0 {
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), 0)
|
||||
}
|
||||
if !e.Reverse &&i<0{
|
||||
// 对自己生效
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), e.Level)
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect3:能力操作类效果(重置/反转/偷取等)
|
||||
type Effect33 struct {
|
||||
node.EffectNode
|
||||
Reverse bool
|
||||
Level int8
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// 执行时逻辑
|
||||
// ----------------------
|
||||
func (e *Effect33) Skill_Use() bool {
|
||||
|
||||
for i, v := range e.Ctx().Opp.Prop[:] {
|
||||
if v > 0 {
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// 工厂函数
|
||||
// ----------------------
|
||||
func newEffect3(reverse bool, level int8) *Effect3 {
|
||||
return &Effect3{
|
||||
Reverse: reverse,
|
||||
Level: level,
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// 注册所有效果
|
||||
// ----------------------
|
||||
func init() {
|
||||
effects := []struct {
|
||||
id int
|
||||
reverse bool
|
||||
level int8
|
||||
}{
|
||||
{3, false, 0}, // 解除自身能力下降状态
|
||||
{33, true, 0}, // 消除对手能力提升状态
|
||||
// {63, false, 0, info.AbilityOpType.BounceWeaken}, // 将能力下降反馈给对手
|
||||
// {85, false, -1, info.AbilityOpType.StealStrengthen}, // 将对手提升效果转移到自己
|
||||
// {143, true, 1, info.AbilityOpType.Reverse}, // 反转对手能力提升为下降
|
||||
}
|
||||
|
||||
for _, e := range effects {
|
||||
input.InitEffect(input.EffectType.Skill, e.id, newEffect3(e.reverse, e.level))
|
||||
}
|
||||
// {3, false, 0}, // 解除自身能力下降状态
|
||||
// {33, true, 0}, // 消除对手能力提升状态{3, false, 0}, // 解除自身能力下降状态
|
||||
// {33, true, 0}, // 消除对手能力提升状态
|
||||
input.InitEffect(input.EffectType.Skill, 3, &Effect3{})
|
||||
input.InitEffect(input.EffectType.Skill, 33, &Effect33{})
|
||||
}
|
||||
|
||||
@@ -221,21 +221,9 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
attacker.RecoverEffect()
|
||||
currentSkill = nil
|
||||
if i == 0 { //先手方被控,这时候应该算做未出手状态
|
||||
if canUse {
|
||||
f.TrueFirst = attacker
|
||||
|
||||
attacker.Exec(func(effect input.Effect) bool {
|
||||
effect.IsFirst(true)
|
||||
return true
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
f.TrueFirst = defender
|
||||
defender.Exec(func(effect input.Effect) bool {
|
||||
effect.IsFirst(true)
|
||||
return true
|
||||
})
|
||||
f.TrueFirst = defender
|
||||
for _, effect := range defender.EffectCache {
|
||||
effect.IsFirst(true)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -253,6 +241,10 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
||||
for _, effect := range attacker.EffectCache {
|
||||
effect.IsFirst(true)
|
||||
}
|
||||
f.processSkillAttack(attacker, defender, currentSkill)
|
||||
currentSkill = originalSkill //还原技能
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ func (e *EffectNode) Skill_Can() bool {
|
||||
// return true
|
||||
// }
|
||||
|
||||
// func (e *EffectNode) SkillUseed() bool {
|
||||
// func (e *EffectNode) Skill_Use() bool {
|
||||
// // if e.Effect != nil {
|
||||
// // if e.Input.CurrentPet.Info.Hp == 0 {
|
||||
// // e.OnDefeat(ctx.Input, ctx.SkillEntity) //死亡
|
||||
|
||||
Reference in New Issue
Block a user