Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
refactor(fight): 优化战斗效果中的属性检测逻辑 通过引入HasPropADD()和HasPropSub()方法来替代循环遍历, 简化了多处战斗效果代码,提高了可读性和性能。 - effect/200.go: 使用HasPropADD()替代循环检测 - effect/418.go: 使用HasPropADD()替代循环检测 - effect/437.go: 使用HasPropADD()替代循环检测 - effect/449.go: 使用HasPropSub()替代循环检测 - effect
36 lines
796 B
Go
36 lines
796 B
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
)
|
||
|
||
// 460 - m%几率令对手害怕,若对手处于能力强化状态则额外附加n%几率
|
||
type Effect460 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect460) OnSkill() bool {
|
||
baseChance := e.Args()[0].IntPart() // m%
|
||
|
||
totalChance := baseChance
|
||
if e.Ctx().Opp.HasPropADD() {
|
||
totalChance += e.Args()[1].IntPart()
|
||
}
|
||
success, _, _ := e.Input.Player.Roll(int(totalChance), 100)
|
||
|
||
if success {
|
||
fearEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Fear))
|
||
if fearEffect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, fearEffect)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 460, &Effect460{})
|
||
|
||
}
|