refactor(socket): 移除未使用的网络相关导入和注释掉的 RST 攻击检测逻辑 移除了 `ServerEvent.go` 中未使用的 `net` 和 `strings` 包导入。同时, 将原有的 RST 攻击检测及防护逻辑代码注释掉,便于后续重新设计或彻底删除。 fix(logic): 调整 fight pool 初始化与释放策略 将 `fight/action.go` 中的 `Fightpool` 类型从 `*ants.MultiPool` 改为 `*ants.Pool`,并调整其初始化方式为 `NewPool(-1)` 以适应动态扩容。 此外,在 `main.go` 中将 `ReleaseTimeout` 参数由 100 调整为 0, 确保立即清理超时任务。 feat(fight): 优化战斗输入状态重置逻辑 在 `fight/action.go` 的 `ReadyFight` 方法中提前设置 `GetInputByPlayer(c, false).Finished = true`,避免重复赋值。 同时更新了状态睡眠效果的处理流程,并简化了输入模块的状态缓存机制, 移除了冗余的 `Initeffectcache` 函数调用及相关逻辑。 perf(fight): 动态计算玩家动作等待时间 在 `loop.go` 的 `collectPlayerActions` 方法中, 将固定超时时间替换为基于 `waittime` 的动态等待时间计算公式, 提高响应灵活性。同时修复通道关闭判断条件以增强稳定性。 refactor(fight): 更新技能效果解析和状态持续逻辑 修改 `input.go` 中 `GenSataus` 方法以正确初始化状态数组; 在 `Turn.go` 中重构 `Turn_End` 方法内的执行逻辑, 确保仅在我方后手时增加回合数,提升战斗流程准确性。 chore(service): 删除废弃文件 SocketHandler_Tomee.go 完全移除已弃用的 `SocketHandler_Tomee.go` 文件及其全部内容, 减少项目冗余代码。 ```
130 lines
3.1 KiB
Go
130 lines
3.1 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"
|
||
)
|
||
|
||
type BaseSataus struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
// /重写切换事件
|
||
func (e *BaseSataus) Switch(in *input.Input, outpet, inpet *info.BattlePetEntity) bool {
|
||
|
||
//状态如果是我方切换,那么就消除掉状态效果
|
||
if e.Input == e.Ctx().Our {
|
||
//下场,执行消回合效果
|
||
// e.ctx.Our.CancelAll()
|
||
///我放下场
|
||
e.Alive(false)
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 施加一个基类effect
|
||
type EffectStatus struct {
|
||
BaseSataus
|
||
Status info.EnumBattleStatus
|
||
}
|
||
|
||
type StatusNotSkill struct {
|
||
EffectStatus
|
||
}
|
||
|
||
// 不能出手
|
||
func (e *StatusNotSkill) Skill_Hit_Pre() bool {
|
||
|
||
return false
|
||
|
||
}
|
||
|
||
type StatusSleep struct { //睡眠不能出手 ,这个挂载到对面来实现对方攻击后解除睡眠效果
|
||
BaseSataus
|
||
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().Category() != info.Category.STATUS {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 扣血类
|
||
type DrainHP struct {
|
||
EffectStatus
|
||
|
||
damage decimal.Decimal
|
||
}
|
||
|
||
func (e *DrainHP) Skill_Hit_Pre() bool {
|
||
e.damage = decimal.NewFromUint64(uint64(e.Ctx().Our.CurrentPet.Info.MaxHp)).
|
||
Div(decimal.NewFromInt(8))
|
||
|
||
e.Ctx().Our.Damage(e.Input, &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(e.Ctx().Our, 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{}) //睡眠
|
||
}
|