DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
This commit is contained in:
commit
645b64fe21
4388 files changed
+1405457
No files matched your search
@@ -0,0 +1,98 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"longheng.io/server/internal/platform/db"
|
||||
)
|
||||
|
||||
// MailboxRepository persists the selected character's mailbox state.
|
||||
type MailboxRepository interface {
|
||||
db.Store[MailboxRecord]
|
||||
}
|
||||
|
||||
// MailboxRecord is the durable mailbox aggregate for one character.
|
||||
type MailboxRecord struct {
|
||||
CharacterID string `json:"character_id"`
|
||||
Mails map[string]MailRecord `json:"mails,omitempty"`
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
// MailRecord is one server-owned mail. Attachments are claimed exactly once.
|
||||
type MailRecord struct {
|
||||
MailID string `json:"mail_id"`
|
||||
SenderCharacterID string `json:"sender_character_id,omitempty"`
|
||||
SenderName string `json:"sender_name,omitempty"`
|
||||
RecipientCharacterID string `json:"recipient_character_id,omitempty"`
|
||||
RecipientName string `json:"recipient_name,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Body string `json:"body,omitempty"`
|
||||
Gold int64 `json:"gold,omitempty"`
|
||||
Attachments []MailAttachment `json:"attachments,omitempty"`
|
||||
Read bool `json:"read,omitempty"`
|
||||
Claimed bool `json:"claimed,omitempty"`
|
||||
Deleted bool `json:"deleted,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
ExpireAt time.Time `json:"expire_at,omitempty"`
|
||||
Metadata map[string]string `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// MailAttachment is an inventory item attached to one mail.
|
||||
type MailAttachment struct {
|
||||
ItemID int64 `json:"item_id"`
|
||||
Count int64 `json:"count"`
|
||||
Bind bool `json:"bind,omitempty"`
|
||||
ExpireAt time.Time `json:"expire_at,omitempty"`
|
||||
RawEntry []byte `json:"raw_entry,omitempty"`
|
||||
Extra map[string]string `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
// MailboxField represents mailbox fields that support partial persistence.
|
||||
type MailboxField string
|
||||
|
||||
const (
|
||||
MailboxFieldMails MailboxField = "mails"
|
||||
)
|
||||
|
||||
// SaveMailboxFields persists only selected mailbox fields when supported.
|
||||
func SaveMailboxFields(ctx context.Context, repo MailboxRepository, record MailboxRecord, fields ...MailboxField) error {
|
||||
return db.SaveFields(ctx, repo, record, MailboxFields.Normalize, fields...)
|
||||
}
|
||||
|
||||
// CloneMailbox deep-copies a mailbox aggregate.
|
||||
func CloneMailbox(record MailboxRecord) MailboxRecord {
|
||||
record.Mails = cloneMailMap(record.Mails)
|
||||
return record
|
||||
}
|
||||
|
||||
func MailboxKey(record MailboxRecord) string {
|
||||
return strings.TrimSpace(record.CharacterID)
|
||||
}
|
||||
|
||||
func cloneMailMap(in map[string]MailRecord) map[string]MailRecord {
|
||||
if len(in) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make(map[string]MailRecord, len(in))
|
||||
for key, value := range in {
|
||||
value.Attachments = cloneMailAttachments(value.Attachments)
|
||||
value.Metadata = cloneStringMap(value.Metadata)
|
||||
out[key] = value
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func cloneMailAttachments(in []MailAttachment) []MailAttachment {
|
||||
if len(in) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]MailAttachment, len(in))
|
||||
for idx, value := range in {
|
||||
value.RawEntry = append([]byte(nil), value.RawEntry...)
|
||||
value.Extra = cloneStringMap(value.Extra)
|
||||
out[idx] = value
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user