服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
238 lines
8.9 KiB
Go
238 lines
8.9 KiB
Go
package dnfbridge
|
||
|
||
import (
|
||
"fmt"
|
||
"time"
|
||
|
||
"longheng.io/server/internal/modules/dnf/dnfenum"
|
||
"longheng.io/server/internal/modules/dnf/raid"
|
||
)
|
||
|
||
const (
|
||
runtimeRaidOwnerAnton byte = currentRaidAntonMode
|
||
runtimeRaidOwnerLuke byte = currentRaidLukeMode
|
||
runtimeRaidOwnerFiendWar byte = currentRaidFiendWarMode
|
||
|
||
runtimeRaidLukeLightRoute byte = 2
|
||
runtimeRaidLukeDarkRoute byte = 6
|
||
)
|
||
|
||
type runtimeRaidOwnerConfig struct {
|
||
Mode byte
|
||
Raid *raid.AntonConfig
|
||
Luke *raid.LukeConfig
|
||
// FiendWar 只在超时空频道非 nil。它的 Battle.Raid 是合成出来的
|
||
// *raid.AntonConfig(PhaseMax=1),所以 Raid 字段对三个 owner 都非 nil,
|
||
// 而 FiendWar 额外带着 30 区域地图 / 规则对 / 禁锢秒数 / 商人与雷达电池。
|
||
FiendWar *raid.FiendWarConfig
|
||
}
|
||
|
||
func runtimeRaidModeForSession(session *gameSession) byte {
|
||
if session == nil {
|
||
return 0
|
||
}
|
||
switch session.channel.Type {
|
||
case dnfenum.RaidChannelType:
|
||
return runtimeRaidOwnerAnton
|
||
case dnfenum.HiddenRaidType:
|
||
return runtimeRaidOwnerLuke
|
||
case dnfenum.FiendWarRaidChannelType:
|
||
return runtimeRaidOwnerFiendWar
|
||
default:
|
||
return 0
|
||
}
|
||
}
|
||
|
||
// runtimeRaidOwnerSupportsSingleRaid reports whether the owner behind ownerMode
|
||
// declares a native single (单人) raid.
|
||
//
|
||
// Anton and Luke both do, and both go through the SAME Anton-side parser: the
|
||
// single raid is declared by [SINGLE RAID PHASE] plus
|
||
// [single raid start minium member], which anton_pvf.go turns into
|
||
// AntonConfig.SingleMode / SingleStartMinimumMembers and advertises as the
|
||
// AntonRaidModeSingle ("single") choice. Luke reuses that shape and even asserts
|
||
// it is present -- luke_pvf.go fails the load when base.SingleMode is nil, and
|
||
// validateLukeSingleRoutes then checks its single phase against the light and
|
||
// dark routes. Luke's single type is picked per weekday by
|
||
// runtimeRaidLukeSingleTypeForTime (2=light, 6=dark).
|
||
//
|
||
// Fiend War is the only owner without one. parseFiendWarBattle synthesises its
|
||
// baseline as
|
||
//
|
||
// &AntonConfig{PhaseMax: 1, MemberMax: recruit.MemberMax,
|
||
// StartMinimumMembers: recruit.StartMinimumMembers,
|
||
// EntryCost: recruit.EntryCost} // fiendwar_battle_pvf.go:83
|
||
//
|
||
// so SingleMode stays nil and SingleStartMinimumMembers stays 0 -- which is why
|
||
// the live log's Fiend War start request carried "minimum_members=0
|
||
// maximum_members=1": runtimeRaidStartRosterBounds fell through to
|
||
// config.SingleStartMinimumMembers for a config that has no single mode at all.
|
||
//
|
||
// Live incident 2026-10-07: two players opened a one-member Fiend War raid
|
||
// (tail_flag=1), pressed start, and commitRuntimeRaidStartWithOwner returned
|
||
// false every time (5 attempts, 2 raids, all "commit runtime raid start after
|
||
// durable entry debit"). cancelRuntimeRaidStart only clears StartPending and
|
||
// FrozenMembers, so the raid object survived with TailFlag=1, Started=false and
|
||
// never reached a dissolve path -- the player stayed "already in a raid"
|
||
// forever, and every later join was refused with direction_not_admissible,
|
||
// which the client rendered as dstr 32059 「抱歉, 不存在该玩家。」.
|
||
func runtimeRaidOwnerSupportsSingleRaid(ownerMode byte) bool {
|
||
return ownerMode != runtimeRaidOwnerFiendWar
|
||
}
|
||
|
||
// runtimeRaidSingleRequested reports whether a create request or an existing
|
||
// raid object asks for the single (单人) raid, which the wire format carries as
|
||
// the tail flag.
|
||
func runtimeRaidSingleRequested(tailFlag byte) bool {
|
||
return tailFlag == 1
|
||
}
|
||
|
||
func (s *Service) runtimeRaidLukeConfig() (*raid.LukeConfig, error) {
|
||
if s == nil {
|
||
return nil, raid.ErrLukePVFSourceRequired
|
||
}
|
||
s.raidLukeMu.Lock()
|
||
defer s.raidLukeMu.Unlock()
|
||
if s.raidLuke != nil {
|
||
return s.raidLuke, nil
|
||
}
|
||
if s.raidLukeErr != nil {
|
||
return nil, s.raidLukeErr
|
||
}
|
||
s.initialEquipmentMu.Lock()
|
||
archive, err := s.initialEquipmentArchiveLocked()
|
||
s.initialEquipmentMu.Unlock()
|
||
if err != nil {
|
||
s.raidLukeErr = fmt.Errorf("load luke runtime archive: %w", err)
|
||
return nil, s.raidLukeErr
|
||
}
|
||
config, err := raid.LoadLukeConfig(archive)
|
||
if err != nil {
|
||
s.raidLukeErr = fmt.Errorf("load current luke runtime config: %w", err)
|
||
return nil, s.raidLukeErr
|
||
}
|
||
s.raidLuke = config
|
||
return config, nil
|
||
}
|
||
|
||
// runtimeRaidLukeCardSetConfig loads etc/raid/luke/LukeCardSet.etc, the tarot
|
||
// table the 1181 card display is built from. Same shape as runtimeRaidLukeConfig:
|
||
// one archive read, cached, and the failure cached too so a missing or invalid
|
||
// document is logged once instead of on every waiting-area entry.
|
||
func (s *Service) runtimeRaidLukeCardSetConfig() (*raid.LukeCardSetConfig, error) {
|
||
if s == nil {
|
||
return nil, raid.ErrLukeCardSetSourceRequired
|
||
}
|
||
s.raidLukeCardSetMu.Lock()
|
||
defer s.raidLukeCardSetMu.Unlock()
|
||
if s.raidLukeCardSet != nil {
|
||
return s.raidLukeCardSet, nil
|
||
}
|
||
if s.raidLukeCardSetErr != nil {
|
||
return nil, s.raidLukeCardSetErr
|
||
}
|
||
s.initialEquipmentMu.Lock()
|
||
archive, err := s.initialEquipmentArchiveLocked()
|
||
s.initialEquipmentMu.Unlock()
|
||
if err != nil {
|
||
s.raidLukeCardSetErr = fmt.Errorf("load luke card set runtime archive: %w", err)
|
||
return nil, s.raidLukeCardSetErr
|
||
}
|
||
config, err := raid.LoadLukeCardSet(archive)
|
||
if err != nil {
|
||
s.raidLukeCardSetErr = fmt.Errorf("load current luke card set config: %w", err)
|
||
return nil, s.raidLukeCardSetErr
|
||
}
|
||
s.raidLukeCardSet = config
|
||
return config, nil
|
||
}
|
||
|
||
// runtimeRaidLukeRaidMonsterListConfig loads etc/raid/luke/luke.etc.buff
|
||
// [RAID MONSTER LIST], the table that says which named monster and which boss
|
||
// each maze of each raid dungeon spawns. The 1181 card display derives its seven
|
||
// faces from it, so a failure here is logged once and makes that packet fail
|
||
// closed rather than fall back to an arbitrary face.
|
||
func (s *Service) runtimeRaidLukeRaidMonsterListConfig() (*raid.LukeRaidMonsterListConfig, error) {
|
||
if s == nil {
|
||
return nil, raid.ErrLukeRaidMonsterListSourceRequired
|
||
}
|
||
s.raidLukeMonsterListMu.Lock()
|
||
defer s.raidLukeMonsterListMu.Unlock()
|
||
if s.raidLukeMonsterList != nil {
|
||
return s.raidLukeMonsterList, nil
|
||
}
|
||
if s.raidLukeMonsterListErr != nil {
|
||
return nil, s.raidLukeMonsterListErr
|
||
}
|
||
s.initialEquipmentMu.Lock()
|
||
archive, err := s.initialEquipmentArchiveLocked()
|
||
s.initialEquipmentMu.Unlock()
|
||
if err != nil {
|
||
s.raidLukeMonsterListErr = fmt.Errorf("load luke raid monster list runtime archive: %w", err)
|
||
return nil, s.raidLukeMonsterListErr
|
||
}
|
||
config, err := raid.LoadLukeRaidMonsterList(archive)
|
||
if err != nil {
|
||
s.raidLukeMonsterListErr = fmt.Errorf("load current luke raid monster list config: %w", err)
|
||
return nil, s.raidLukeMonsterListErr
|
||
}
|
||
s.raidLukeMonsterList = config
|
||
return config, nil
|
||
}
|
||
|
||
func (s *Service) runtimeRaidOwnerConfigForSession(session *gameSession) (runtimeRaidOwnerConfig, error) {
|
||
if session == nil {
|
||
return runtimeRaidOwnerConfig{}, errRuntimeRaidLifecycleState
|
||
}
|
||
switch session.channel.Type {
|
||
case dnfenum.RaidChannelType:
|
||
config, err := s.runtimeRaidAntonConfig()
|
||
return runtimeRaidOwnerConfig{Mode: runtimeRaidOwnerAnton, Raid: config}, err
|
||
case dnfenum.HiddenRaidType:
|
||
config, err := s.runtimeRaidLukeConfig()
|
||
if err != nil {
|
||
return runtimeRaidOwnerConfig{}, err
|
||
}
|
||
return runtimeRaidOwnerConfig{Mode: runtimeRaidOwnerLuke, Raid: config.Raid, Luke: config}, nil
|
||
case dnfenum.FiendWarRaidChannelType:
|
||
config, err := s.runtimeRaidFiendWarConfig()
|
||
if err != nil {
|
||
return runtimeRaidOwnerConfig{}, err
|
||
}
|
||
if config.Battle == nil {
|
||
return runtimeRaidOwnerConfig{}, errRuntimeRaidLifecycleState
|
||
}
|
||
// Battle.Raid 是 parseFiendWarBattle 合成的 *AntonConfig(PhaseMax=1),
|
||
// 所以 Raid 字段对超时空也非 nil —— 报名/名额/入场费走与安徒恩相同的骨架。
|
||
return runtimeRaidOwnerConfig{Mode: runtimeRaidOwnerFiendWar, Raid: config.Battle.Raid, FiendWar: config}, nil
|
||
default:
|
||
return runtimeRaidOwnerConfig{}, errRuntimeRaidLifecycleState
|
||
}
|
||
}
|
||
|
||
// Current PVF exposes the two native Luke single route symbols (2=light,
|
||
// 6=dark). The historical live schedule used Tuesday for light and Saturday
|
||
// for dark; the all-days local profile follows the official first-server split.
|
||
func runtimeRaidLukeSingleTypeForTime(at time.Time) byte {
|
||
switch at.In(runtimeRaidChinaCalendar).Weekday() {
|
||
case time.Monday, time.Tuesday, time.Wednesday:
|
||
return runtimeRaidLukeLightRoute
|
||
default:
|
||
return runtimeRaidLukeDarkRoute
|
||
}
|
||
}
|
||
|
||
func runtimeRaidBaseConfig(state runtimeRaidState) *raid.AntonConfig {
|
||
if state.RaidMode == runtimeRaidOwnerLuke && state.LukeConfig != nil {
|
||
return state.LukeConfig.Raid
|
||
}
|
||
// 超时空的 "base" 是 parseFiendWarBattle 合成的那个 *AntonConfig。它同时是
|
||
// lifecycle 的 config 和 runtimeRaidBaseConfig 的返回值,所以路径/阶段/名额
|
||
// 相关的每一处都不需要知道超时空的存在。Battle 为 nil 时退回 AntonConfig,
|
||
// 让调用方拿到 nil 而不是 panic。
|
||
if state.RaidMode == runtimeRaidOwnerFiendWar && state.FiendWarConfig != nil && state.FiendWarConfig.Battle != nil {
|
||
return state.FiendWarConfig.Battle.Raid
|
||
}
|
||
return state.AntonConfig
|
||
}
|