Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
refactor(fight): 移除能力操作类型枚举并简化属性设置方法 移除了 info.EnumAbilityOpType 枚举类型及其相关常量定义, 重构了 SetProp 方法调用,不再传递操作类型参数, 通过检查等级正负值来判断是增加还是减少属性, 减少了代码复杂度并统一了属性变更的处理逻辑。 ```
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/action"
|
||
"blazing/logic/service/fight/input"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// 16. hp 与 battle_lv 的某一种绑定, 自身体力每减少1/8, 则该battle_lv上升1个等级, 最高到12;(a1: which blv)
|
||
// TODO: 实现hp 与 battle_lv 的某一种绑定, 自身体力每减少1/8, 则该battle_lv上升1个等级, 最高到12;(a1: which blv)的核心逻辑
|
||
type NewSel16 struct {
|
||
NewSel0
|
||
curhp alpacadecimal.Decimal
|
||
}
|
||
|
||
func (e *NewSel16) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
||
|
||
// fmt.Println(e.ID().GetCatchTime(), e.Ctx().Our.CurrentPet.Info.CatchTime)
|
||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||
return
|
||
}
|
||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
if e.curhp.IntPart() == 0 {
|
||
e.curhp = maxHP
|
||
|
||
}
|
||
|
||
//如果当前被扣除的血量少于当前血,说明我方回血
|
||
if e.curhp.Cmp(e.Ctx().Our.CurrentPet.GetHP()) == -1 {
|
||
e.curhp = e.Ctx().Our.CurrentPet.GetHP()
|
||
return
|
||
}
|
||
if e.curhp.Sub(e.Ctx().Our.CurrentPet.GetHP()).Cmp(maxHP.Div(alpacadecimal.NewFromInt(8))) == 1 {
|
||
e.curhp = e.Ctx().Our.CurrentPet.GetHP()
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[0].IntPart()), 1)
|
||
}
|
||
|
||
}
|
||
func init() {
|
||
input.InitEffect(input.EffectType.NewSel, 16, &NewSel16{})
|
||
}
|