save
This commit is contained in:
parent
4a3955fd5b
commit
b2b6ec729a
@ -8,7 +8,6 @@ import (
|
||||
"math/rand"
|
||||
"mt"
|
||||
"q5"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -890,22 +889,6 @@ func (gm *GuildMgr) SearchGuild(sinceId int64, name string, cb func(errCode int3
|
||||
})
|
||||
}
|
||||
|
||||
func (gm *GuildMgr) GetTopGuildsByTotalStars(rankNum int) []*Guild {
|
||||
allGuilds := make([]*Guild, 0, len(gm.guilds))
|
||||
for _, guild := range gm.guilds {
|
||||
allGuilds = append(allGuilds, guild)
|
||||
}
|
||||
|
||||
sort.Slice(allGuilds, func(i, j int) bool {
|
||||
return allGuilds[i].TotalStars > allGuilds[j].TotalStars
|
||||
})
|
||||
|
||||
if len(allGuilds) <= rankNum {
|
||||
return allGuilds
|
||||
}
|
||||
return allGuilds[:rankNum]
|
||||
}
|
||||
|
||||
// RandomGuilds 随机10个公会
|
||||
func (gm *GuildMgr) RandomGuilds() []*Guild {
|
||||
if len(gm.guilds) <= RandomGuildCount {
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"f5"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"q5"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
@ -350,7 +351,23 @@ func (p *Player) CMRecommendGuildList(hdr *f5.MsgHdr, msg *cs.CMRecommendGuildLi
|
||||
func (p *Player) CMGetTopGuildsByTotalStars(hdr *f5.MsgHdr, msg *cs.CMGetTopGuildsByTotalStars) {
|
||||
rspMsg := new(cs.SMGetTopGuildsByTotalStars)
|
||||
guildsNum := int(msg.GetGuildsNum())
|
||||
rspMsg.Guilds = p.FillMFGuilds(guildMgr.GetTopGuildsByTotalStars(guildsNum))
|
||||
|
||||
var allMFGuilds []*cs.MFGuild
|
||||
for _, g := range guildMgr.guilds {
|
||||
guild := p.FillMFGuild(g)
|
||||
allMFGuilds = append(allMFGuilds, guild)
|
||||
}
|
||||
|
||||
sort.Slice(allMFGuilds, func(i, j int) bool {
|
||||
return allMFGuilds[i].GetTotalStars() > allMFGuilds[j].GetTotalStars()
|
||||
})
|
||||
|
||||
if guildsNum > len(allMFGuilds) {
|
||||
guildsNum = len(allMFGuilds)
|
||||
}
|
||||
allMFGuilds = allMFGuilds[:guildsNum]
|
||||
rspMsg.Guilds = allMFGuilds
|
||||
|
||||
p.SendMsg(rspMsg)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user