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,138 @@
|
||||
package avatartitle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"longheng.io/server/internal/modules/dnf/alignedcmd"
|
||||
"longheng.io/server/internal/modules/dnf/dnfenum"
|
||||
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
||||
dnfrepomemory "longheng.io/server/internal/modules/dnf/repository/memory"
|
||||
)
|
||||
|
||||
func TestDecodeTitleBookRequest(t *testing.T) {
|
||||
got, err := DecodeTitleBookRequest([]byte{
|
||||
1, 0, 0, 0,
|
||||
5, 0, 0, 0,
|
||||
0x44, 0x33, 0x22, 0x11,
|
||||
2, 0, 0, 0,
|
||||
3, 0, 0, 0,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("DecodeTitleBookRequest error = %v", err)
|
||||
}
|
||||
if got.ItemSpaceRaw != 1 || got.Slot != 5 || got.ItemID != 0x11223344 || got.Category != 2 || got.Index != 3 {
|
||||
t.Fatalf("got = %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeCompoundAvatarRequestMatchesCurrentEXEOp99(t *testing.T) {
|
||||
got, err := DecodeCompoundAvatarRequest([]byte{
|
||||
0x75, 0x00,
|
||||
0x15, 0x00, 0x15, 0xec, 0xb4, 0x06,
|
||||
0x16, 0x00, 0x15, 0xec, 0xb4, 0x06,
|
||||
0x75, 0xeb, 0xb4, 0x06,
|
||||
0x02, 0x00,
|
||||
0x00, 0x00,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.ConsumeSlot != 117 || got.Slot1 != 21 || got.ExpectedItemID1 != 112520213 ||
|
||||
got.Slot2 != 22 || got.ExpectedItemID2 != 112520213 || got.RequestItemID != 112520053 ||
|
||||
got.AbilityNo != 2 || got.RequestedItemFlag != 0 || got.MaterialClass != 0 {
|
||||
t.Fatalf("request=%+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeAvatarEmblemRequest(t *testing.T) {
|
||||
got, err := DecodeAvatarEmblemRequest([]byte{
|
||||
listTypeAvatar,
|
||||
0x05, 0x00,
|
||||
0x44, 0x33, 0x22, 0x11,
|
||||
1,
|
||||
0x06, 0x00,
|
||||
0x88, 0x77, 0x66, 0x55,
|
||||
2,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("DecodeAvatarEmblemRequest error = %v", err)
|
||||
}
|
||||
if got.TargetSlot != 5 || got.TargetItemID != 0x11223344 || len(got.Emblems) != 1 {
|
||||
t.Fatalf("got = %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerBlocksAvatarTitleAck(t *testing.T) {
|
||||
got, err := NewHandler().Handle(context.Background(), alignedcmd.Request{
|
||||
Opcode: uint16(dnfenum.CmdPacketAddAvatarSocket),
|
||||
Body: []byte{0x05, 0x00, 0x44, 0x33, 0x22, 0x11, 0x06, 0x00},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Handle error = %v", err)
|
||||
}
|
||||
if !got.Handled || got.ResponseAllowed {
|
||||
t.Fatalf("result = %+v, want handled without response", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerUsesOwnerPreflightAndStillBlocksAck(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repos := dnfrepomemory.NewMemoryGroup()
|
||||
if err := repos.Character.Save(ctx, dnfrepo.CharacterRecord{CharacterID: "88", AccountID: "acc"}); err != nil {
|
||||
t.Fatalf("Character.Save error = %v", err)
|
||||
}
|
||||
if err := repos.Inventory.Save(ctx, dnfrepo.InventoryRecord{
|
||||
CharacterID: "88",
|
||||
Slots: map[string]dnfrepo.ItemStack{
|
||||
"1:5": {ItemID: 0x11223344, Count: 1},
|
||||
"0:6": {ItemID: 7001, Count: 1},
|
||||
},
|
||||
}); err != nil {
|
||||
t.Fatalf("Inventory.Save error = %v", err)
|
||||
}
|
||||
if err := repos.Equipment.Save(ctx, dnfrepo.EquipmentRecord{
|
||||
CharacterID: "88",
|
||||
Entries: map[string]dnfrepo.EquipmentEntry{
|
||||
"0": {SlotIndex: 0, ItemID: 9001},
|
||||
},
|
||||
}); err != nil {
|
||||
t.Fatalf("Equipment.Save error = %v", err)
|
||||
}
|
||||
|
||||
got, err := NewHandler().Handle(ctx, alignedcmd.Request{
|
||||
Opcode: uint16(dnfenum.CmdPacketAddAvatarSocket),
|
||||
SelectedCharacterID: 88,
|
||||
Repositories: repos,
|
||||
Body: []byte{0x05, 0x00, 0x44, 0x33, 0x22, 0x11, 0x06, 0x00},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Handle error = %v", err)
|
||||
}
|
||||
if !got.Handled || got.ResponseAllowed {
|
||||
t.Fatalf("result = %+v, want handled without response", got)
|
||||
}
|
||||
for _, want := range []string{"avatartitle owner verified", "targetFound=true", "materialFound=true", "equipEntries=1"} {
|
||||
if !strings.Contains(got.Reason, want) {
|
||||
t.Fatalf("reason %q missing %q", got.Reason, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommandRecordsAvatarOwnerGap(t *testing.T) {
|
||||
cmd := NewEmblemCommand(alignedcmd.Request{
|
||||
AccountID: " acc ",
|
||||
SelectedCharacterID: 88,
|
||||
}, AvatarEmblemRequest{
|
||||
TargetSlot: 5,
|
||||
TargetItemID: 0x11223344,
|
||||
Emblems: []EmblemApply{{SocketIndex: 2}},
|
||||
})
|
||||
summary := cmd.String()
|
||||
for _, want := range []string{`account="acc"`, "char=88", "target=(5,287454020)", "emblems=1", "avatar owner", "USERINFO"} {
|
||||
if !strings.Contains(summary, want) {
|
||||
t.Fatalf("summary %q missing %q", summary, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user