DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
This commit is contained in:
commit
645b64fe21
4388 files changed
+1405457
No files matched your search
@@ -0,0 +1,261 @@
|
||||
package dnfbridge
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
dnfcharstat "longheng.io/server/internal/modules/dnf/charstat"
|
||||
dnfpvf "longheng.io/server/internal/modules/dnf/pvf"
|
||||
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
||||
dnfrepomemory "longheng.io/server/internal/modules/dnf/repository/memory"
|
||||
"longheng.io/server/internal/modules/dnf/skillcmd"
|
||||
platformpvf "longheng.io/server/internal/platform/pvf"
|
||||
)
|
||||
|
||||
func TestEquipmentExpAdvantageParsesCurrentPVFField(t *testing.T) {
|
||||
doc, err := dnfpvf.Parse("equipment/test.equ", "[exp advantage]\n5\n")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := equipmentStatNumber(doc, "exp advantage"); got != 5 {
|
||||
t.Fatalf("exp advantage=%d, want 5", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealScriptPVFEquipmentExpAdvantage(t *testing.T) {
|
||||
pvfPath := os.Getenv("DNFBRIDGE_REAL_PVF_SMOKE")
|
||||
if pvfPath == "" {
|
||||
t.Skip("set DNFBRIDGE_REAL_PVF_SMOKE to run real Script.pvf equipment smoke")
|
||||
}
|
||||
archive, err := platformpvf.LoadArchive(platformpvf.Options{Path: pvfPath})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
service := &Service{initialEquipmentArchive: archive}
|
||||
if err := service.preloadEquipmentStatIndex(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for itemID, want := range map[int64]int64{
|
||||
400300054: 5,
|
||||
400360015: 50,
|
||||
} {
|
||||
percent, ok := service.equipmentPVFExpAdvantage(context.Background(), itemID, nil)
|
||||
if !ok || percent != want {
|
||||
t.Fatalf("item %d exp advantage percent=%d found=%t, want %d", itemID, percent, ok, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealScriptPVFAllJobsStarterSkillLayouts(t *testing.T) {
|
||||
pvfPath := os.Getenv("DNFBRIDGE_REAL_PVF_SMOKE")
|
||||
if pvfPath == "" {
|
||||
t.Skip("set DNFBRIDGE_REAL_PVF_SMOKE to run real Script.pvf skill smoke")
|
||||
}
|
||||
archive, err := platformpvf.LoadArchive(platformpvf.Options{Path: pvfPath})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
catalog, err := buildSkillCatalogFromSource(context.Background(), archive)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
service := &Service{initialEquipmentArchive: archive, skillCatalog: catalog}
|
||||
for job := 0; job < 16; job++ {
|
||||
entries, err := service.initialCharacterSkills(context.Background(), byte(job))
|
||||
if err != nil {
|
||||
t.Fatalf("job %d initial skills: %v", job, err)
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
t.Fatalf("job %d has no PVF initial skills", job)
|
||||
}
|
||||
states := make(map[int64]dnfrepo.SkillState, len(entries))
|
||||
for _, entry := range entries {
|
||||
states[entry.SkillID] = dnfrepo.SkillState{Level: entry.Level, Enabled: true}
|
||||
definition, _ := catalog.Find(byte(job), uint16(entry.SkillID))
|
||||
t.Logf("job=%d skill=%d level=%d name=%q kind=%q active=%t class=%d grow=%v command=%q", job, entry.SkillID, entry.Level, definition.Name, definition.Kind, definition.Active, definition.SkillClass, definition.GrowTypes, definition.Command)
|
||||
}
|
||||
layout, err := skillcmd.BuildInitialSkillLayout(catalog, byte(job), currentSkillInfoTreeIndex, states)
|
||||
if err != nil {
|
||||
t.Fatalf("job %d layout: %v", job, err)
|
||||
}
|
||||
activeCount := 0
|
||||
primaryCount := 0
|
||||
for slot, skillID := range layout {
|
||||
definition, ok := catalog.Find(byte(job), skillID)
|
||||
if !ok {
|
||||
t.Fatalf("job %d layout skill %d missing", job, skillID)
|
||||
}
|
||||
if definition.Active {
|
||||
activeCount++
|
||||
}
|
||||
if slot >= 0 && slot < 6 {
|
||||
primaryCount++
|
||||
if !definition.Active {
|
||||
t.Fatalf("job %d passive skill %d entered primary slot %d", job, skillID, slot)
|
||||
}
|
||||
}
|
||||
}
|
||||
wantPrimary := activeCount
|
||||
if wantPrimary > 3 {
|
||||
wantPrimary = 3
|
||||
}
|
||||
if activeCount == 0 || primaryCount != wantPrimary {
|
||||
t.Fatalf("job %d starter active=%d primary=%d entries=%v layout=%v", job, activeCount, primaryCount, entries, layout)
|
||||
}
|
||||
for slot := 3; slot < 6; slot++ {
|
||||
if skillID, ok := layout[slot]; ok {
|
||||
t.Fatalf("job %d unexpected starter quickbar slot=%d skill=%d", job, slot, skillID)
|
||||
}
|
||||
}
|
||||
t.Logf("job=%d entries=%v layout=%v", job, entries, layout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealScriptPVFAllJobsStarterSkillsPersistAndRoundTripThroughOp19(t *testing.T) {
|
||||
pvfPath := os.Getenv("DNFBRIDGE_REAL_PVF_SMOKE")
|
||||
if pvfPath == "" {
|
||||
t.Skip("set DNFBRIDGE_REAL_PVF_SMOKE to run real Script.pvf skill round-trip smoke")
|
||||
}
|
||||
archive, err := platformpvf.LoadArchive(platformpvf.Options{Path: pvfPath})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
catalog, err := buildSkillCatalogFromSource(context.Background(), archive)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
repositories := dnfrepomemory.NewMemoryGroup()
|
||||
service := &Service{
|
||||
repositoryProvider: func() (dnfrepo.Group, bool) { return repositories, true },
|
||||
initialEquipmentArchive: archive,
|
||||
skillCatalog: catalog,
|
||||
}
|
||||
|
||||
for job := 0; job < 16; job++ {
|
||||
t.Run("job_"+strconv.Itoa(job), func(t *testing.T) {
|
||||
characterID := "real-pvf-job-" + strconv.Itoa(job)
|
||||
character := dnfrepo.CharacterRecord{
|
||||
CharacterID: characterID,
|
||||
Job: strconv.Itoa(job),
|
||||
Level: 1,
|
||||
}
|
||||
connection := &bufferConn{}
|
||||
if err := service.sendCurrentSceneSkillInfo(
|
||||
&gameSession{conn: connection},
|
||||
context.Background(),
|
||||
character,
|
||||
"test_real_pvf_all_job_op19_round_trip",
|
||||
); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
packet, rest := splitGameServerUpperPacket(t, connection.write.Bytes())
|
||||
if len(rest) != 0 || packet.Header.Classification != 0 || packet.Header.MsgID != currentSkillInfoMsgID {
|
||||
t.Fatalf("packet=%+v rest=%x", packet.Header, rest)
|
||||
}
|
||||
saved, found, err := repositories.Skill.Load(context.Background(), characterID)
|
||||
if err != nil || !found {
|
||||
t.Fatalf("saved found=%t err=%v", found, err)
|
||||
}
|
||||
initial, err := service.initialCharacterSkills(context.Background(), byte(job))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !skillRecordMatchesPVFInitialSkills(saved.Skills, initial) {
|
||||
t.Fatalf("job %d persisted skills=%v, want PVF initial=%v", job, saved.Skills, initial)
|
||||
}
|
||||
layout := saved.Layouts[currentSkillInfoTreeIndex]
|
||||
if len(layout) == 0 {
|
||||
t.Fatalf("job %d persisted an empty layout", job)
|
||||
}
|
||||
wantWire := make(map[int]uint16, len(layout))
|
||||
primaryCount := 0
|
||||
for slot, skillID := range layout {
|
||||
wantWire[slot] = skillID
|
||||
definition, ok := catalog.Find(byte(job), skillID)
|
||||
if !ok {
|
||||
t.Fatalf("job %d persisted unknown skill=%d slot=%d", job, skillID, slot)
|
||||
}
|
||||
if slot >= 0 && slot < 6 {
|
||||
primaryCount++
|
||||
if slot > 2 || !definition.Active {
|
||||
t.Fatalf("job %d invalid primary slot=%d skill=%d active=%t", job, slot, skillID, definition.Active)
|
||||
}
|
||||
}
|
||||
}
|
||||
if primaryCount == 0 || primaryCount > 3 {
|
||||
t.Fatalf("job %d primary starter count=%d layout=%v", job, primaryCount, layout)
|
||||
}
|
||||
if got := currentSkillInfoFirstTreeSlots(t, packet.Body); !reflect.DeepEqual(got, wantWire) {
|
||||
t.Fatalf("job %d op19 slots=%v, want persisted=%v", job, got, wantWire)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealScriptPVFJob15StarterStatVectors(t *testing.T) {
|
||||
pvfPath := os.Getenv("DNFBRIDGE_REAL_PVF_SMOKE")
|
||||
if pvfPath == "" {
|
||||
t.Skip("set DNFBRIDGE_REAL_PVF_SMOKE to run real Script.pvf stat smoke")
|
||||
}
|
||||
archive, err := platformpvf.LoadArchive(platformpvf.Options{Path: pvfPath})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
table, err := dnfcharstat.Load(context.Background(), archive, dnfcharstat.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
base, err := table.Compute(15, 0, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
skillCatalog, err := buildSkillCatalogFromSource(context.Background(), archive)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, skillID := range []uint16{1, 50, 169, 174, 179, 511} {
|
||||
definition, ok := skillCatalog.Find(15, skillID)
|
||||
if !ok {
|
||||
t.Fatalf("job15 skill missing id=%d", skillID)
|
||||
}
|
||||
t.Logf("job15 skill id=%d name=%q kind=%q active=%t class=%d required=%d grow=%v feature=%d command=%q", skillID, definition.Name, definition.Kind, definition.Active, definition.SkillClass, definition.RequiredLevel, definition.GrowTypes, definition.FeatureSkillType, definition.Command)
|
||||
}
|
||||
entries, err := parseInitialCharacterEquipmentFromSource(archive, 15)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
service := &Service{
|
||||
initialEquipmentArchive: archive,
|
||||
equipmentStats: make(map[int64]dnfcharstat.Vector),
|
||||
}
|
||||
combined := base
|
||||
for _, entry := range entries {
|
||||
text, actualPath, err := readInitialPVFText(archive, initialPVFPath("equipment", entry.PVFPath), entry.PVFPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
doc, err := dnfpvf.Parse(actualPath, text)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, section := range doc.Sections {
|
||||
name := strings.ToLower(section.Name)
|
||||
if strings.Contains(name, "defense") || strings.Contains(name, "attack") || strings.Contains(name, "stat") {
|
||||
t.Logf("item=%d section=%q numbers=%v texts=%v", entry.ItemID, section.Name, doc.Numbers(section.Name), doc.Texts(section.Name))
|
||||
}
|
||||
}
|
||||
stats, ok := service.equipmentPVFStat(context.Background(), entry.ItemID, map[string]string{"pvf_path": entry.PVFPath})
|
||||
if !ok {
|
||||
t.Fatalf("equipment stat missing item=%d path=%s", entry.ItemID, entry.PVFPath)
|
||||
}
|
||||
t.Logf("item=%d slot=%d stats=%+v", entry.ItemID, entry.Slot, stats)
|
||||
combined.Add(stats)
|
||||
}
|
||||
t.Logf("job15 base=%+v", base)
|
||||
t.Logf("job15 combined=%+v", combined)
|
||||
}
|
||||
Reference in new issue
Block a user