服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
90 lines
3.2 KiB
Go
90 lines
3.2 KiB
Go
package dungeon
|
|
|
|
import (
|
|
"testing"
|
|
|
|
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
|
)
|
|
|
|
func reservedTestPlacement(slotStart int16, slotEnd int16) PickupItemPlacement {
|
|
return PickupItemPlacement{
|
|
Definition: PickupItemDefinition{
|
|
ItemID: 7001,
|
|
Kind: PickupItemStackable,
|
|
StackLimit: 999,
|
|
SlotStart: slotStart,
|
|
SlotEnd: slotEnd,
|
|
},
|
|
Amount: 1,
|
|
BuildNew: func(int16) (dnfrepo.ItemStack, error) {
|
|
return dnfrepo.ItemStack{ItemID: 7001, Count: 1}, nil
|
|
},
|
|
}
|
|
}
|
|
|
|
// 弃置物躺在地上期间,它被丢下的那一格必须留给它。
|
|
//
|
|
// 装备不能并进已占用的行,所以一旦新拾取物按"最小空格优先"占掉那一格,那件弃置物
|
|
// 就永久捡不起来 —— 2026-09-27 线上就是这样卡死的(新拾取占了 43 格,地面对象 504
|
|
// 再也拾取不了)。归还原格位这条规则不变,这里只验证"已许诺"的格位会被跳过。
|
|
func TestPlacePickupItemSkipsSlotsReservedForDiscardOrigins(t *testing.T) {
|
|
record := dnfrepo.InventoryRecord{Slots: map[string]dnfrepo.ItemStack{}}
|
|
placement := reservedTestPlacement(5, 9)
|
|
placement.ReservedSlots = map[int16]struct{}{5: {}, 6: {}}
|
|
|
|
slot, _, err := PlacePickupItem(&record, placement)
|
|
if err != nil {
|
|
t.Fatalf("PlacePickupItem: %v", err)
|
|
}
|
|
if slot != 7 {
|
|
t.Fatalf("slot=%d, want 7 (5 and 6 are promised to pending discards)", slot)
|
|
}
|
|
if _, placed := record.Slots["0:7"]; !placed {
|
|
t.Fatalf("inventory=%+v", record.Slots)
|
|
}
|
|
}
|
|
|
|
// 保留集只对主背包生效。行键按列表分开("<list>:<slot>"),而每一个 discard origin
|
|
// 都是 list 0,所以别的列表不该被主背包的保留影响。
|
|
func TestPlacePickupItemIgnoresReservationsOnOtherLists(t *testing.T) {
|
|
record := dnfrepo.InventoryRecord{Slots: map[string]dnfrepo.ItemStack{}}
|
|
placement := reservedTestPlacement(5, 9)
|
|
placement.ListType = 38
|
|
placement.ReservedSlots = map[int16]struct{}{5: {}}
|
|
|
|
slot, _, err := PlacePickupItem(&record, placement)
|
|
if err != nil {
|
|
t.Fatalf("PlacePickupItem: %v", err)
|
|
}
|
|
if slot != 5 {
|
|
t.Fatalf("slot=%d, want 5: reservations are main-bag only", slot)
|
|
}
|
|
}
|
|
|
|
// nil 保留集(除副本拾取以外的所有调用方)必须与改动前完全一致:最小空格优先。
|
|
func TestPlacePickupItemWithoutReservationsKeepsLowestFreeSlot(t *testing.T) {
|
|
record := dnfrepo.InventoryRecord{Slots: map[string]dnfrepo.ItemStack{}}
|
|
slot, _, err := PlacePickupItem(&record, reservedTestPlacement(5, 9))
|
|
if err != nil {
|
|
t.Fatalf("PlacePickupItem: %v", err)
|
|
}
|
|
if slot != 5 {
|
|
t.Fatalf("slot=%d, want 5", slot)
|
|
}
|
|
}
|
|
|
|
// 保留一个格位不等于把它永久锁死:那个格位一旦被真正占用(或不再保留),
|
|
// 分配就回到原来的最小空格语义。
|
|
func TestPlacePickupItemFallsThroughWhenRangeIsOnlyReservedSlots(t *testing.T) {
|
|
record := dnfrepo.InventoryRecord{Slots: map[string]dnfrepo.ItemStack{}}
|
|
placement := reservedTestPlacement(5, 6)
|
|
placement.ReservedSlots = map[int16]struct{}{5: {}, 6: {}}
|
|
|
|
if _, _, err := PlacePickupItem(&record, placement); err == nil {
|
|
t.Fatal("want inventory-full error when every slot in range is reserved")
|
|
}
|
|
if len(record.Slots) != 0 {
|
|
t.Fatalf("inventory=%+v", record.Slots)
|
|
}
|
|
}
|