服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
74 lines
2.6 KiB
Go
74 lines
2.6 KiB
Go
package inventory
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
|
dnfweaknesspotion "longheng.io/server/internal/modules/dnf/weaknesspotion"
|
|
)
|
|
|
|
// ApplyWeaknessPotion records the 防虚弱药剂 effect of one consumed item.
|
|
//
|
|
// The client applies the potion's buff locally and never reports it (live
|
|
// capture 2026-09-15 00:43: the only uplink around a use is class-1/op44), so
|
|
// the server has to recognise the item itself and remember the effect. The
|
|
// effect has two halves, both owned here because both are character state:
|
|
//
|
|
// - the current penalty is cleared immediately ("自动解除虚弱状态"), which is
|
|
// the same stamina/weakness_recovery_at pair dnfbridge's forced-return path
|
|
// writes, so the next weakness refresh publishes level 0 on its own;
|
|
// - the immunity window is stored as a durable unix second, because several
|
|
// variants state the effect survives a death, a town return and a relog.
|
|
//
|
|
// Items outside the family return false without touching the database, so an
|
|
// unrelated consumable keeps exactly the behaviour it had before.
|
|
func (o *Owner) ApplyWeaknessPotion(
|
|
ctx context.Context,
|
|
characterID string,
|
|
itemID int64,
|
|
now time.Time,
|
|
) (bool, error) {
|
|
seconds, inFamily := dnfweaknesspotion.ImmunitySeconds(itemID)
|
|
if !inFamily || o == nil || o.assets == nil || characterID == "" {
|
|
return false, nil
|
|
}
|
|
if now.IsZero() {
|
|
now = time.Now().UTC()
|
|
} else {
|
|
now = now.UTC()
|
|
}
|
|
until := now.Add(time.Duration(seconds) * time.Second).Unix()
|
|
err := o.assets.WithinCharacterAssets(ctx, characterID, func(
|
|
characters dnfrepo.CharacterRepository,
|
|
_ dnfrepo.InventoryRepository,
|
|
_ dnfrepo.EquipmentRepository,
|
|
) error {
|
|
character, found, err := characters.Load(ctx, characterID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !found {
|
|
return ErrCharacterRequired
|
|
}
|
|
character = dnfrepo.CloneCharacter(character)
|
|
if character.Stats == nil {
|
|
character.Stats = make(map[string]int64, 4)
|
|
}
|
|
// Drinking a second potion must never shorten the window that is already
|
|
// running (a 60-minute 网吧 potion followed by a 10-minute one).
|
|
if existing := dnfweaknesspotion.ImmuneUntil(character.Stats); existing > until {
|
|
until = existing
|
|
}
|
|
character.Stats[dnfweaknesspotion.ImmuneUntilStatKey] = until
|
|
character.Stats[dnfweaknesspotion.WeaknessLevelStatKey] = 0
|
|
character.Stats[dnfweaknesspotion.WeaknessRecoveryAtStatKey] = 0
|
|
character.UpdatedAt = now
|
|
return dnfrepo.SaveCharacterFields(ctx, characters, character, dnfrepo.CharacterFieldStats)
|
|
})
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return true, nil
|
|
}
|