- 修改 `ChangePet` 方法,记录初始攻击值并在切换时正确传递 - 简化多个 effect 的初始化方式,移除冗余的 `EffectNode` 字段 - 增强 Effect58 和 Effect67 的逻辑判断,增加空指针检查和类型判断 - 引入 decimal 包用于精确血量计算 - 统一 `Switch` 接口参数,增强状态类和节点类的兼容性 - 修正部分技能效果的触发条件和持续时间设置 - 调整回合结束逻辑,注释掉原有后手增益机制
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
/**
|
|
* 当次攻击击败对方时减少对方下次出战精灵的最大体力1/n
|
|
*/
|
|
type Effect67 struct {
|
|
node.EffectNode
|
|
can bool
|
|
}
|
|
|
|
func init() {
|
|
t := &Effect67{}
|
|
|
|
input.InitEffect(input.EffectType.Skill, 67, t)
|
|
|
|
}
|
|
func (e *Effect67) OnSkill() bool {
|
|
if !e.Hit() {
|
|
return true
|
|
}
|
|
e.can = true
|
|
return true
|
|
}
|
|
|
|
// 重写死亡,如果击败,就出触发死亡事件,判断是目标精灵
|
|
func (e *Effect67) Switch(in *input.Input, at info.AttackValue, outpet *info.BattlePetEntity) bool {
|
|
//技能效果还没生效
|
|
if !e.can {
|
|
return true
|
|
}
|
|
//如果是我方切精灵
|
|
if in == e.Ctx().Our {
|
|
return true
|
|
}
|
|
|
|
if outpet.NotAlive { //如果上一只已经死亡后切换的,对对手直接施加扣血
|
|
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
|
Type: info.DamageType.Fixed,
|
|
Damage: decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.MaxHp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))),
|
|
})
|
|
|
|
}
|
|
|
|
return true
|
|
}
|
|
func (e *Effect67) SetArgs(t *input.Input, a ...int) {
|
|
|
|
e.EffectNode.SetArgs(t, a...)
|
|
e.EffectNode.Duration(1)
|
|
|
|
}
|