服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
129 lines
4.4 KiB
Go
129 lines
4.4 KiB
Go
package dnfbridge
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"longheng.io/server/internal/modules/dnf/channelcatalog"
|
|
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
|
dnfrepomemory "longheng.io/server/internal/modules/dnf/repository/memory"
|
|
)
|
|
|
|
func TestOnlineMailboxRecipientGetsCurrentClass0Alarm(t *testing.T) {
|
|
ctx := context.Background()
|
|
repositories := dnfrepomemory.NewMemoryGroup()
|
|
if err := repositories.Mailbox.Save(ctx, dnfrepo.MailboxRecord{
|
|
CharacterID: "88",
|
|
Mails: map[string]dnfrepo.MailRecord{
|
|
"1": {MailID: "1", CreatedAt: time.Now().UTC()},
|
|
},
|
|
}); err != nil {
|
|
t.Fatalf("save mailbox: %v", err)
|
|
}
|
|
connection := &bufferConn{}
|
|
recipient := &gameSession{
|
|
conn: connection,
|
|
connID: "mailbox-online-recipient",
|
|
channel: channelcatalog.Channel{ID: 19},
|
|
selectedCharacterID: 88,
|
|
}
|
|
service := &Service{
|
|
options: options{
|
|
gameUpperHeader: gameUpperHeaderServer16,
|
|
gameUpperBodyCodec: gameUpperBodyCodecPlain,
|
|
},
|
|
repositoryProvider: func() (dnfrepo.Group, bool) { return repositories, true },
|
|
gameSessions: map[uint16]*gameSession{88: recipient},
|
|
}
|
|
|
|
if err := service.sendMailboxAlarmToOnlineRecipient(88); err != nil {
|
|
t.Fatalf("send mailbox alarm: %v", err)
|
|
}
|
|
packet, trailing := splitGameServerUpperPacket(t, connection.write.Bytes())
|
|
if len(trailing) != 0 || packet.Header.MsgID != 0x0063 || packet.Header.Classification != 0 ||
|
|
!bytes.Equal(packet.Body, []byte{0x00, 0x00, 0x00, 0x01, 0x00}) {
|
|
t.Fatalf("class0/0x63 packet header=%+v body=% X trailing=% X", packet.Header, packet.Body, trailing)
|
|
}
|
|
}
|
|
|
|
func TestMailboxAlarmForSessionClearsEmptyMailboxState(t *testing.T) {
|
|
repositories := dnfrepomemory.NewMemoryGroup()
|
|
connection := &bufferConn{}
|
|
session := &gameSession{
|
|
conn: connection,
|
|
connID: "mailbox-empty-state",
|
|
channel: channelcatalog.Channel{ID: 19},
|
|
selectedCharacterID: 88,
|
|
}
|
|
service := &Service{
|
|
options: options{
|
|
gameUpperHeader: gameUpperHeaderServer16,
|
|
gameUpperBodyCodec: gameUpperBodyCodecPlain,
|
|
},
|
|
repositoryProvider: func() (dnfrepo.Group, bool) { return repositories, true },
|
|
}
|
|
|
|
if err := service.sendMailboxAlarmForSession(session, 88, "test_empty_mailbox"); err != nil {
|
|
t.Fatalf("send empty mailbox alarm: %v", err)
|
|
}
|
|
packet, trailing := splitGameServerUpperPacket(t, connection.write.Bytes())
|
|
if len(trailing) != 0 || packet.Header.MsgID != 0x0063 || packet.Header.Classification != 0 ||
|
|
!bytes.Equal(packet.Body, []byte{0x00, 0x00, 0x00, 0x00, 0x00}) {
|
|
t.Fatalf("empty class0/0x63 packet header=%+v body=% X trailing=% X", packet.Header, packet.Body, trailing)
|
|
}
|
|
}
|
|
|
|
func TestInitialTownSceneTailSendsMailboxAlarmOnce(t *testing.T) {
|
|
service, session := newDeferredTailResumeFixture(t)
|
|
repositories, available := service.repositoryGroup()
|
|
if !available {
|
|
t.Fatal("mailbox repositories are unavailable")
|
|
}
|
|
characterID := "29"
|
|
if err := repositories.Mailbox.Save(context.Background(), dnfrepo.MailboxRecord{
|
|
CharacterID: characterID,
|
|
Mails: map[string]dnfrepo.MailRecord{
|
|
"1": {MailID: "1", CreatedAt: time.Now().UTC()},
|
|
"2": {MailID: "2", Read: true, CreatedAt: time.Now().UTC()},
|
|
},
|
|
}); err != nil {
|
|
t.Fatalf("save mailbox: %v", err)
|
|
}
|
|
|
|
if err := service.sendDeferredSelectSceneTail(session, "initial_town_mailbox_alarm"); err != nil {
|
|
t.Fatalf("send initial town scene tail: %v", err)
|
|
}
|
|
packets := splitAllCurrentUpperPackets(t, session.conn.(*bufferConn).write.Bytes())
|
|
alarmCount := 0
|
|
alarmIndex := -1
|
|
rentalIndex := -1
|
|
for index, packet := range packets {
|
|
if packet.Header.Classification != 0 {
|
|
continue
|
|
}
|
|
if packet.Header.MsgID == currentRentalStateMsgID {
|
|
rentalIndex = index
|
|
}
|
|
if packet.Header.MsgID == 0x0063 {
|
|
alarmCount++
|
|
alarmIndex = index
|
|
if !bytes.Equal(packet.Body, []byte{0x01, 0x00}) {
|
|
t.Fatalf("initial mailbox alarm body=% X, want 01 00", packet.Body)
|
|
}
|
|
}
|
|
}
|
|
if alarmCount != 1 || alarmIndex <= rentalIndex {
|
|
t.Fatalf("initial mailbox alarm count=%d index=%d rental_index=%d", alarmCount, alarmIndex, rentalIndex)
|
|
}
|
|
|
|
firstWriteLen := session.conn.(*bufferConn).write.Len()
|
|
if err := service.sendDeferredSelectSceneTail(session, "duplicate_initial_town_mailbox_alarm"); err != nil {
|
|
t.Fatalf("repeat initial town scene tail: %v", err)
|
|
}
|
|
if session.conn.(*bufferConn).write.Len() != firstWriteLen {
|
|
t.Fatalf("duplicate initial town scene tail replayed mailbox alarm")
|
|
}
|
|
}
|