mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 10:03:06 +01:00
fix(guild): implement alliance application toggle (#166)
Alliance applications were hardcoded to always-open. Add a `recruiting` column to guild_alliances and handle OperateJoint actions 0x06 (Allow) and 0x07 (Deny) confirmed via Wii U debug symbols. Only the parent guild leader can toggle the setting, matching the existing disband guard.
This commit is contained in:
@@ -238,6 +238,126 @@ func TestOperateJoint_Kick_NotOwner(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperateJoint_Allow_AsOwner(t *testing.T) {
|
||||
server := createMockServer()
|
||||
guildMock := &mockGuildRepo{
|
||||
alliance: &GuildAlliance{
|
||||
ID: 5,
|
||||
ParentGuildID: 10,
|
||||
},
|
||||
}
|
||||
guildMock.guild = &Guild{ID: 10}
|
||||
guildMock.guild.LeaderCharID = 1
|
||||
server.guildRepo = guildMock
|
||||
session := createMockSession(1, server)
|
||||
|
||||
pkt := &mhfpacket.MsgMhfOperateJoint{
|
||||
AckHandle: 100,
|
||||
AllianceID: 5,
|
||||
GuildID: 10,
|
||||
Action: mhfpacket.OPERATE_JOINT_ALLOW,
|
||||
}
|
||||
|
||||
handleMsgMhfOperateJoint(session, pkt)
|
||||
|
||||
if guildMock.allianceRecruitingSet == nil || !*guildMock.allianceRecruitingSet {
|
||||
t.Error("SetAllianceRecruiting should be called with true")
|
||||
}
|
||||
|
||||
select {
|
||||
case <-session.sendPackets:
|
||||
default:
|
||||
t.Error("No response packet queued")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperateJoint_Allow_NotOwner(t *testing.T) {
|
||||
server := createMockServer()
|
||||
guildMock := &mockGuildRepo{
|
||||
alliance: &GuildAlliance{
|
||||
ID: 5,
|
||||
ParentGuildID: 99, // different guild
|
||||
},
|
||||
}
|
||||
guildMock.guild = &Guild{ID: 10}
|
||||
guildMock.guild.LeaderCharID = 1
|
||||
server.guildRepo = guildMock
|
||||
session := createMockSession(1, server)
|
||||
|
||||
pkt := &mhfpacket.MsgMhfOperateJoint{
|
||||
AckHandle: 100,
|
||||
AllianceID: 5,
|
||||
GuildID: 10,
|
||||
Action: mhfpacket.OPERATE_JOINT_ALLOW,
|
||||
}
|
||||
|
||||
handleMsgMhfOperateJoint(session, pkt)
|
||||
|
||||
if guildMock.allianceRecruitingSet != nil {
|
||||
t.Error("Non-owner should not toggle alliance recruiting")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperateJoint_Deny_AsOwner(t *testing.T) {
|
||||
server := createMockServer()
|
||||
guildMock := &mockGuildRepo{
|
||||
alliance: &GuildAlliance{
|
||||
ID: 5,
|
||||
ParentGuildID: 10,
|
||||
},
|
||||
}
|
||||
guildMock.guild = &Guild{ID: 10}
|
||||
guildMock.guild.LeaderCharID = 1
|
||||
server.guildRepo = guildMock
|
||||
session := createMockSession(1, server)
|
||||
|
||||
pkt := &mhfpacket.MsgMhfOperateJoint{
|
||||
AckHandle: 100,
|
||||
AllianceID: 5,
|
||||
GuildID: 10,
|
||||
Action: mhfpacket.OPERATE_JOINT_DENY,
|
||||
}
|
||||
|
||||
handleMsgMhfOperateJoint(session, pkt)
|
||||
|
||||
if guildMock.allianceRecruitingSet == nil || *guildMock.allianceRecruitingSet {
|
||||
t.Error("SetAllianceRecruiting should be called with false")
|
||||
}
|
||||
|
||||
select {
|
||||
case <-session.sendPackets:
|
||||
default:
|
||||
t.Error("No response packet queued")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperateJoint_Deny_NotOwner(t *testing.T) {
|
||||
server := createMockServer()
|
||||
guildMock := &mockGuildRepo{
|
||||
alliance: &GuildAlliance{
|
||||
ID: 5,
|
||||
ParentGuildID: 99,
|
||||
},
|
||||
}
|
||||
guildMock.guild = &Guild{ID: 10}
|
||||
guildMock.guild.LeaderCharID = 1
|
||||
server.guildRepo = guildMock
|
||||
session := createMockSession(1, server)
|
||||
|
||||
pkt := &mhfpacket.MsgMhfOperateJoint{
|
||||
AckHandle: 100,
|
||||
AllianceID: 5,
|
||||
GuildID: 10,
|
||||
Action: mhfpacket.OPERATE_JOINT_DENY,
|
||||
}
|
||||
|
||||
handleMsgMhfOperateJoint(session, pkt)
|
||||
|
||||
if guildMock.allianceRecruitingSet != nil {
|
||||
t.Error("Non-owner should not toggle alliance recruiting")
|
||||
}
|
||||
}
|
||||
|
||||
// --- handleMsgMhfInfoJoint tests ---
|
||||
|
||||
func TestInfoJoint_Success(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user