服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
115 lines
4.8 KiB
Go
115 lines
4.8 KiB
Go
package dnfbridge
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
dnftown "longheng.io/server/internal/modules/dnf/town"
|
|
platformpvf "longheng.io/server/internal/platform/pvf"
|
|
)
|
|
|
|
func TestAutomaticRobotPublicTownPlacementsDeduplicateAndIncludeDungeonGates(t *testing.T) {
|
|
towns := []dnftown.Town{
|
|
{ID: 38, Areas: []dnftown.Area{
|
|
{ID: 0, Kind: "normal", MapPath: "Town/Public.map", NPCs: []dnftown.NPCSpawn{{NPCID: 1, X: 500, Y: 300}}},
|
|
{ID: 2, Kind: "normal", MapPath: "town/public.map", NPCs: []dnftown.NPCSpawn{{NPCID: 2, X: 600, Y: 300}}},
|
|
{ID: 3, Kind: "dungeon_gate", MapPath: "Town/Dungeon_Entrance.map", NPCs: []dnftown.NPCSpawn{{NPCID: 3, X: 700, Y: 320}}},
|
|
{ID: 4, Kind: "gate", MapPath: "Town/Seria.map", NPCs: []dnftown.NPCSpawn{{NPCID: 4, X: 1, Y: 1}}},
|
|
}},
|
|
{ID: 8, Areas: []dnftown.Area{{ID: 0, Kind: "normal", MapPath: "GuildAgit/private.map", NPCs: []dnftown.NPCSpawn{{NPCID: 5, X: 1, Y: 1}}}}},
|
|
}
|
|
placements := automaticRobotPublicTownPlacements(towns)
|
|
if len(placements) != 2 {
|
|
t.Fatalf("placements=%+v, want one public map and one dungeon entrance", placements)
|
|
}
|
|
if placements[0].MapPath != "town/public.map" || !placements[0].StoreArea ||
|
|
placements[1].MapPath != "town/dungeon_entrance.map" || !placements[1].DungeonGate || placements[1].StoreArea {
|
|
t.Fatalf("placements=%+v", placements)
|
|
}
|
|
}
|
|
|
|
func TestAutomaticRobotNPCCorridorKeepsTheDominantFloor(t *testing.T) {
|
|
minX, maxX, minY, maxY, ok := automaticRobotNPCCorridor([]dnftown.NPCSpawn{
|
|
{NPCID: 1, X: 800, Y: 155}, {NPCID: 2, X: 1600, Y: 156}, {NPCID: 3, X: 2400, Y: 160},
|
|
{NPCID: 4, X: 900, Y: 350}, {NPCID: 5, X: 1000, Y: 405},
|
|
})
|
|
if !ok {
|
|
t.Fatal("dominant NPC floor was not resolved")
|
|
}
|
|
if minX != 824 || maxX != 2376 || minY < 149 || maxY > 163 {
|
|
t.Fatalf("corridor=(%d..%d,%d..%d), want dominant y=155..160 floor", minX, maxX, minY, maxY)
|
|
}
|
|
}
|
|
|
|
func TestAutomaticRobotTownPlacementStaysInsideItsSafeCorridor(t *testing.T) {
|
|
placements := automaticRobotPublicTownPlacements([]dnftown.Town{{
|
|
ID: 38, Areas: []dnftown.Area{{ID: 0, Kind: "normal", MapPath: "town/public.map",
|
|
NPCs: []dnftown.NPCSpawn{{NPCID: 1, X: 500, Y: 200}, {NPCID: 2, X: 900, Y: 205}}}},
|
|
}})
|
|
if len(placements) != 1 {
|
|
t.Fatalf("placements=%+v", placements)
|
|
}
|
|
base := placements[0]
|
|
for index := 1; index <= 100; index++ {
|
|
x := automaticRobotCoordinateInRange(base.MinX, base.MaxX, uint64(index)*53+automaticRobotSeed(index))
|
|
y := automaticRobotCoordinateInRange(base.MinY, base.MaxY, uint64(index)*7+(automaticRobotSeed(index)>>24))
|
|
if x < base.MinX || x > base.MaxX || y < base.MinY || y > base.MaxY {
|
|
t.Fatalf("placement %d=(%d,%d) is outside %+v", index, x, y, base)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAutomaticRobotRealPVFPublicTownDistribution(t *testing.T) {
|
|
pvfPath := os.Getenv("DNFBRIDGE_REAL_PVF_SMOKE")
|
|
if pvfPath == "" {
|
|
t.Skip("set DNFBRIDGE_REAL_PVF_SMOKE to verify automatic robot town distribution")
|
|
}
|
|
archive, err := platformpvf.LoadArchive(platformpvf.Options{Path: pvfPath})
|
|
if err != nil {
|
|
t.Fatalf("load Script.pvf: %v", err)
|
|
}
|
|
table, err := dnftown.Load(context.Background(), archive, dnftown.Options{})
|
|
if err != nil {
|
|
t.Fatalf("load town catalog: %v", err)
|
|
}
|
|
placements := automaticRobotPublicTownPlacements(table.Towns())
|
|
entrances := 0
|
|
storeAreas := 0
|
|
hendonMainSafe, westCoastMainSafe := false, false
|
|
for _, placement := range placements {
|
|
if placement.DungeonGate {
|
|
entrances++
|
|
}
|
|
if placement.StoreArea {
|
|
storeAreas++
|
|
}
|
|
if placement.X < placement.MinX || placement.X > placement.MaxX || placement.Y < placement.MinY || placement.Y > placement.MaxY {
|
|
t.Fatalf("base placement outside corridor: %+v", placement)
|
|
}
|
|
if placement.Village == 39 && placement.Area == 0 {
|
|
hendonMainSafe = placement.StoreArea && placement.MinY >= 140 && placement.MaxY <= 180
|
|
}
|
|
if placement.Village == 40 && placement.Area == 0 {
|
|
westCoastMainSafe = placement.StoreArea && placement.MinY >= 140 && placement.MaxY <= 170
|
|
}
|
|
}
|
|
if len(placements) < 25 || len(placements) > 50 || entrances == 0 {
|
|
t.Fatalf("public placements=%d dungeon entrances=%d", len(placements), entrances)
|
|
}
|
|
if storeAreas < 10 {
|
|
t.Fatalf("store areas=%d, want populated public hubs", storeAreas)
|
|
}
|
|
if !hendonMainSafe || !westCoastMainSafe {
|
|
t.Fatalf("main hub corridors hendon=%t west_coast=%t", hendonMainSafe, westCoastMainSafe)
|
|
}
|
|
service := &Service{townCatalog: table}
|
|
for index := 1; index <= 500; index++ {
|
|
placement := service.automaticRobotTownPlacement(index)
|
|
if placement.X < placement.MinX || placement.X > placement.MaxX || placement.Y < placement.MinY || placement.Y > placement.MaxY {
|
|
t.Fatalf("fleet placement %d outside corridor: %+v", index, placement)
|
|
}
|
|
}
|
|
t.Logf("public unique maps=%d dungeon entrances=%d robots/map=%d..%d", len(placements), entrances, 500/len(placements), (500+len(placements)-1)/len(placements))
|
|
}
|