refactor(fight/effect): 重构技能命中处理逻辑,统一使用OnHit/OnMiss接口并新增Effect85偷取强化效果
This commit is contained in:
@@ -2,7 +2,9 @@ package input
|
||||
|
||||
import (
|
||||
element "blazing/common/data/Element"
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"fmt"
|
||||
|
||||
"github.com/mohae/deepcopy"
|
||||
"github.com/shopspring/decimal"
|
||||
@@ -16,17 +18,56 @@ func (u *Input) Death() {
|
||||
|
||||
}
|
||||
|
||||
// 1是添加,-1是减少,0是清除
|
||||
func (u *Input) SetProp(in *Input, prop, level int, ptype info.EnumAbilityOpType) {
|
||||
// 施加方,类型,等级,操作类别,是否成功
|
||||
func (u *Input) SetProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) (ret bool) {
|
||||
canuseskill := u.Exec(func(t Effect) bool { //这个是能否使用技能
|
||||
//结算状态
|
||||
return t.BeferProp(in, prop, level, ptype) //返回本身结算,如果false,说明不能使用技能了
|
||||
|
||||
})
|
||||
if canuseskill {
|
||||
u.AttackValue.Prop[prop] = u.AttackValue.Prop[prop] + int8(level)
|
||||
}
|
||||
switch ptype {
|
||||
case info.AbilityOpType.AbilityOpIncrease:
|
||||
newValue := utils.Min(u.AttackValue.Prop[prop]+int8(level), 6)
|
||||
|
||||
if newValue > u.AttackValue.Prop[prop] {
|
||||
fmt.Println("属性值会增加")
|
||||
ret = true
|
||||
} else {
|
||||
fmt.Println("属性值不会增加")
|
||||
ret = false
|
||||
}
|
||||
|
||||
// 执行赋值
|
||||
u.AttackValue.Prop[prop] = newValue
|
||||
|
||||
case info.AbilityOpType.AbilityOpDecrease:
|
||||
u.AttackValue.Prop[prop] = utils.Max(u.AttackValue.Prop[prop]+int8(level), -6)
|
||||
case info.AbilityOpType.AbilityOpClearWeaken:
|
||||
u.AttackValue.Prop[prop] = utils.Max(u.AttackValue.Prop[prop], 0)
|
||||
case info.AbilityOpType.AbilityOpClearStrengthen:
|
||||
u.AttackValue.Prop[prop] = utils.Min(u.AttackValue.Prop[prop], 0)
|
||||
case info.AbilityOpType.AbilityOpStealStrengthen:
|
||||
|
||||
if in.AttackValue.Prop[prop] > 0 {
|
||||
u.SetProp(u, prop, in.AttackValue.Prop[prop], info.AbilityOpType.AbilityOpClearStrengthen)
|
||||
|
||||
in.SetProp(u, prop, 0, info.AbilityOpType.AbilityOpClearStrengthen) //消除对面
|
||||
}
|
||||
case info.AbilityOpType.AbilityOpReverse:
|
||||
if level > 0 && u.AttackValue.Prop[prop] > 0 { //反转强化,实际上是附带2倍的反转强化
|
||||
|
||||
u.SetProp(u, prop, u.AttackValue.Prop[prop]*2, info.AbilityOpType.AbilityOpDecrease)
|
||||
|
||||
}
|
||||
if level < 0 && u.AttackValue.Prop[prop] < 0 {
|
||||
u.SetProp(u, prop, -u.AttackValue.Prop[prop]*2, info.AbilityOpType.AbilityOpIncrease)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
func (i *Input) GetAction(opp *Input) {
|
||||
//使用1#技能,实际上要按照四个技能权重去使用
|
||||
|
||||
@@ -17,7 +17,7 @@ type Effect interface {
|
||||
|
||||
// OnSkillPP() bool //技能PP减少节点
|
||||
AfterProp(t *Input)
|
||||
BeferProp(in *Input, prop, level int, ptype info.EnumAbilityOpType) bool
|
||||
BeferProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) bool
|
||||
AfterAttr(t *info.BattlePetEntity) //在获取属性前,比如重写对方属性AfterAttr
|
||||
BeferAttr(t *info.BattlePetEntity) //在获取属性后,比如视为对方属性
|
||||
SetArgs(input *Input, param ...int)
|
||||
|
||||
Reference in New Issue
Block a user