80 lines
2.0 KiB
Go
80 lines
2.0 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// 49. 受到物理攻击或特殊攻击后,下n回合受物理攻击或特殊攻击伤害减免m%(a1: n, a2: m)
|
||
// TODO: 需要记录受到的攻击类型并实现持续减伤效果
|
||
type NewSel49 struct {
|
||
NewSel0
|
||
|
||
// 记录受到攻击的类型:1=物理攻击,2=特殊攻击
|
||
attackType int
|
||
// 记录剩余减伤回合数
|
||
remainingTurns int
|
||
}
|
||
|
||
func (e *NewSel49) Action_end_ex() bool {
|
||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||
return true
|
||
}
|
||
|
||
// 记录受到攻击的类型
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
if e.Ctx().SkillEntity.Category() == info.Category.PHYSICAL {
|
||
e.attackType = 1
|
||
e.remainingTurns = int(e.Args()[0].IntPart())
|
||
} else if e.Ctx().SkillEntity.Category() == info.Category.SPECIAL {
|
||
e.attackType = 2
|
||
e.remainingTurns = int(e.Args()[0].IntPart())
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *NewSel49) DamageDivEx(t *info.DamageZone) bool {
|
||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||
return true
|
||
}
|
||
|
||
// 检查是否还有减伤效果
|
||
if e.remainingTurns <= 0 {
|
||
return true
|
||
}
|
||
|
||
// 检查攻击类型是否匹配
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
attackCategory := e.Ctx().SkillEntity.Category()
|
||
if (e.attackType == 1 && attackCategory == info.Category.PHYSICAL) ||
|
||
(e.attackType == 2 && attackCategory == info.Category.SPECIAL) {
|
||
// 减免m%伤害
|
||
percent := alpacadecimal.NewFromInt(100).Sub(e.Args()[1])
|
||
t.Damage = t.Damage.Mul(percent).Div(alpacadecimal.NewFromInt(100))
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *NewSel49) TurnEnd() {
|
||
// 每回合减少减伤效果剩余回合数
|
||
if e.remainingTurns > 0 {
|
||
e.remainingTurns--
|
||
}
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.NewSel, 49, &NewSel49{})
|
||
}
|