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,92 @@
|
||||
package dungeon
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"longheng.io/server/internal/modules/dnf/dungeoncmd"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrEntryLevelTooLow = errors.New("dnf dungeon character level is too low")
|
||||
ErrEntryFatigueUnknown = errors.New("dnf dungeon character fatigue is unavailable")
|
||||
ErrEntryFatigueExhausted = errors.New("dnf dungeon character fatigue is exhausted")
|
||||
ErrEntryPartyLimit = errors.New("dnf dungeon party exceeds PVF limit")
|
||||
)
|
||||
|
||||
// EntryPolicy contains only the proved PVF and persisted-character facts used
|
||||
// to decide whether a character may enter a dungeon. Transport/session code is
|
||||
// responsible for taking a stable party snapshot before calling ValidateEntry.
|
||||
type EntryPolicy struct {
|
||||
CharacterLevel int
|
||||
MinimumLevel int64
|
||||
MinimumLevelSet bool
|
||||
PartyCount int
|
||||
PartyLimit int64
|
||||
PartyLimitSet bool
|
||||
NoFatigue bool
|
||||
EnterWithoutFatigue bool
|
||||
Fatigue int64
|
||||
FatigueKnown bool
|
||||
}
|
||||
|
||||
func ValidateEntry(policy EntryPolicy) error {
|
||||
if policy.MinimumLevelSet && int64(policy.CharacterLevel) < policy.MinimumLevel {
|
||||
return fmt.Errorf(
|
||||
"%w: level=%d required=%d",
|
||||
ErrEntryLevelTooLow,
|
||||
policy.CharacterLevel,
|
||||
policy.MinimumLevel,
|
||||
)
|
||||
}
|
||||
partyCount := policy.PartyCount
|
||||
if partyCount < 1 {
|
||||
partyCount = 1
|
||||
}
|
||||
if policy.PartyLimitSet && policy.PartyLimit > 0 && int64(partyCount) > policy.PartyLimit {
|
||||
return fmt.Errorf("%w: members=%d limit=%d", ErrEntryPartyLimit, partyCount, policy.PartyLimit)
|
||||
}
|
||||
if policy.NoFatigue || policy.EnterWithoutFatigue {
|
||||
return nil
|
||||
}
|
||||
if !policy.FatigueKnown {
|
||||
return ErrEntryFatigueUnknown
|
||||
}
|
||||
if policy.Fatigue <= 0 {
|
||||
return fmt.Errorf("%w: fatigue=%d", ErrEntryFatigueExhausted, policy.Fatigue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CharacterStat(stats map[string]int64, names ...string) (int64, bool) {
|
||||
for _, name := range names {
|
||||
if value, ok := stats[name]; ok {
|
||||
return value, true
|
||||
}
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// SameSelectRequest defines idempotent current-client op16 replay identity.
|
||||
// Opaque tails are deliberately excluded until current-EXE evidence proves
|
||||
// their semantics.
|
||||
func SameSelectRequest(left, right dungeoncmd.SelectDungeonRequest) bool {
|
||||
return left.DungeonID == right.DungeonID &&
|
||||
left.Difficulty == right.Difficulty &&
|
||||
left.EntryOption == right.EntryOption &&
|
||||
left.SelectionMode == right.SelectionMode &&
|
||||
left.RuntimeState == right.RuntimeState &&
|
||||
left.RuntimeToken == right.RuntimeToken &&
|
||||
left.Reserved == right.Reserved &&
|
||||
left.PartyState == right.PartyState &&
|
||||
left.LeaderObjectKey == right.LeaderObjectKey &&
|
||||
left.SpecialMode == right.SpecialMode &&
|
||||
len(left.OpaqueTail) == 0 && len(right.OpaqueTail) == 0
|
||||
}
|
||||
|
||||
func RuntimeOwnsCharacter(storedCharacterID string, selectedCharacterID uint16) bool {
|
||||
return selectedCharacterID != 0 &&
|
||||
strings.TrimSpace(storedCharacterID) == strconv.Itoa(int(selectedCharacterID))
|
||||
}
|
||||
Reference in new issue
Block a user