Files
90CNServer/pvf/services/variant_service_test.go
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

73 lines
2.1 KiB
Go

package services
import (
"os"
"path/filepath"
"strings"
"testing"
)
// TestVariantArchiveService drives the UI-facing services against the archive
// supplied via PVF_TESTFILE. This variant uses non-standard per-section LCG
// seeds, so it exercises the parser's seed recovery through the real open,
// tree, search and read paths rather than the parser alone.
func TestVariantArchiveService(t *testing.T) {
src := os.Getenv("PVF_TESTFILE")
if src == "" {
t.Skip("PVF_TESTFILE 未设置")
}
// Hard-link into a temp dir so nothing touches the source archive.
link := filepath.Join(t.TempDir(), "Script.pvf")
if err := os.Link(src, link); err != nil {
data, err := os.ReadFile(src)
if err != nil {
t.Fatal(err)
}
if err := os.WriteFile(link, data, 0o644); err != nil {
t.Fatal(err)
}
}
c := NewCore()
t.Cleanup(c.closeArchive)
svc := NewArchiveService(c)
info, err := svc.Open(link)
if err != nil {
t.Fatalf("open: %v", err)
}
if info.FileCount <= 0 {
t.Fatalf("file count = %d", info.FileCount)
}
t.Logf("opened: %d files, %d groups", info.FileCount, info.GroupCount)
root, err := svc.ListChildren("")
if err != nil || len(root) == 0 {
t.Fatalf("root children: %v, %d", err, len(root))
}
if monster, err := svc.ListChildren("monster"); err != nil || len(monster) == 0 {
t.Fatalf("monster dir: %v, %d", err, len(monster))
}
c.startSearchIndex()
waitForSearchIndex(t, c)
res, err := svc.Search("100300001", 0, 10)
if err != nil || len(res.Hits) == 0 {
t.Fatalf("search: %v, %d hits", err, len(res.Hits))
}
hit := res.Hits[0]
if !strings.HasSuffix(hit.Path, "100300001.equ") {
t.Fatalf("unexpected search hit: %s", hit.Path)
}
// The editor path must decompile the retrieved script, which only works
// when the string pools and body chunks decoded with the recovered seeds.
meta, err := NewEditorService(c).GetFile(hit.FileIndex)
if err != nil {
t.Fatalf("get file: %v", err)
}
if meta.Path == "" || !strings.Contains(meta.Text, "[name]") {
t.Fatalf("script not decompiled: path=%q text=%.80q", meta.Path, meta.Text)
}
t.Logf("script: %s -> %.60q", meta.Path, meta.Text)
}