服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
88 lines
2.9 KiB
Go
88 lines
2.9 KiB
Go
package dnfbridge
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
dnfguild "longheng.io/server/internal/modules/dnf/guild"
|
|
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
|
"longheng.io/server/internal/modules/dnf/worldmap"
|
|
)
|
|
|
|
// The durable battle key owns the timer. Refresh/reconnect reconstructs its
|
|
// remaining delay, and a callback from an older battle never changes a new one.
|
|
func (s *Service) scheduleCurrentGuildWar(g *dnfguild.Guild) error {
|
|
if g == nil || g.War.Battle == nil {
|
|
return nil
|
|
}
|
|
b := *g.War.Battle
|
|
id := g.ID
|
|
queue := s.ensureGameplayTimeQueue()
|
|
return queue.ScheduleAfter(fmt.Sprintf("guild-war:%d:%s", id, b.Key), max(time.Millisecond, time.Unix(b.EndsAt, 0).Sub(queue.Now())), func(now time.Time) {
|
|
ctx, cancel := s.currentGuildContext()
|
|
defer cancel()
|
|
var ended *dnfguild.Guild
|
|
err := s.mutateCurrentGuild(ctx, func(_ dnfrepo.Group, r *dnfguild.Registry) error {
|
|
g := r.Guilds[id]
|
|
if g == nil || g.War.Battle == nil || g.War.Battle.Key != b.Key || now.Unix() < g.War.Battle.EndsAt {
|
|
return nil
|
|
}
|
|
r.AdvanceWars(now)
|
|
ended = g
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
s.logPacketEvent("game-guild-war-expiry-failed", "guild_id", id, "error", err)
|
|
// Preserve the same durable generation while retrying a failed save.
|
|
retry := *g
|
|
copyBattle := b
|
|
copyBattle.EndsAt = now.Add(time.Second).Unix()
|
|
retry.War.Battle = ©Battle
|
|
if e := s.scheduleCurrentGuildWar(&retry); e != nil {
|
|
s.logPacketEvent("game-guild-war-expiry-retry-failed", "error", e)
|
|
}
|
|
return
|
|
}
|
|
if ended != nil {
|
|
if err = s.publishCurrentGuildWarEnd(ended, b.Key); err != nil {
|
|
s.logPacketEvent("game-guild-war-expiry-publish-failed", "guild_id", id, "error", err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
func (s *Service) publishCurrentGuildWarEnd(g *dnfguild.Guild, key string) error {
|
|
for id := range g.Members {
|
|
identity, online := s.onlineGameSessionCharacterSnapshot(uint16(currentGuildNumericID(id)))
|
|
if !online || identity.session == nil {
|
|
continue
|
|
}
|
|
ss := identity.session
|
|
if err := s.postGameSessionCharacterEvent(ss, "guild-war-ended", identity.character, identity.generation, func() error {
|
|
ss.dungeon.mu.Lock()
|
|
runtime := ss.dungeon.runtime
|
|
belongs := runtime != nil && runtime.guildWarID == g.ID && runtime.guildWarKey == key && runtime.Session != nil
|
|
active := belongs && runtime.Session.Snapshot().Run.Status == worldmap.DungeonRunActive
|
|
ss.dungeon.mu.Unlock()
|
|
if active {
|
|
ctx, cancel := s.currentGuildContext()
|
|
defer cancel()
|
|
transition, err := s.prepareCurrentDungeonTownTransitionForSession(ctx, ss, identity.character)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err = s.sendCurrentActiveDungeonReturnToTown(ss, runtime, transition, 132, "guild_war_ended"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if ready, _ := s.currentSceneTransitionReadyForState(ss); !ready {
|
|
return nil
|
|
}
|
|
return s.writeCurrentGuildWarOverview(ss, g)
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|