更新公会
This commit is contained in:
parent
c836719666
commit
fae06002f7
@ -54,15 +54,22 @@ CREATE TABLE `t_guild` (
|
|||||||
`guild_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '公会id',
|
`guild_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '公会id',
|
||||||
`name` varchar(48) NOT NULL,
|
`name` varchar(48) NOT NULL,
|
||||||
`leader_account_id` varchar(60) NOT NULL,
|
`leader_account_id` varchar(60) NOT NULL,
|
||||||
|
`avatar` int(11) DEFAULT '0' COMMENT '公会头像',
|
||||||
|
`notice` mediumtext DEFAULT '',
|
||||||
|
`join_cond` tinyint(4) DEFAULT '0' COMMENT '公会加入类型 0 需要审批, 1 自由加入, 2 成员星星数条件',
|
||||||
|
`join_cond_value` int(11) DEFAULT '0' COMMENT '星星数条件值',
|
||||||
|
`total_stars` int(11) DEFAULT '0',
|
||||||
|
`total_kills` int(11) DEFAULT '0',
|
||||||
|
`chicken_dinners` int(11) DEFAULT '0',
|
||||||
`max_members` int(11) DEFAULT '0',
|
`max_members` int(11) DEFAULT '0',
|
||||||
`is_deleted` tinyint(4) DEFAULT '0' COMMENT '是否已解散公会 0 正常, 1 已解散',
|
`is_deleted` tinyint(4) DEFAULT '0' COMMENT '是否已解散公会 0 正常, 1 已解散',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `idx_guild_id` (`guild_id`),
|
UNIQUE KEY `idx_guild_id` (`guild_id`),
|
||||||
KEY `idx_guild_name` (name),
|
UNIQUE KEY `idx_guild_name` (name),
|
||||||
KEY `idx_guild_leader` (leader_account_id)
|
KEY `idx_guild_leader` (leader_account_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='公会表';
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='公会表';
|
||||||
|
|
||||||
drop table if exists `t_guild_members`;
|
drop table if exists `t_guild_members`;
|
||||||
CREATE TABLE `t_guild_members` (
|
CREATE TABLE `t_guild_members` (
|
||||||
|
@ -11,7 +11,7 @@ type ChatMgr struct {
|
|||||||
fm *FriendsMgr
|
fm *FriendsMgr
|
||||||
gm *GuildMgr
|
gm *GuildMgr
|
||||||
|
|
||||||
worldMsgRec ChatMsgRec
|
worldMsgRec *ChatMsgRec
|
||||||
guildMsgRec map[int64]*ChatMsgRec
|
guildMsgRec map[int64]*ChatMsgRec
|
||||||
privateChatUsers map[string]*ChatUserRec
|
privateChatUsers map[string]*ChatUserRec
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ func NewChatMgr(pm *PlayerMgr, fm *FriendsMgr, gm *GuildMgr) *ChatMgr {
|
|||||||
pm: pm,
|
pm: pm,
|
||||||
fm: fm,
|
fm: fm,
|
||||||
gm: gm,
|
gm: gm,
|
||||||
worldMsgRec: ChatMsgRec{},
|
worldMsgRec: &ChatMsgRec{},
|
||||||
guildMsgRec: make(map[int64]*ChatMsgRec),
|
guildMsgRec: make(map[int64]*ChatMsgRec),
|
||||||
privateChatUsers: make(map[string]*ChatUserRec),
|
privateChatUsers: make(map[string]*ChatUserRec),
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ const (
|
|||||||
LogTypeDemote = 5
|
LogTypeDemote = 5
|
||||||
LogTypeDisband = 6
|
LogTypeDisband = 6
|
||||||
GuildMemberLevelLeader = 1 // 成员等级, 会长
|
GuildMemberLevelLeader = 1 // 成员等级, 会长
|
||||||
GuildMemberLevelCadre = 2 // 成员等级, 干部
|
GuildMemberLevelViceLeader = 2 // 成员等级, 副会长
|
||||||
|
GuildMemberLevelElite = 3 // 成员等级, 精英
|
||||||
GuildMemberLevelDefault = 3 // 成员等级, 普通成员
|
GuildMemberLevelDefault = 3 // 成员等级, 普通成员
|
||||||
PendingReqIsJoinGuildStatusDefault = 0 // 等待验证请求状态, 0 等待审核
|
PendingReqIsJoinGuildStatusDefault = 0 // 等待验证请求状态, 0 等待审核
|
||||||
PendingReqIsJoinGuildStatusJoined = 1 // 等待验证请求状态, 1 已加入
|
PendingReqIsJoinGuildStatusJoined = 1 // 等待验证请求状态, 1 已加入
|
||||||
|
@ -3670,11 +3670,13 @@ type MFGuild struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
GuildId *int64 `protobuf:"varint,1,opt,name=guild_id,json=guildId" json:"guild_id,omitempty"`
|
AutoId *int64 `protobuf:"varint,1,opt,name=auto_id,json=autoId" json:"auto_id,omitempty"`
|
||||||
Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
GuildId *int64 `protobuf:"varint,2,opt,name=guild_id,json=guildId" json:"guild_id,omitempty"`
|
||||||
LeaderId *string `protobuf:"bytes,3,opt,name=leader_id,json=leaderId" json:"leader_id,omitempty"`
|
Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
||||||
Members *int32 `protobuf:"varint,4,opt,name=members" json:"members,omitempty"`
|
LeaderId *string `protobuf:"bytes,4,opt,name=leader_id,json=leaderId" json:"leader_id,omitempty"`
|
||||||
MaxMembers *int32 `protobuf:"varint,5,opt,name=max_members,json=maxMembers" json:"max_members,omitempty"`
|
Members *int32 `protobuf:"varint,5,opt,name=members" json:"members,omitempty"`
|
||||||
|
MaxMembers *int32 `protobuf:"varint,6,opt,name=max_members,json=maxMembers" json:"max_members,omitempty"`
|
||||||
|
Notice *string `protobuf:"bytes,7,opt,name=notice" json:"notice,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *MFGuild) Reset() {
|
func (x *MFGuild) Reset() {
|
||||||
@ -3709,6 +3711,13 @@ func (*MFGuild) Descriptor() ([]byte, []int) {
|
|||||||
return file_cs_proto_proto_rawDescGZIP(), []int{68}
|
return file_cs_proto_proto_rawDescGZIP(), []int{68}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *MFGuild) GetAutoId() int64 {
|
||||||
|
if x != nil && x.AutoId != nil {
|
||||||
|
return *x.AutoId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (x *MFGuild) GetGuildId() int64 {
|
func (x *MFGuild) GetGuildId() int64 {
|
||||||
if x != nil && x.GuildId != nil {
|
if x != nil && x.GuildId != nil {
|
||||||
return *x.GuildId
|
return *x.GuildId
|
||||||
@ -3744,6 +3753,13 @@ func (x *MFGuild) GetMaxMembers() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *MFGuild) GetNotice() string {
|
||||||
|
if x != nil && x.Notice != nil {
|
||||||
|
return *x.Notice
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// 请求公会日志
|
// 请求公会日志
|
||||||
type CMGuildLogs struct {
|
type CMGuildLogs struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -4199,32 +4215,35 @@ var file_cs_proto_proto_rawDesc = []byte{
|
|||||||
0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x35, 0x0a, 0x0e, 0x53, 0x4d, 0x53, 0x65, 0x61,
|
0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x35, 0x0a, 0x0e, 0x53, 0x4d, 0x53, 0x65, 0x61,
|
||||||
0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x12, 0x23, 0x0a, 0x06, 0x67, 0x75, 0x69,
|
0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x12, 0x23, 0x0a, 0x06, 0x67, 0x75, 0x69,
|
||||||
0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x63, 0x73, 0x2e, 0x4d,
|
0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x63, 0x73, 0x2e, 0x4d,
|
||||||
0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x06, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x22, 0x90,
|
0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x06, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x22, 0xc1,
|
||||||
0x01, 0x0a, 0x07, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x75,
|
0x01, 0x0a, 0x07, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x61, 0x75,
|
||||||
0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x67, 0x75,
|
0x74, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x75, 0x74,
|
||||||
0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
|
0x6f, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x65, 0x61,
|
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x12,
|
||||||
0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x65,
|
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
|
||||||
0x61, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72,
|
0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,
|
||||||
0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73,
|
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12,
|
||||||
0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18,
|
0x18, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05,
|
||||||
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
|
0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78,
|
||||||
0x73, 0x22, 0x0d, 0x0a, 0x0b, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73,
|
0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
|
||||||
0x22, 0x3b, 0x0a, 0x0b, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x12,
|
0x6d, 0x61, 0x78, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f,
|
||||||
0x2c, 0x0a, 0x09, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03,
|
0x74, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69,
|
||||||
0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c,
|
0x63, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67,
|
||||||
0x6f, 0x67, 0x52, 0x09, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x7b, 0x0a,
|
0x73, 0x22, 0x3b, 0x0a, 0x0b, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73,
|
||||||
0x0a, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x67,
|
0x12, 0x2c, 0x0a, 0x09, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20,
|
||||||
0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x67,
|
0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64,
|
||||||
0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
0x4c, 0x6f, 0x67, 0x52, 0x09, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x7b,
|
||||||
0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f,
|
0x0a, 0x0a, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x12, 0x19, 0x0a, 0x08,
|
||||||
0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70,
|
0x67, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07,
|
||||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65,
|
0x67, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||||
0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
|
0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63,
|
||||||
0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2a, 0x22, 0x0a, 0x0a, 0x43, 0x6f,
|
0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x79,
|
||||||
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x74,
|
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x54, 0x79, 0x70,
|
||||||
0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42, 0x06,
|
0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01,
|
||||||
0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2a, 0x22, 0x0a, 0x0a, 0x43,
|
||||||
|
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f,
|
||||||
|
0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42,
|
||||||
|
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -4,18 +4,25 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GuildMember 公会成员
|
|
||||||
type GuildMember struct {
|
type GuildMember struct {
|
||||||
AccountId string
|
AccountId string
|
||||||
Level int // 1: 会长, 2: 干部, 3: 成员
|
Level int // 1: 会长, 2: 副会长, 3: 精英, 4 成员
|
||||||
}
|
}
|
||||||
|
|
||||||
type Guild struct {
|
type Guild struct {
|
||||||
GuildId int64
|
AutoId int64 // 公会自增id
|
||||||
Name string
|
GuildId int64 // 公会id
|
||||||
LeaderId string
|
Name string // 公会名称
|
||||||
Members []*GuildMember
|
LeaderId string // 公会leader
|
||||||
MaxMembers int
|
Avatar int32 // 头像
|
||||||
|
Notice string // 公告
|
||||||
|
JoinCond int32 // 公会加入条件
|
||||||
|
JoinCondValue int32 // 公会加入条件值
|
||||||
|
TotalStars int32 // 总星星数量
|
||||||
|
TotalKills int32 // 单局总击杀数
|
||||||
|
ChickenDinners int32 // 单局第一名数
|
||||||
|
MaxMembers int32 // 公会最大成员数 default 30
|
||||||
|
Members []*GuildMember
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuildLog 公会日志
|
// GuildLog 公会日志
|
||||||
@ -58,7 +65,7 @@ func (g *Guild) IsMember(accountId string) bool {
|
|||||||
|
|
||||||
// IsFull 成员是否已满
|
// IsFull 成员是否已满
|
||||||
func (g *Guild) IsFull() bool {
|
func (g *Guild) IsFull() bool {
|
||||||
return len(g.Members) >= g.MaxMembers
|
return int32(len(g.Members)) >= g.MaxMembers
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddMember 添加成员
|
// AddMember 添加成员
|
||||||
@ -88,3 +95,11 @@ func (g *Guild) RemoveMember(accountId string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Guild) SetNotice(notice *string) {
|
||||||
|
g.Notice = *notice
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Guild) GetNotice() string {
|
||||||
|
return g.Notice
|
||||||
|
}
|
||||||
|
@ -7,7 +7,20 @@ import (
|
|||||||
|
|
||||||
// loadGuildFromDB 加载公会
|
// loadGuildFromDB 加载公会
|
||||||
func (gm *GuildMgr) loadGuildFromDB() {
|
func (gm *GuildMgr) loadGuildFromDB() {
|
||||||
fields := []string{"guild_id", "name", "leader_account_id", "max_members"}
|
fields := []string{
|
||||||
|
"idx",
|
||||||
|
"guild_id",
|
||||||
|
"name",
|
||||||
|
"leader_account_id",
|
||||||
|
"avatar",
|
||||||
|
"notice",
|
||||||
|
"join_cond",
|
||||||
|
"join_cond_value",
|
||||||
|
"total_stars",
|
||||||
|
"total_kills",
|
||||||
|
"chicken_dinners",
|
||||||
|
"max_members",
|
||||||
|
}
|
||||||
where := [][]string{
|
where := [][]string{
|
||||||
{"is_deleted", "0"},
|
{"is_deleted", "0"},
|
||||||
}
|
}
|
||||||
@ -25,25 +38,22 @@ func (gm *GuildMgr) loadGuildFromDBResult(err error, rows *f5.DataSet) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
guildId := q5.ToInt64(*rows.GetByIndex(1))
|
||||||
guildId int64
|
// put to gm.guilds
|
||||||
name string
|
gm.guilds[guildId] = &Guild{
|
||||||
leaderAccountId string
|
AutoId: q5.ToInt64(*rows.GetByIndex(0)),
|
||||||
maxMembers int
|
GuildId: q5.ToInt64(*rows.GetByIndex(1)),
|
||||||
)
|
Name: q5.ToString(*rows.GetByIndex(2)),
|
||||||
guildId = q5.ToInt64(*rows.GetByIndex(0))
|
LeaderId: q5.ToString(*rows.GetByIndex(3)),
|
||||||
name = q5.ToString(*rows.GetByIndex(1))
|
Avatar: q5.ToInt32(*rows.GetByIndex(4)),
|
||||||
leaderAccountId = q5.ToString(*rows.GetByIndex(2))
|
Notice: q5.ToString(*rows.GetByIndex(5)),
|
||||||
maxMembers = int(q5.ToInt32(*rows.GetByIndex(3)))
|
JoinCond: q5.ToInt32(*rows.GetByIndex(6)),
|
||||||
|
JoinCondValue: q5.ToInt32(*rows.GetByIndex(7)),
|
||||||
newGuild := &Guild{
|
TotalStars: q5.ToInt32(*rows.GetByIndex(8)),
|
||||||
GuildId: guildId,
|
TotalKills: q5.ToInt32(*rows.GetByIndex(9)),
|
||||||
Name: name,
|
ChickenDinners: q5.ToInt32(*rows.GetByIndex(10)),
|
||||||
LeaderId: leaderAccountId,
|
MaxMembers: q5.ToInt32(*rows.GetByIndex(11)),
|
||||||
MaxMembers: maxMembers,
|
|
||||||
}
|
}
|
||||||
// push to gm.guilds
|
|
||||||
gm.guilds[guildId] = newGuild
|
|
||||||
// init pendingReqs
|
// init pendingReqs
|
||||||
gm.pendingReqs[guildId] = make(map[string]bool)
|
gm.pendingReqs[guildId] = make(map[string]bool)
|
||||||
}
|
}
|
||||||
@ -187,8 +197,8 @@ func (gm *GuildMgr) createGuildDB(g *Guild) {
|
|||||||
"t_guild",
|
"t_guild",
|
||||||
fields,
|
fields,
|
||||||
func(err error, lastInsertId int64, rowsAffected int64) {
|
func(err error, lastInsertId int64, rowsAffected int64) {
|
||||||
if err != nil {
|
if err != nil || rowsAffected != 1 {
|
||||||
f5.GetSysLog().Info("error:%v\n", err)
|
f5.GetSysLog().Info("createGuildDB:%v\n", err)
|
||||||
}
|
}
|
||||||
f5.GetSysLog().Info("lastInsertId:%d\n", lastInsertId)
|
f5.GetSysLog().Info("lastInsertId:%d\n", lastInsertId)
|
||||||
f5.GetSysLog().Info("rowsAffected:%d\n", rowsAffected)
|
f5.GetSysLog().Info("rowsAffected:%d\n", rowsAffected)
|
||||||
|
@ -131,7 +131,7 @@ func (gm *GuildMgr) Approve(guildId int64, operatorAccountId, accountId string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 公会干部及以上仅可操作
|
// 公会干部及以上仅可操作
|
||||||
err = gm.checkOperatorPerm(operatorMember, GuildMemberLevelCadre)
|
err = gm.checkOperatorPerm(operatorMember, GuildMemberLevelViceLeader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ func (gm *GuildMgr) JoinGuild(guildId int64, accountId string) error {
|
|||||||
return fmt.Errorf("guild not found")
|
return fmt.Errorf("guild not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(guild.Members) >= guild.MaxMembers {
|
if guild.IsFull() {
|
||||||
return fmt.Errorf("guild is full")
|
return fmt.Errorf("guild is full")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ func (gm *GuildMgr) DismissMember(guildId int64, operatorAccountId, accountId st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 公会干部及以上仅可操作
|
// 公会干部及以上仅可操作
|
||||||
err = gm.checkOperatorPerm(operatorMember, GuildMemberLevelCadre)
|
err = gm.checkOperatorPerm(operatorMember, GuildMemberLevelViceLeader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -302,12 +302,12 @@ func (gm *GuildMgr) PromoteMember(guildId int64, operatorAccountId, accountId st
|
|||||||
return fmt.Errorf("member not found in the guild")
|
return fmt.Errorf("member not found in the guild")
|
||||||
}
|
}
|
||||||
|
|
||||||
if member.Level == GuildMemberLevelCadre {
|
if member.Level == GuildMemberLevelViceLeader {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
member.Level = GuildMemberLevelCadre
|
member.Level = GuildMemberLevelViceLeader
|
||||||
fields := [][]string{{"level", q5.ToString(GuildMemberLevelCadre)}}
|
fields := [][]string{{"level", q5.ToString(GuildMemberLevelViceLeader)}}
|
||||||
gm.updateGuildMember(guild, member.AccountId, fields)
|
gm.updateGuildMember(guild, member.AccountId, fields)
|
||||||
|
|
||||||
logContent := fmt.Sprintf("PromoteMember[%d-%s-%s]", guildId, operatorAccountId, accountId)
|
logContent := fmt.Sprintf("PromoteMember[%d-%s-%s]", guildId, operatorAccountId, accountId)
|
||||||
@ -399,19 +399,25 @@ func (gm *GuildMgr) Disband(guildId int64, accountId string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GuildMgr) RemoveGuildsId(guildId int64) {
|
// SetNotice 设置公告
|
||||||
guildIndex := -1
|
func (gm *GuildMgr) SetNotice(guildId int64, accountId string, notice *string) error {
|
||||||
for i, gId := range gm.guildIds {
|
guild := gm.GetGuild(guildId)
|
||||||
if gId == guildId {
|
if guild == nil {
|
||||||
guildIndex = i
|
return fmt.Errorf("guild not found")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if guildIndex < 0 {
|
|
||||||
return
|
// 仅会长可操作
|
||||||
|
if accountId != guild.LeaderId {
|
||||||
|
return fmt.Errorf("cannot disband guild")
|
||||||
}
|
}
|
||||||
copy(gm.guildIds[guildIndex:], gm.guildIds[guildIndex+1:])
|
guild.SetNotice(notice)
|
||||||
gm.guildIds[len(gm.guildIds)-1] = 0
|
|
||||||
gm.guildIds = gm.guildIds[:len(gm.guildIds)-1]
|
updateFields := [][]string{
|
||||||
|
{"notice", *notice},
|
||||||
|
}
|
||||||
|
gm.updateGuild(guild, updateFields)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteLog 记录公会日志
|
// WriteLog 记录公会日志
|
||||||
@ -537,12 +543,23 @@ func (gm *GuildMgr) loadGuildIds() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GuildMgr) addGuildIds(guildId int64) {
|
func (gm *GuildMgr) RemoveGuildsId(guildId int64) {
|
||||||
gm.guildIds = append(gm.guildIds, guildId)
|
guildIndex := -1
|
||||||
|
for i, gId := range gm.guildIds {
|
||||||
|
if gId == guildId {
|
||||||
|
guildIndex = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if guildIndex < 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
copy(gm.guildIds[guildIndex:], gm.guildIds[guildIndex+1:])
|
||||||
|
gm.guildIds[len(gm.guildIds)-1] = 0
|
||||||
|
gm.guildIds = gm.guildIds[:len(gm.guildIds)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func containsSubstring(s, substr string) bool {
|
func (gm *GuildMgr) addGuildIds(guildId int64) {
|
||||||
return len(s) >= len(substr) && s[len(s)-len(substr):] == substr
|
gm.guildIds = append(gm.guildIds, guildId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GuildMgr) GetAllPendingReqs(guildId int64) map[string]bool {
|
func (gm *GuildMgr) GetAllPendingReqs(guildId int64) map[string]bool {
|
||||||
@ -558,3 +575,7 @@ func (gm *GuildMgr) GetGuildLogs(guildId int64) []*GuildLog {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func containsSubstring(s, substr string) bool {
|
||||||
|
return len(s) >= len(substr) && s[len(s)-len(substr):] == substr
|
||||||
|
}
|
||||||
|
@ -300,14 +300,17 @@ func (p *Player) CMGuildInfo(hdr *f5.MsgHdr, msg *cs.CMGuildInfo) {
|
|||||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
members := q5.ToInt32(len(g.Members))
|
members := q5.ToInt32(len(g.Members))
|
||||||
maxMembers := q5.ToInt32(g.MaxMembers)
|
maxMembers := q5.ToInt32(g.MaxMembers)
|
||||||
currGuild := &cs.MFGuild{
|
currGuild := &cs.MFGuild{
|
||||||
|
AutoId: &g.AutoId,
|
||||||
GuildId: &g.GuildId,
|
GuildId: &g.GuildId,
|
||||||
Name: &g.Name,
|
Name: &g.Name,
|
||||||
LeaderId: &g.LeaderId,
|
LeaderId: &g.LeaderId,
|
||||||
Members: &members,
|
Members: &members,
|
||||||
MaxMembers: &maxMembers,
|
MaxMembers: &maxMembers,
|
||||||
|
Notice: &g.Notice,
|
||||||
}
|
}
|
||||||
rspMsg.Guild = currGuild
|
rspMsg.Guild = currGuild
|
||||||
rspMsg.RandomGuilds = nil
|
rspMsg.RandomGuilds = nil
|
||||||
@ -514,11 +517,13 @@ func (p *Player) FillGuild(guilds []*Guild) []*cs.MFGuild {
|
|||||||
members := q5.ToInt32(len(g.Members))
|
members := q5.ToInt32(len(g.Members))
|
||||||
maxMembers := q5.ToInt32(g.MaxMembers)
|
maxMembers := q5.ToInt32(g.MaxMembers)
|
||||||
guild := &cs.MFGuild{
|
guild := &cs.MFGuild{
|
||||||
|
AutoId: &g.AutoId,
|
||||||
GuildId: &g.GuildId,
|
GuildId: &g.GuildId,
|
||||||
Name: &g.Name,
|
Name: &g.Name,
|
||||||
LeaderId: &g.LeaderId,
|
LeaderId: &g.LeaderId,
|
||||||
Members: &members,
|
Members: &members,
|
||||||
MaxMembers: &maxMembers,
|
MaxMembers: &maxMembers,
|
||||||
|
Notice: &g.Notice,
|
||||||
}
|
}
|
||||||
resGuilds = append(resGuilds, guild)
|
resGuilds = append(resGuilds, guild)
|
||||||
}
|
}
|
||||||
|
@ -487,11 +487,13 @@ message SMSearchGuilds
|
|||||||
repeated MFGuild guilds = 1;
|
repeated MFGuild guilds = 1;
|
||||||
}
|
}
|
||||||
message MFGuild {
|
message MFGuild {
|
||||||
optional int64 guild_id = 1;
|
optional int64 auto_id = 1;
|
||||||
optional string name = 2;
|
optional int64 guild_id = 2;
|
||||||
optional string leader_id = 3;
|
optional string name = 3;
|
||||||
optional int32 members = 4;
|
optional string leader_id = 4;
|
||||||
optional int32 max_members = 5;
|
optional int32 members = 5;
|
||||||
|
optional int32 max_members = 6;
|
||||||
|
optional string notice = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求公会日志
|
// 请求公会日志
|
||||||
|
Loading…
x
Reference in New Issue
Block a user