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,119 @@
|
||||
package quest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
||||
)
|
||||
|
||||
func isPVPWinDefinition(definition Definition) bool {
|
||||
return normalizeQuestTag(definition.Type) == "pvp quest" && definition.SubType == 1 &&
|
||||
len(definition.IntData) == 2 && definition.IntData[0] > 0 &&
|
||||
definition.IntData[0] <= math.MaxUint32 && definition.IntData[1] == 0
|
||||
}
|
||||
|
||||
type PVPProgressResult struct {
|
||||
Quest dnfrepo.QuestRecord
|
||||
SnapshotRequired bool
|
||||
}
|
||||
|
||||
// ApplyPVPWin consumes one authoritative ranked 1v1 win. The existing quest
|
||||
// finish transaction remains responsible for granting the quest reward.
|
||||
func (o *Owner) ApplyPVPWin(ctx context.Context, catalog *Catalog, accountID, characterID, completionKey string, completedAt time.Time) (PVPProgressResult, error) {
|
||||
if o == nil || o.repositories.CharacterSettlement == nil || catalog == nil {
|
||||
return PVPProgressResult{}, ErrOwnerUnavailable
|
||||
}
|
||||
if strings.TrimSpace(accountID) == "" || strings.TrimSpace(characterID) == "" ||
|
||||
strings.TrimSpace(completionKey) == "" || completedAt.IsZero() {
|
||||
return PVPProgressResult{}, fmt.Errorf("PVP quest completion identity/time missing")
|
||||
}
|
||||
digest := sha256.Sum256([]byte(completionKey))
|
||||
var result PVPProgressResult
|
||||
err := o.repositories.CharacterSettlement.WithinCharacterSettlement(ctx, characterID, func(tx dnfrepo.Group) error {
|
||||
if tx.Character == nil || tx.Quest == nil {
|
||||
return ErrOwnerUnavailable
|
||||
}
|
||||
character, found, err := tx.Character.Load(ctx, characterID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !found || character.CharacterID != characterID || character.AccountID != accountID {
|
||||
return ErrCharacterNotFound
|
||||
}
|
||||
record, found, err := tx.Quest.Load(ctx, characterID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if found && record.CharacterID != characterID {
|
||||
return fmt.Errorf("PVP quest character mismatch")
|
||||
}
|
||||
result.Quest = dnfrepo.CloneQuest(record)
|
||||
result.SnapshotRequired = found
|
||||
replayed := true
|
||||
for i := 0; i < 4; i++ {
|
||||
v, exists := character.Stats[fmt.Sprintf("pvp_quest_receipt_%d", i)]
|
||||
replayed = replayed && exists && v == int64(binary.LittleEndian.Uint64(digest[i*8:]))
|
||||
}
|
||||
if replayed {
|
||||
return nil
|
||||
}
|
||||
var fields []dnfrepo.QuestField
|
||||
seen := make(map[int64]bool)
|
||||
visit := func(states map[int64]dnfrepo.QuestState, field dnfrepo.QuestField) {
|
||||
changed := false
|
||||
for id, state := range states {
|
||||
if seen[id] {
|
||||
continue
|
||||
}
|
||||
seen[id] = true
|
||||
definition, exists := catalog.Find(id)
|
||||
if !exists || !isPVPWinDefinition(definition) || !isActiveQuestStatus(state.Status) ||
|
||||
state.ProgressValue <= 0 || state.ProgressValue > definition.IntData[0] || state.UpdatedAt.After(completedAt) {
|
||||
continue
|
||||
}
|
||||
state.ProgressValue--
|
||||
state.UpdatedAt = completedAt
|
||||
if state.Extra == nil {
|
||||
state.Extra = make(map[string]string)
|
||||
}
|
||||
state.Extra["completion_kind"] = "pvp_win"
|
||||
state.Extra["completion_key"] = completionKey
|
||||
state.Extra["pvf_path"] = definition.Path
|
||||
if state.ProgressValue == 0 {
|
||||
state.Extra["reward_state"] = "pending"
|
||||
}
|
||||
states[id] = state
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
fields = append(fields, field)
|
||||
}
|
||||
}
|
||||
visit(result.Quest.States, dnfrepo.QuestFieldStates)
|
||||
visit(result.Quest.Progress, dnfrepo.QuestFieldProgress)
|
||||
if len(fields) > 0 {
|
||||
result.Quest.UpdatedAt = completedAt
|
||||
if err := dnfrepo.SaveQuestFields(ctx, tx.Quest, result.Quest, fields...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
character = dnfrepo.CloneCharacter(character)
|
||||
if character.Stats == nil {
|
||||
character.Stats = make(map[string]int64)
|
||||
}
|
||||
for i := 0; i < 4; i++ {
|
||||
character.Stats[fmt.Sprintf("pvp_quest_receipt_%d", i)] = int64(binary.LittleEndian.Uint64(digest[i*8:]))
|
||||
}
|
||||
return dnfrepo.SaveCharacterFields(ctx, tx.Character, character, dnfrepo.CharacterFieldStats)
|
||||
})
|
||||
if err != nil {
|
||||
return PVPProgressResult{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
Reference in new issue
Block a user