服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
93 lines
2.3 KiB
Go
93 lines
2.3 KiB
Go
package monster
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
dnfpvf "longheng.io/server/internal/modules/dnf/pvf"
|
|
)
|
|
|
|
func TestLoadBuildsMonsterTable(t *testing.T) {
|
|
table, err := Load(context.Background(), testIndex(t), Options{})
|
|
if err != nil {
|
|
t.Fatalf("load monster: %v", err)
|
|
}
|
|
if snapshot := table.Snapshot(); snapshot.Monsters != 1 {
|
|
t.Fatalf("unexpected snapshot: %+v", snapshot)
|
|
}
|
|
monster, ok := table.Find(3001)
|
|
if !ok {
|
|
t.Fatalf("expected monster")
|
|
}
|
|
if monster.Name != "training dummy" || monster.Kind != "normal" || monster.Level != 7 || monster.HP != 120 {
|
|
t.Fatalf("unexpected monster: %+v", monster)
|
|
}
|
|
if monster.Scalars["attack"] != 21 || monster.Scalars["move_speed"] != 2.5 {
|
|
t.Fatalf("unexpected scalars: %+v", monster.Scalars)
|
|
}
|
|
monster.Scalars["attack"] = 1
|
|
again, _ := table.FindPath("./MONSTER/training_dummy.mob")
|
|
if again.Scalars["attack"] != 21 {
|
|
t.Fatalf("table returned mutable scalars: %+v", again.Scalars)
|
|
}
|
|
}
|
|
|
|
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{
|
|
"monster/monster.lst": "3001 `monster/missing.mob`\n",
|
|
}, dnfpvf.BuildOptions{Paths: []string{"monster/monster.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{
|
|
"monster/monster.lst": "3001 `monster/training_dummy.mob`\n",
|
|
"monster/training_dummy.mob": `
|
|
[name]
|
|
` + "`training dummy`" + `
|
|
[monster type]
|
|
` + "`normal`" + `
|
|
[level]
|
|
7
|
|
[hp]
|
|
120
|
|
[attack]
|
|
21
|
|
[move speed]
|
|
2.5
|
|
[exp]
|
|
8
|
|
`,
|
|
}, 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
|
|
}
|