Files
90CNServer/server/internal/services/dnfbridge/dungeon_recommended_clear_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

143 lines
4.7 KiB
Go

package dnfbridge
import (
"testing"
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
"longheng.io/server/internal/modules/dnf/worldmap"
)
func TestCurrentDungeonIsRecommendedClearUsesPVFRangeAndAcceptedOrdinaryClear(t *testing.T) {
runtime := &runtimeDungeonState{
Dungeon: worldmap.Dungeon{
ID: 11,
Mazes: []worldmap.Maze{{}},
Metadata: worldmap.DungeonMetadata{
RecommendedLevels: []int64{85, 90},
},
},
Character: dnfrepo.CharacterRecord{Level: 90},
ordinaryFinalRoomClearAccepted: true,
}
if !currentDungeonIsRecommendedClear(runtime) {
t.Fatal("accepted level-90 clear in PVF range was not recommended")
}
runtime.Character.Level = 91
if currentDungeonIsRecommendedClear(runtime) {
t.Fatal("out-of-range clear was recommended")
}
runtime.Character.Level = 90
runtime.ordinaryFinalRoomClearAccepted = false
if currentDungeonIsRecommendedClear(runtime) {
t.Fatal("unaccepted clear was recommended")
}
}
func TestCurrentDungeonIsRecommendedClearFallsBackToPVFEntryAndBasisLevels(t *testing.T) {
runtime := &runtimeDungeonState{
Dungeon: worldmap.Dungeon{
ID: 310,
Mazes: []worldmap.Maze{{}},
Metadata: worldmap.DungeonMetadata{
MinimumRequiredLevel: worldmap.OptionalInt{Set: true, Value: 87},
BasisLevel: worldmap.OptionalInt{Set: true, Value: 90},
},
},
Character: dnfrepo.CharacterRecord{Level: 90},
ordinaryFinalRoomClearAccepted: true,
}
if !currentDungeonIsRecommendedClear(runtime) {
t.Fatal("ordinary level-90 clear did not use the PVF 87..90 fallback")
}
for _, level := range []int{86, 91} {
runtime.Character.Level = level
if currentDungeonIsRecommendedClear(runtime) {
t.Fatalf("out-of-range level %d was recommended", level)
}
}
}
func TestCurrentDungeonIsRecommendedClearAcceptsQuestConnectedStoryMaze(t *testing.T) {
runtime := &runtimeDungeonState{
Dungeon: worldmap.Dungeon{
ID: 310,
Mazes: []worldmap.Maze{{QuestConnection: []int64{0, 3946, -1}}},
Metadata: worldmap.DungeonMetadata{
MinimumRequiredLevel: worldmap.OptionalInt{Set: true, Value: 87},
BasisLevel: worldmap.OptionalInt{Set: true, Value: 90},
},
},
Character: dnfrepo.CharacterRecord{Level: 90},
ordinaryFinalRoomClearAccepted: true,
}
if !currentDungeonIsRecommendedClear(runtime) {
t.Fatal("accepted suitable-level story-maze clear was not recommended")
}
}
func TestCurrentDungeonIsRecommendedClearRejectsIneligibleRoutes(t *testing.T) {
base := runtimeDungeonState{
Dungeon: worldmap.Dungeon{
ID: 310,
Mazes: []worldmap.Maze{{}},
Metadata: worldmap.DungeonMetadata{
MinimumRequiredLevel: worldmap.OptionalInt{Set: true, Value: 87},
BasisLevel: worldmap.OptionalInt{Set: true, Value: 90},
},
},
Character: dnfrepo.CharacterRecord{Level: 90},
ordinaryFinalRoomClearAccepted: true,
}
for _, test := range []struct {
name string
mutate func(*runtimeDungeonState)
}{
{name: "practice", mutate: func(runtime *runtimeDungeonState) {
runtime.ProtocolMode = currentDungeonProtocolModePractice
}},
{name: "no fatigue", mutate: func(runtime *runtimeDungeonState) {
runtime.Dungeon.Metadata.NoFatigue = true
}},
{name: "tournament", mutate: func(runtime *runtimeDungeonState) {
runtime.tournament = &worldmap.TournamentRuntime{}
}},
{name: "unresolved maze", mutate: func(runtime *runtimeDungeonState) {
runtime.MazeIndex = len(runtime.Dungeon.Mazes)
}},
} {
t.Run(test.name, func(t *testing.T) {
runtime := base
runtime.Dungeon.Mazes = append([]worldmap.Maze(nil), base.Dungeon.Mazes...)
runtime.Dungeon.Mazes[0].QuestConnection = append([]int64(nil), base.Dungeon.Mazes[0].QuestConnection...)
test.mutate(&runtime)
if currentDungeonIsRecommendedClear(&runtime) {
t.Fatal("non-ordinary clear was recommended")
}
})
}
}
func TestCurrentDungeonMatchesRecommendedLevelRejectsMalformedPVFRange(t *testing.T) {
runtime := &runtimeDungeonState{
Dungeon: worldmap.Dungeon{
ID: 11,
Metadata: worldmap.DungeonMetadata{
RecommendedLevels: []int64{90, 85},
},
},
Character: dnfrepo.CharacterRecord{Level: 90},
}
if currentDungeonMatchesRecommendedLevel(runtime) {
t.Fatal("reversed PVF range matched")
}
runtime.Dungeon.Metadata.RecommendedLevels = []int64{90}
if currentDungeonMatchesRecommendedLevel(runtime) {
t.Fatal("incomplete PVF range matched")
}
runtime.Dungeon.Metadata.MinimumRequiredLevel = worldmap.OptionalInt{Set: true, Value: 85}
runtime.Dungeon.Metadata.BasisLevel = worldmap.OptionalInt{Set: true, Value: 90}
if currentDungeonMatchesRecommendedLevel(runtime) {
t.Fatal("malformed explicit range silently fell back to entry levels")
}
}