Files
90CNServer/server/internal/services/dnfbridge/dungeon_context_op27_test.go
T
hanfuit 645b64fe21 DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go):
- GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面
- GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新
- 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新)
- 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍
- 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0)
- 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算

启动器(Python/JS):
- 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭
- GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐)
- 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
2026-11-04 14:31:55 +08:00

72 lines
2.6 KiB
Go

package dnfbridge
import (
"encoding/hex"
"errors"
"testing"
)
func TestCurrentDungeonContextBuildMinimumMatchesCurrentEXEReader(t *testing.T) {
body, err := (currentDungeonContext{}).Build()
if err != nil {
t.Fatal(err)
}
if len(body) != 37 {
t.Fatalf("op27 minimum body len=%d want=37 body=%x", len(body), body)
}
if got := hex.EncodeToString(body); got != "00000000000000000000000000000000000000000000000000000000000000000000000000" {
t.Fatalf("op27 minimum body=%s", got)
}
}
func TestCurrentDungeonContextBuildMatchesCurrentEXEReader(t *testing.T) {
body, err := (currentDungeonContext{
Value0: 1,
Value1: 2,
List0: []uint16{3},
List1: []uint16{4},
Groups: []currentDungeonContextGroup{{ObjectOrActorKey: 5, Rows: []currentDungeonContextGroupRow{{ValueA: 6, ValueB: 7, ValueC: 8}}}},
ContextValue0: 9,
ContextValue1: 10,
ContextValue2: 11,
ContextValue3: 12,
OptionalTablePresent: true,
OptionalRows: []currentDungeonContextOptionalRow{{Key: 13, Value0: 14, Value1: 15}},
BooleanLikeValue: 1,
LargeContextValue0: 16,
LargeContextValue1: 17,
BoundedMode: 7,
CappedValue: 100,
Pairs: []currentDungeonContextPair{{Key: 18, Value: 19}},
}).Build()
if err != nil {
t.Fatal(err)
}
const want = "010000000200000001030001040001050001060000000700000008000000090000000a000b000c00000001010d0000000e000f00011000000011000000076400011200000013000000"
if got := hex.EncodeToString(body); got != want {
t.Fatalf("op27 body=%s want=%s", got, want)
}
}
func TestCurrentDungeonContextBuildRejectsUnsafeRanges(t *testing.T) {
tests := []struct {
name string
packet currentDungeonContext
want error
}{
{name: "first list", packet: currentDungeonContext{List0: make([]uint16, 9)}, want: errDungeonContextListCount},
{name: "second list", packet: currentDungeonContext{List1: make([]uint16, 9)}, want: errDungeonContextListCount},
{name: "optional rows without flag", packet: currentDungeonContext{OptionalRows: []currentDungeonContextOptionalRow{{}}}, want: errDungeonContextOptionalCount},
{name: "bounded mode", packet: currentDungeonContext{BoundedMode: 8}, want: errDungeonContextBoundedMode},
{name: "capped value", packet: currentDungeonContext{CappedValue: 101}, want: errDungeonContextCappedValue},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, err := test.packet.Build()
if !errors.Is(err, test.want) {
t.Fatalf("error=%v want=%v", err, test.want)
}
})
}
}