mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 02:23:37 +01:00
feat(diva): implement Diva Defense (UD) system
Add full Diva Defense / United Defense system: schema, repo layer, i18n bead names, and RE-verified packet handler implementations. Schema (0011_diva.sql): diva_beads, diva_beads_assignment, diva_beads_points, diva_prizes tables; interception_maps/points columns on guilds and guild_characters. Seed (DivaDefaults.sql): 26 prize milestones for personal and guild reward tracks (item_type=26 diva coins). Repo (DivaRepo): 11 new methods covering bead assignment, point accumulation, interception point tracking, prize queries, and cleanup. Mocks wired in test_helpers_test.go. i18n: Bead struct with EN/JP names for all 18 bead types (IDs 1–25). Session tracks currentBeadIndex (-1 = none assigned). Packet handlers corrected against mhfo-hd.dll RE findings: - GetKijuInfo: u8 count, 512-byte desc, color_id+bead_type per entry - SetKiju: 1-byte ACK; persists bead assignment to DB - GetUdMyPoint: 8×18-byte entries, no count prefix - GetUdTotalPointInfo: u8 error + u64[64] + u8[64] + u64 (~585 B) - GetUdSelectedColorInfo: u8 error + u8[8] = 9 bytes - GetUdDailyPresentList: correct u16 count format (was wrong hex) - GetUdNormaPresentList: correct u16 count format (was wrong hex) - GetUdRankingRewardList: correct u16 count with u32 item_id/qty - GetRewardSong: 22-byte layout with 0xFFFFFFFF prayer_end sentinel - AddRewardSongCount: parse implemented (was NOT IMPLEMENTED stub)
This commit is contained in:
@@ -70,13 +70,17 @@ func TestHandleMsgMhfUseRewardSong(t *testing.T) {
|
||||
server := createMockServer()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("handleMsgMhfUseRewardSong panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
pkt := &mhfpacket.MsgMhfUseRewardSong{AckHandle: 12345}
|
||||
handleMsgMhfUseRewardSong(session, pkt)
|
||||
|
||||
handleMsgMhfUseRewardSong(session, nil)
|
||||
select {
|
||||
case p := <-session.sendPackets:
|
||||
if len(p.data) == 0 {
|
||||
t.Error("Response packet should have data")
|
||||
}
|
||||
default:
|
||||
t.Error("No response packet queued")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleMsgMhfAddRewardSongCount(t *testing.T) {
|
||||
@@ -193,16 +197,16 @@ func TestEmptyHandlers_MiscFiles_Reward(t *testing.T) {
|
||||
server := createMockServer()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
tests := []struct {
|
||||
// Handlers that accept nil and take no action (no AckHandle).
|
||||
nilSafeTests := []struct {
|
||||
name string
|
||||
fn func()
|
||||
}{
|
||||
{"handleMsgMhfUseRewardSong", func() { handleMsgMhfUseRewardSong(session, nil) }},
|
||||
{"handleMsgMhfAddRewardSongCount", func() { handleMsgMhfAddRewardSongCount(session, nil) }},
|
||||
{"handleMsgMhfAcceptReadReward", func() { handleMsgMhfAcceptReadReward(session, nil) }},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
for _, tt := range nilSafeTests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -212,4 +216,18 @@ func TestEmptyHandlers_MiscFiles_Reward(t *testing.T) {
|
||||
tt.fn()
|
||||
})
|
||||
}
|
||||
|
||||
// handleMsgMhfUseRewardSong is a real handler (requires a typed packet).
|
||||
t.Run("handleMsgMhfUseRewardSong", func(t *testing.T) {
|
||||
pkt := &mhfpacket.MsgMhfUseRewardSong{AckHandle: 1}
|
||||
handleMsgMhfUseRewardSong(session, pkt)
|
||||
select {
|
||||
case p := <-session.sendPackets:
|
||||
if len(p.data) == 0 {
|
||||
t.Error("handleMsgMhfUseRewardSong: response should have data")
|
||||
}
|
||||
default:
|
||||
t.Error("handleMsgMhfUseRewardSong: no response queued")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user