87 lines
2.0 KiB
Go
87 lines
2.0 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
|
)
|
|
|
|
// Effect 578: {0}回合内对手所有属性技能命中率减少{1}%
|
|
type Effect578 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect578) SkillHit_ex() bool {
|
|
|
|
// 技能为空时不处理
|
|
skill := e.Ctx().SkillEntity
|
|
if skill == nil {
|
|
return true
|
|
}
|
|
if skill.AttackTime == 2 {
|
|
return true
|
|
}
|
|
if skill.Category() != info.Category.STATUS {
|
|
return true
|
|
}
|
|
success, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
|
|
if success {
|
|
skill.SetMiss()
|
|
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// HitReductionEffect 是一个临时效果,降低对手属性技能的命中率
|
|
type HitReductionEffect struct {
|
|
node.EffectNode
|
|
roundsLeft int
|
|
reduction alpacadecimal.Decimal
|
|
source *input.Input
|
|
target *input.Input
|
|
}
|
|
|
|
// SkillHit 在对手使用技能时触发
|
|
func (h *HitReductionEffect) SkillHit() bool {
|
|
// 这里需要降低属性技能的命中率
|
|
// 注意:这只是一个框架,实际实现需要根据具体技能类型调整
|
|
if h.Ctx().SkillEntity != nil {
|
|
// 如果是属性技能,降低命中率
|
|
// 这里假定属性技能的分类是通过某个属性判断
|
|
// 为了简化,这里只做概念性的实现
|
|
h.Ctx().SkillEntity.Accuracy = h.Ctx().SkillEntity.Accuracy.Sub(h.reduction)
|
|
if h.Ctx().SkillEntity.Accuracy.Cmp(alpacadecimal.Zero) < 0 {
|
|
h.Ctx().SkillEntity.Accuracy = alpacadecimal.Zero
|
|
}
|
|
}
|
|
|
|
// 减少剩余回合数
|
|
h.roundsLeft--
|
|
if h.roundsLeft <= 0 {
|
|
return false // 效果结束
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// Duration 设置持续回合数
|
|
func (h *HitReductionEffect) Duration(rounds int) {
|
|
h.roundsLeft = rounds
|
|
}
|
|
|
|
// SetArgs 设置参数
|
|
func (h *HitReductionEffect) SetArgs(source *input.Input, args ...int) {
|
|
h.source = source
|
|
if len(args) > 1 {
|
|
h.roundsLeft = args[0]
|
|
h.reduction = alpacadecimal.NewFromInt(int64(args[1]))
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 578, &Effect578{})
|
|
}
|