服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
94 lines
2.3 KiB
Go
94 lines
2.3 KiB
Go
package equip
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
dnfpvf "longheng.io/server/internal/modules/dnf/pvf"
|
|
)
|
|
|
|
func TestLoadBuildsEquipTable(t *testing.T) {
|
|
index := testIndex(t)
|
|
table, err := Load(context.Background(), index, Options{})
|
|
if err != nil {
|
|
t.Fatalf("load equip: %v", err)
|
|
}
|
|
if snapshot := table.Snapshot(); snapshot.Items != 1 {
|
|
t.Fatalf("unexpected snapshot: %+v", snapshot)
|
|
}
|
|
item, ok := table.Find(1001)
|
|
if !ok {
|
|
t.Fatalf("expected item")
|
|
}
|
|
if item.Name != "short sword" || item.Kind != "weapon" || item.Slot != "weapon" || item.Level != 12 {
|
|
t.Fatalf("unexpected item: %+v", item)
|
|
}
|
|
if item.Stats["physical_attack"] != 34 || item.Stats["attack_speed"] != 1.5 {
|
|
t.Fatalf("unexpected stats: %+v", item.Stats)
|
|
}
|
|
item.Stats["physical_attack"] = 1
|
|
again, _ := table.FindPath("./EQUIPMENT/weapon/sword.equ")
|
|
if again.Stats["physical_attack"] != 34 {
|
|
t.Fatalf("table returned mutable stats: %+v", again.Stats)
|
|
}
|
|
}
|
|
|
|
func TestLoadRequiresIndex(t *testing.T) {
|
|
_, err := Load(context.Background(), nil, Options{})
|
|
if !errors.Is(err, ErrIndexRequired) {
|
|
t.Fatalf("expected ErrIndexRequired, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestLoadReportsEmptyList(t *testing.T) {
|
|
index, err := dnfpvf.Build(context.Background(), textSource{
|
|
"equipment/equipment.lst": "1001 `equipment/weapon/missing.equ`\n",
|
|
}, dnfpvf.BuildOptions{Paths: []string{"equipment/equipment.lst"}})
|
|
if err != nil {
|
|
t.Fatalf("build index: %v", err)
|
|
}
|
|
_, err = Load(context.Background(), index, Options{})
|
|
if !errors.Is(err, ErrListEmpty) {
|
|
t.Fatalf("expected ErrListEmpty, got %v", err)
|
|
}
|
|
}
|
|
|
|
func testIndex(t *testing.T) *dnfpvf.Index {
|
|
t.Helper()
|
|
index, err := dnfpvf.Build(context.Background(), textSource{
|
|
"equipment/equipment.lst": "1001 `equipment/weapon/sword.equ`\n",
|
|
"equipment/weapon/sword.equ": `
|
|
[name]
|
|
` + "`short sword`" + `
|
|
[equipment type]
|
|
` + "`weapon`" + `
|
|
[attach type]
|
|
` + "`weapon`" + `
|
|
[minimum level]
|
|
12
|
|
[rarity]
|
|
` + "`rare`" + `
|
|
[physical attack]
|
|
34
|
|
[attack speed]
|
|
1.5
|
|
`,
|
|
}, dnfpvf.BuildOptions{Lists: []string{DefaultList}})
|
|
if err != nil {
|
|
t.Fatalf("build index: %v", err)
|
|
}
|
|
return index
|
|
}
|
|
|
|
type textSource map[string]string
|
|
|
|
func (s textSource) ReadText(relativePath string) (string, error) {
|
|
for key, value := range s {
|
|
if pathKey(key) == pathKey(relativePath) {
|
|
return value, nil
|
|
}
|
|
}
|
|
return "", dnfpvf.ErrDocNotFound
|
|
}
|