refactor(socket): 优化消息处理逻辑,避免顺序执行问题 将消息处理的循环从协程外部移入协程内部,确保每个消息在独立的 goroutine 中处理, 避免因并发导致的消息顺序错乱问题。同时移除了多余的空行,使代码更简洁。 fix(controller): 为低 ID 用户设置 VIP 标志 在 COMMEND_ONLINE 接口逻辑中,新增对 UserID 小于 10000 的用户设置 IsVip = 1, 用于标识测试或特殊用户身份。 ref
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
"math/rand"
|
|
)
|
|
|
|
// -----------------------------------------------------------
|
|
// 威力随机效果
|
|
// -----------------------------------------------------------
|
|
// 威力将在 [Min, Max] 区间内随机取值
|
|
type EffectRandomPower struct {
|
|
node.EffectNode
|
|
Min int
|
|
Max int
|
|
}
|
|
|
|
// -----------------------------------------------------------
|
|
// 初始化注册
|
|
// -----------------------------------------------------------
|
|
func init() {
|
|
registerRandomPower(61, 50, 150)
|
|
registerRandomPower(70, 140, 220)
|
|
registerRandomPower(118, 140, 180)
|
|
}
|
|
|
|
// -----------------------------------------------------------
|
|
// 工厂函数:注册不同威力范围的技能效果
|
|
// -----------------------------------------------------------
|
|
func registerRandomPower(effectID, min, max int) {
|
|
input.InitEffect(input.EffectType.Skill, effectID, &EffectRandomPower{
|
|
Min: min,
|
|
Max: max,
|
|
})
|
|
}
|
|
|
|
// -----------------------------------------------------------
|
|
// 命中时触发
|
|
// -----------------------------------------------------------
|
|
func (e *EffectRandomPower) Skill_Hit(ctx input.Ctx) bool {
|
|
if e.Max <= e.Min {
|
|
ctx.SkillEntity.Power = e.Min
|
|
return true
|
|
}
|
|
|
|
// 如果 FightC 没提供随机器,使用 math/rand 兜底
|
|
var n int
|
|
if e.Input != nil && e.Input.FightC != nil {
|
|
n = int(e.Input.FightC.GetRand().Int31n(int32(e.Max-e.Min+1))) + e.Min
|
|
} else {
|
|
n = rand.Intn(e.Max-e.Min+1) + e.Min
|
|
}
|
|
|
|
ctx.SkillEntity.Power = n
|
|
return true
|
|
}
|