refactor(fight/effect): 重构技能效果实现 移除独立的Effect112实现,将其整合到selfkill模块中。 通过继承SelfKill结构体来实现技能112的效果,提高代码复用性。 同时修复了原Effect112中的方法命名规范问题,将OnSkill改为Skill_Use。 删除了无用的Effect59 SwitchIn方法。 ```
This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
package effect
|
|
||||||
|
|
||||||
import (
|
|
||||||
"blazing/logic/service/fight/info"
|
|
||||||
"blazing/logic/service/fight/input"
|
|
||||||
"blazing/logic/service/fight/node"
|
|
||||||
|
|
||||||
"github.com/alpacahq/alpacadecimal"
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 牺牲全部体力造成对手250~300点伤害,造成致命伤害时,对手剩下1点体力
|
|
||||||
*/
|
|
||||||
type Effect112 struct {
|
|
||||||
node.EffectNode
|
|
||||||
can bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
|
|
||||||
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 命中之后
|
|
||||||
func (e *Effect112) OnSkill() bool {
|
|
||||||
|
|
||||||
e.can = true
|
|
||||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
|
||||||
Type: info.DamageType.Fixed,
|
|
||||||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
|
||||||
})
|
|
||||||
n := int64(e.Input.FightC.GetRand().Int31n(int32(50+1))) + 250
|
|
||||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
|
||||||
Type: info.DamageType.Fixed,
|
|
||||||
Damage: alpacadecimal.Max(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
|
|
||||||
})
|
|
||||||
e.Ctx().Our.CurrentPet.NotAlive = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
@@ -30,6 +30,7 @@ func (e *SelfKill) OnSkill() bool {
|
|||||||
Type: info.DamageType.Fixed,
|
Type: info.DamageType.Fixed,
|
||||||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
||||||
})
|
})
|
||||||
|
e.can = true
|
||||||
e.Ctx().Our.CurrentPet.NotAlive = true
|
e.Ctx().Our.CurrentPet.NotAlive = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -38,17 +39,6 @@ func (e *SelfKill) OnSkill() bool {
|
|||||||
func (e *SelfKill) SwitchOut(in *input.Input) bool {
|
func (e *SelfKill) SwitchOut(in *input.Input) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (e *Effect59) SwitchIn(in *input.Input) bool {
|
|
||||||
// 1. 检查效果是否生效(当次攻击有效)
|
|
||||||
|
|
||||||
//
|
|
||||||
if in != e.Ctx().Our {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
e.can = true
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消耗自身全部体力(体力降到0), 使下一只出战精灵的 battle_lv1 和 battle_lv2 能力提升1个等级
|
* 消耗自身全部体力(体力降到0), 使下一只出战精灵的 battle_lv1 和 battle_lv2 能力提升1个等级
|
||||||
@@ -143,3 +133,32 @@ func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 牺牲全部体力造成对手250~300点伤害,造成致命伤害时,对手剩下1点体力
|
||||||
|
*/
|
||||||
|
type Effect112 struct {
|
||||||
|
SelfKill
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 命中之后
|
||||||
|
func (e *Effect112) Skill_Use() bool {
|
||||||
|
|
||||||
|
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||||
|
Type: info.DamageType.Fixed,
|
||||||
|
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
||||||
|
})
|
||||||
|
n := int64(e.Input.FightC.GetRand().Int31n(int32(50+1))) + 250
|
||||||
|
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||||
|
Type: info.DamageType.Fixed,
|
||||||
|
Damage: alpacadecimal.Max(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
|
||||||
|
})
|
||||||
|
e.Ctx().Our.CurrentPet.NotAlive = true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user