114 lines
2.8 KiB
Go
114 lines
2.8 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
|
||
"github.com/gogf/gf/v2/util/gconv"
|
||
"github.com/shopspring/decimal"
|
||
)
|
||
|
||
// 施加一个基类effect
|
||
type EffectStatus struct {
|
||
node.EffectNode
|
||
Status info.EnumBattleStatus
|
||
}
|
||
|
||
type StatusNotSkill struct {
|
||
EffectStatus
|
||
}
|
||
|
||
// 不能出手
|
||
func (e *StatusNotSkill) Skill_Hit_Pre() bool {
|
||
|
||
return false
|
||
|
||
}
|
||
|
||
type StatusSleep struct { //睡眠不能出手 ,这个挂载到对面来实现对方攻击后解除睡眠效果
|
||
StatusNotSkill
|
||
can bool
|
||
}
|
||
|
||
func (e *StatusSleep) Skill_Hit_Pre() bool {
|
||
e.StatusNotSkill.Skill_Hit_Pre()
|
||
e.can = true
|
||
return false
|
||
|
||
}
|
||
func (e *StatusSleep) Skill_Use_ex() bool {
|
||
if !e.can {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||
t := e.Input.GetEffect(input.EffectType.Status, int(info.PetStatus.Sleep))
|
||
if t != nil {
|
||
t.Alive(false)
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 扣血类
|
||
type DrainHP struct {
|
||
EffectStatus
|
||
|
||
damage decimal.Decimal
|
||
}
|
||
|
||
func (e *DrainHP) Skill_Hit_Pre() bool {
|
||
e.damage = decimal.NewFromUint64(uint64(e.Input.CurrentPet.Info.MaxHp)).
|
||
Div(decimal.NewFromInt(8))
|
||
|
||
e.Input.Damage(&info.DamageZone{
|
||
|
||
Type: info.DamageType.True,
|
||
Damage: e.damage,
|
||
})
|
||
|
||
return true
|
||
}
|
||
|
||
// 被寄生种子 扣血类
|
||
type DrainedHP struct {
|
||
DrainHP
|
||
}
|
||
|
||
func (e *DrainedHP) Skill_Hit_Pre() bool {
|
||
|
||
if gconv.Int(e.Input.CurrentPet.Type) == 1 {
|
||
return true
|
||
}
|
||
e.DrainHP.Skill_Hit_Pre() //先调用父类扣血
|
||
//TODO 寄生种子 给对面回血,待实现回血buff
|
||
|
||
//这个回血不属于任何类型,所以不会被阻止回血
|
||
e.Ctx().Opp.Heal(nil, e.damage)
|
||
// input.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8
|
||
|
||
return true
|
||
|
||
}
|
||
func init() {
|
||
//麻痹,疲惫,害怕,石化,都是无法行动
|
||
|
||
tt := func(t info.EnumBattleStatus, f *StatusNotSkill) {
|
||
|
||
f.Status = t
|
||
input.InitEffect(input.EffectType.Status, int(t), f)
|
||
}
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.DrainedHP), &DrainedHP{}) //寄生种子
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.Poisoned), &DrainHP{}) //中毒
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.Frozen), &DrainHP{}) //冻伤
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.Burned), &DrainHP{}) //烧伤
|
||
tt(info.PetStatus.Paralysis, &StatusNotSkill{}) //麻痹
|
||
tt(info.PetStatus.Tired, &StatusNotSkill{}) //疲惫
|
||
tt(info.PetStatus.Fear, &StatusNotSkill{}) //害怕
|
||
tt(info.PetStatus.Petrified, &StatusNotSkill{}) //石化
|
||
input.InitEffect(input.EffectType.Status, 8, &StatusSleep{}) //睡眠
|
||
}
|