refactor(fight/input): 重构效果获取逻辑,优化属性计算流程并新增GetPropEffect方法
This commit is contained in:
@@ -26,7 +26,7 @@ type Input struct {
|
||||
|
||||
func NewInput(c common.FightI, p common.PlayerI) *Input {
|
||||
ret := &Input{FightC: c, Player: p}
|
||||
t, _ := Geteffect(4000000)
|
||||
t := ret.GetDamageEffect(0)
|
||||
ret.AddEffect(t) //添加默认基类,实现继承
|
||||
p.SetFightC(c) //给玩家设置战斗容器
|
||||
return ret
|
||||
|
||||
@@ -35,7 +35,7 @@ type Effect interface {
|
||||
IsHit(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
|
||||
TakeHit(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
|
||||
//() bool // 暴击伤害结算后触发
|
||||
OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
|
||||
OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
|
||||
// OnHit() bool // 技能命中时触发
|
||||
// OnMiss() bool // 技能未命中时触发
|
||||
// AfterAttacked() bool // 被攻击后触发(受击判定)
|
||||
@@ -108,22 +108,26 @@ func InitPropEffect(id int, t Effect) {
|
||||
// * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5)
|
||||
// 是否需要真实提升
|
||||
func (c *Input) GetProp(id int, istue bool) int {
|
||||
//todo 插入获取前
|
||||
// 获取基础属性值
|
||||
baseValue := int(c.AttackValue.Prop[id])
|
||||
|
||||
t, ok := NodeM[id+2000000]
|
||||
if ok {
|
||||
if id < 5 {
|
||||
if istue {
|
||||
return t.Stack()
|
||||
}
|
||||
return info.CalculateRealValue(int(c.CurrentPet.Info.Prop[id]), t.Stack())
|
||||
}
|
||||
//命中就直接返回
|
||||
return t.Stack()
|
||||
// 命中情况直接返回基础值(优先判断)
|
||||
if id >= 5 {
|
||||
return baseValue
|
||||
}
|
||||
|
||||
//todo 插入获取后函数
|
||||
return 0
|
||||
// 处理id < 5的情况
|
||||
if istue {
|
||||
return baseValue
|
||||
}
|
||||
|
||||
// 计算实际值(这里可以插入后续优化的函数调用)
|
||||
realValue := info.CalculateRealValue(int(c.CurrentPet.Info.Prop[id]), baseValue)
|
||||
|
||||
// todo: 插入获取后处理函数,例如:
|
||||
// realValue = postProcessValue(realValue, id, c)
|
||||
|
||||
return realValue
|
||||
|
||||
}
|
||||
func InitDamageEffect(id int, t Effect) {
|
||||
@@ -134,7 +138,7 @@ func InitDamageEffect(id int, t Effect) {
|
||||
// 1为红伤
|
||||
func (c *Input) GetDamageEffect(id int) Effect {
|
||||
|
||||
ret, ok := Geteffect(id + 1000000)
|
||||
ret, ok := Geteffect(id + 4000000)
|
||||
if ok {
|
||||
//todo 获取前GetEffect
|
||||
return ret
|
||||
@@ -143,6 +147,16 @@ func (c *Input) GetDamageEffect(id int) Effect {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Input) GetPropEffect(id int) Effect {
|
||||
|
||||
ret, ok := Geteffect(id + 2000000)
|
||||
if ok {
|
||||
//todo 获取前GetEffect
|
||||
return ret
|
||||
//todo 获取后GetEffect
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func InitStatusEffect(id int, t Effect) {
|
||||
|
||||
NodeM[id+3000000] = t
|
||||
|
||||
Reference in New Issue
Block a user