服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
71 lines
2.0 KiB
Go
71 lines
2.0 KiB
Go
package emotion
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
"time"
|
|
|
|
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
|
dnfrepomemory "longheng.io/server/internal/modules/dnf/repository/memory"
|
|
)
|
|
|
|
func TestOwnerApplyPersistsEmotionProtocolFields(t *testing.T) {
|
|
ctx := context.Background()
|
|
repos := dnfrepomemory.NewMemoryGroup()
|
|
if err := repos.Character.Save(ctx, dnfrepo.CharacterRecord{
|
|
CharacterID: "19",
|
|
AccountID: "account-1",
|
|
Stats: map[string]int64{"gold": 100, "emotion_index": 0x1234, "action_byte": 0x56},
|
|
}); err != nil {
|
|
t.Fatalf("save character: %v", err)
|
|
}
|
|
owner, err := NewOwner(repos)
|
|
if err != nil {
|
|
t.Fatalf("NewOwner: %v", err)
|
|
}
|
|
updatedAt := time.Date(2026, 7, 26, 12, 0, 0, 0, time.FixedZone("CST", 8*60*60))
|
|
result, err := owner.Apply(ctx, Command{
|
|
AccountID: "account-1",
|
|
SelectedCharacterID: 19,
|
|
EmotionIndex: 7,
|
|
UpdatedAt: updatedAt,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("Apply: %v", err)
|
|
}
|
|
if result.CharacterID != "19" || result.EmotionIndex != 7 {
|
|
t.Fatalf("result = %+v", result)
|
|
}
|
|
character, found, err := repos.Character.Load(ctx, "19")
|
|
if err != nil || !found {
|
|
t.Fatalf("load character found=%t err=%v", found, err)
|
|
}
|
|
if character.Stats["mood_value"] != 7 || character.Stats["emotion_index"] != 0x1234 || character.Stats["action_byte"] != 0x56 || character.Stats["gold"] != 100 {
|
|
t.Fatalf("stats = %+v", character.Stats)
|
|
}
|
|
}
|
|
|
|
func TestOwnerApplyRejectsAnotherAccount(t *testing.T) {
|
|
ctx := context.Background()
|
|
repos := dnfrepomemory.NewMemoryGroup()
|
|
if err := repos.Character.Save(ctx, dnfrepo.CharacterRecord{
|
|
CharacterID: "19",
|
|
AccountID: "account-1",
|
|
}); err != nil {
|
|
t.Fatalf("save character: %v", err)
|
|
}
|
|
owner, err := NewOwner(repos)
|
|
if err != nil {
|
|
t.Fatalf("NewOwner: %v", err)
|
|
}
|
|
_, err = owner.Apply(ctx, Command{
|
|
AccountID: "account-2",
|
|
SelectedCharacterID: 19,
|
|
EmotionIndex: 7,
|
|
})
|
|
if !errors.Is(err, ErrAccountMismatch) {
|
|
t.Fatalf("Apply error = %v, want ErrAccountMismatch", err)
|
|
}
|
|
}
|