diff --git a/server/imserver_new/cache/cachemgr.go b/server/imserver_new/cache/cachemgr.go index d75f5482..6a78988f 100644 --- a/server/imserver_new/cache/cachemgr.go +++ b/server/imserver_new/cache/cachemgr.go @@ -28,7 +28,7 @@ func (this *cacheMgr) GetUserProfile(accountId string) common.UserProfile { return nil } -func (this *cacheMgr) PreLoad(accountIds []string) { +func (this *cacheMgr) PreLoadUsers(accountIds []string) { } func (this *cacheMgr) AsyncSearch(sinceId int64, q string, diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index 42a4e9dc..22c5563f 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -96,7 +96,7 @@ type GuildMgr interface { } type CacheMgr interface { - PreLoadUser([]string) + PreLoadUsers([]string) GetUserProfile(string) UserProfile AsyncGetUsers([]string, func(int32, string)) AsyncSearch(int64, string, func(int32, string, int64, []string)) diff --git a/server/imserver_new/global/global.go b/server/imserver_new/global/global.go index cedbe406..d4650223 100644 --- a/server/imserver_new/global/global.go +++ b/server/imserver_new/global/global.go @@ -12,6 +12,10 @@ var initOrders = []int32 { constant.HANDLER_MGR_MODULE_IDX, constant.PLAYER_MGR_MODULE_IDX, constant.WSPLISTENER_MODULE_IDX, + constant.FRIEND_MGR_MODULE_IDX, + constant.GUILD_MGR_MODULE_IDX, + constant.CACHE_MGR_MODULE_IDX, + constant.CHAT_MGR_MODULE_IDX, } var app common.App diff --git a/server/imserver_new/guild/guild.go b/server/imserver_new/guild/guild.go index 15e67c70..20b616f2 100644 --- a/server/imserver_new/guild/guild.go +++ b/server/imserver_new/guild/guild.go @@ -1,164 +1,8 @@ package guild import ( - "math/rand" - "main/constant" + ) -type GuildMember struct { - AccountId string - Level int32 // 1: 会长, 20: 副会长, 30: 精英, 40 成员 -} - -type Guild struct { - AutoId int64 // 公会自增id - GuildId int64 // 公会id - Name string // 公会名称 - LeaderId string // 公会leader - Avatar int32 // 头像 - Notice string // 公告 - JoinCond int32 // 公会加入条件 - JoinCondValue int32 // 公会加入条件值 - TotalStars int32 // 公会统计信息, 总星星数量 从api获取 - TotalKills int32 // 公会统计信息, 单局总击杀数 从api获取 - ChickenDinners int32 // 公会统计信息, 单局第一名数 从api获取 - MaxMembers int32 // 公会最大成员数 default 30 - Members map[string]*GuildMember // accountId -> GuildMember - PendingReqs map[string]int32 // pendingAccountId -> status 0,1,2,3 pending, accept, reject, leave -} - -// GuildLog 公会日志 -type GuildLog struct { - GuildId int64 - AccountId string - LogType int32 - Content string -} - -// PendingReq 待审核请求 -type PendingReq struct { - AccountId string - Status int32 // 0 pending, 1 ok, 2 reject, 3 disband -} - -func (this *Guild) GetGuildId() int64 { - return this.GuildId -} - -func (this *Guild) GetMembersCount() int { - return len(this.Members) -} - -func (this *Guild) GetMembersViceLeaderCount() int { - count := 0 - for _, member := range this.Members { - if member.Level == constant.GuildMemberLevelViceLeader { - count++ - } - } - return count -} - -// IsMember 是否是公会成员 -func (this *Guild) IsMember(accountId string) bool { - _, exists := this.Members[accountId] - return exists -} - -// IsFull 成员是否已满 -func (this *Guild) IsFull() bool { - return int32(len(this.Members)) >= this.MaxMembers -} - -// AddMember 添加成员 -func (this *Guild) AddMember(member *GuildMember) { - accountId := member.AccountId - this.Members[accountId] = member -} - -// RemoveMember 移除成员 -func (this *Guild) RemoveMember(accountId string) { - delete(this.Members, accountId) -} - -// GetMember 获取成员 -func (this *Guild) GetMember(accountId string) *GuildMember { - if member, exists := this.Members[accountId]; exists { - return member - } - return nil -} - -// GetMemberLevel 获取成员职位 -func (this *Guild) GetMemberLevel(accountId string) int32 { - if member, exists := this.Members[accountId]; exists { - return member.Level - } - return 0 -} - -func (this *Guild) SetNotice(notice *string) { - this.Notice = *notice -} - -func (this *Guild) GetNotice() string { - return this.Notice -} - -// AddPendingReq 添加等待审核成员 -func (this *Guild) AddPendingReq(p *PendingReq) { - this.PendingReqs[p.AccountId] = p.Status -} - -func (this *Guild) GetPendingReqStatus(accountId string) int32 { - if pendingReqStatus, exists := this.PendingReqs[accountId]; exists { - return pendingReqStatus - } - return -1 -} - -// RemovePendingReq 移除等待审核成员 -func (this *Guild) RemovePendingReq(accountId string) { - delete(this.PendingReqs, accountId) -} - -func (gm *GuildMember) GetAccountId() string { - return gm.AccountId -} - -func (this *Guild) IsInReq(accountId string) bool { - return this.PendingReqs[accountId] == constant.PendingReqIsJoinGuildStatusJoined -} - -func (this *Guild) NewLeader(oldLeaderId string) *GuildMember { - if len(this.Members) <= 0 { - return nil - } - - // 找到级别最高的成员 - highestLevel := int32(constant.GuildMemberLevelDefault) - highestLevelMembers := make([]*GuildMember, 0) - for accountId, member := range this.Members { - if accountId == oldLeaderId { - continue - } - - if member.Level < highestLevel { - // 发现更高级别的成员,重置列表 - highestLevel = member.Level - highestLevelMembers = []*GuildMember{member} - } else if member.Level == highestLevel { - // 发现与当前最高级别相同的成员,添加到列表中 - highestLevelMembers = append(highestLevelMembers, member) - } - } - - if len(highestLevelMembers) <= 0 { - return nil - } - - newLeaderIndex := rand.Intn(len(highestLevelMembers)) - newLeader := highestLevelMembers[newLeaderIndex] - newLeader.Level = constant.GuildMemberLevelLeader - return newLeader +type guild struct { } diff --git a/server/imserver_new/guild/guildmgr.go b/server/imserver_new/guild/guildmgr.go index a6ef875e..6f5c36f2 100644 --- a/server/imserver_new/guild/guildmgr.go +++ b/server/imserver_new/guild/guildmgr.go @@ -12,10 +12,11 @@ const ( ) type guildMgr struct { + /* guilds map[int64]*Guild // 公会ID -> 公会 guildLogs map[int64][]*GuildLog // 公会ID -> []公会日志列表 userGuilds map[string]int64 // accountId -> 公会ID - loadedFlags int64 + loadedFlags int64*/ } func (this *guildMgr) Init() { @@ -32,13 +33,13 @@ func (this *guildMgr) GetGuildByAccountId(string) common.Guild { return nil } -func (this *guildMgr) GetRecommendGuilds(string) []Guild { - guilds := []Guild{} +func (this *guildMgr) GetRecommendGuilds(string) []common.Guild { + guilds := []common.Guild{} return guilds } -func (this *guildMgr) GetGuildRank() []Guild { - guilds := []Guild{} +func (this *guildMgr) GetGuildRank() []common.Guild { + guilds := []common.Guild{} return guilds }