build(go): 升级 Go 版本至 1.20 并更新依赖包 将项目 Go 版本从 1.18 升级至 1.20,并同步更新了相关模块依赖。 同时替换 decimal 库为 alpacadecimal,以提升数值计算精度和性能。 - 升级 Go 模块版本 - 替换 github.com/govalues/decimal 为 github.com/alpacahq/alpacadecimal - 更新多个间接依赖包版本 - 调整相关代码中 decimal
42 lines
938 B
Go
42 lines
938 B
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// 自身体力越少则威力越大
|
||
type Effect100 struct {
|
||
node.EffectNode
|
||
can bool
|
||
}
|
||
|
||
func (e *Effect100) Skill_Hit() bool {
|
||
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
//技能威力=【165-65*【当前体力百分比】】,任意体力百分比对应的威力浮动范围∈[-10,+10]
|
||
|
||
odp := e.GetInput().CurrentPet.GetHP().Div(e.GetInput().CurrentPet.GetMaxHP()).Mul(alpacadecimal.NewFromInt(65))
|
||
|
||
if odp.Cmp(alpacadecimal.NewFromInt(165)) == -1 {
|
||
e.Ctx().SkillEntity.Power = int(alpacadecimal.NewFromInt(165).Sub(odp).IntPart())
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// ---- 注册所有效果 ----
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 100, &Effect100{})
|
||
}
|