Files
90CNServer/server/internal/modules/dnf/adventuregroup/runtime_config_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

117 lines
3.3 KiB
Go

package adventuregroup
import (
"fmt"
"strings"
"testing"
dnfpvf "longheng.io/server/internal/modules/dnf/pvf"
)
// The live adventurersystem2018.etc ships 15 expert groups, and that count
// bounds the 20-row profession descriptor block (ProfessionTypeCount) rather
// than the 6 u32 content counters (ContentTypeCount). Confusing the two made
// the table look malformed and the server refused to start against the real
// PVF while every fixture-based test still passed, so this pins the real
// group count.
func TestParseProfessionClassificationsAcceptsTheFullNativeGroupCount(t *testing.T) {
var b strings.Builder
b.WriteString("[expert list]\n")
for group := 0; group < 15; group++ {
b.WriteString("[group]\n")
fmt.Fprintf(&b, "%d `group %d`\n", group, group)
b.WriteString("[info]\n")
fmt.Fprintf(&b, "`[swordman]` `second awakening` %d\n", group+1)
b.WriteString("[/info]\n")
b.WriteString("[/group]\n")
}
b.WriteString("[/expert list]")
document, err := dnfpvf.Parse(AdventureSystem2018Path, b.String())
if err != nil {
t.Fatal(err)
}
_, groups, err := parseProfessionClassifications(document)
if err != nil {
t.Fatalf("15 native groups rejected: %v", err)
}
if groups != 15 {
t.Fatalf("groups=%d, want 15", groups)
}
if groups > ProfessionTypeCount {
t.Fatalf("ProfessionTypeCount=%d cannot hold %d native groups", ProfessionTypeCount, groups)
}
}
func TestParseProfessionClassificationsUsesOrderedExpertGroups(t *testing.T) {
document, err := dnfpvf.Parse(AdventureSystem2018Path, `[expert list]
[group]
0 `+"`鬼剑士 (男)`"+`
[info]
`+"`[swordman]` `second awakening` 1"+`
[/info]
[info]
`+"`[swordman]` `second awakening` 4"+`
[/info]
[/group]
[group]
1 `+"`外传`"+`
[info]
`+"`[creator mage]` `second realization` 1"+`
[/info]
[info]
`+"`[demonic swordman]` `second realization` 1"+`
[/info]
[/group]
[/expert list]`)
if err != nil {
t.Fatal(err)
}
classes, groups, err := parseProfessionClassifications(document)
if err != nil {
t.Fatal(err)
}
config := RuntimeConfig{professionClasses: classes, professionGroupCount: groups}
if config.ProfessionGroupCount() != 2 {
t.Fatalf("groups=%d", config.ProfessionGroupCount())
}
for _, test := range []struct {
job, grow int
want byte
}{
{job: 0, grow: 1, want: 0},
{job: 0, grow: 4, want: 0},
{job: 10, grow: 1, want: 1},
{job: 9, grow: 1, want: 1},
} {
got, found := config.ProfessionClassification(test.job, test.grow)
if !found || got != test.want {
t.Fatalf("job=%d grow=%d classification=%d/%t want=%d", test.job, test.grow, got, found, test.want)
}
}
if _, found := config.ProfessionClassification(0, 2); found {
t.Fatal("undefined profession slot resolved")
}
clone := config.Clone()
clone.professionClasses[[2]byte{0, 1}] = 9
if original, _ := config.ProfessionClassification(0, 1); original != 0 {
t.Fatal("runtime clone shares profession map")
}
}
func TestParseProfessionClassificationsRejectsMalformedOrder(t *testing.T) {
document, err := dnfpvf.Parse(AdventureSystem2018Path, `[expert list]
[group]
1 `+"`bad ordinal`"+`
[info]
`+"`[swordman]` `second awakening` 1"+`
[/info]
[/group]
[/expert list]`)
if err != nil {
t.Fatal(err)
}
if _, _, err := parseProfessionClassifications(document); err == nil {
t.Fatal("malformed group order accepted")
}
}