服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
package profile
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type RequestEvent struct {
|
|
AccountID string `json:"account_id"`
|
|
SessionID string `json:"session_id,omitempty"`
|
|
Route string `json:"route,omitempty"`
|
|
RequestID string `json:"request_id,omitempty"`
|
|
IdempotencyKey string `json:"idempotency_key,omitempty"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
StartedAt time.Time `json:"started_at"`
|
|
}
|
|
|
|
type RequestResult struct {
|
|
OK bool `json:"ok"`
|
|
Error string `json:"error,omitempty"`
|
|
Duration time.Duration `json:"duration"`
|
|
}
|
|
|
|
type RequestHook interface {
|
|
BeforeProfileRequest(context.Context, RequestEvent) context.Context
|
|
AfterProfileRequest(context.Context, RequestEvent, RequestResult)
|
|
}
|
|
|
|
type RequestHooks []RequestHook
|
|
|
|
func (hooks RequestHooks) Run(ctx context.Context, event RequestEvent, handler func(context.Context) error) error {
|
|
if ctx == nil {
|
|
ctx = context.Background()
|
|
}
|
|
if handler == nil {
|
|
return fmt.Errorf("profile request handler is required")
|
|
}
|
|
if event.StartedAt.IsZero() {
|
|
event.StartedAt = time.Now().UTC()
|
|
} else {
|
|
event.StartedAt = event.StartedAt.UTC()
|
|
}
|
|
event.Metadata = cloneRequestMetadata(event.Metadata)
|
|
for _, hook := range hooks {
|
|
if hook == nil {
|
|
continue
|
|
}
|
|
next := hook.BeforeProfileRequest(ctx, event)
|
|
if next != nil {
|
|
ctx = next
|
|
}
|
|
}
|
|
err := handler(ctx)
|
|
result := RequestResult{
|
|
OK: err == nil,
|
|
Duration: time.Since(event.StartedAt),
|
|
}
|
|
if err != nil {
|
|
result.Error = err.Error()
|
|
}
|
|
for _, hook := range hooks {
|
|
if hook != nil {
|
|
hook.AfterProfileRequest(ctx, event, result)
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
func cloneRequestMetadata(in map[string]string) map[string]string {
|
|
if len(in) == 0 {
|
|
return nil
|
|
}
|
|
out := make(map[string]string, len(in))
|
|
for key, value := range in {
|
|
out[key] = value
|
|
}
|
|
return out
|
|
}
|