1
This commit is contained in:
parent
0725405c82
commit
0905ea20d6
@ -367,17 +367,29 @@ func (this *playerMgr) GetRecommendPlayers(excludeHums map[string]int32, outHums
|
||||
this.recommendHumans = []*player{}
|
||||
this.traverseHumans(
|
||||
func (hum *player) bool {
|
||||
if _, ok := excludeHums[hum.GetAccountId()]; !ok {
|
||||
q5.AppendSlice(&this.recommendHumans, hum)
|
||||
}
|
||||
q5.AppendSlice(&this.recommendHumans, hum)
|
||||
return true
|
||||
})
|
||||
rand.Shuffle(len(this.recommendHumans), func (i int, j int) {
|
||||
this.recommendHumans[i], this.recommendHumans[j] = this.recommendHumans[j], this.recommendHumans[i]
|
||||
})
|
||||
}
|
||||
randLen := 10
|
||||
if randLen > len(this.recommendHumans) {
|
||||
randLen = len(this.recommendHumans)
|
||||
if len(this.recommendHumans) > 0 {
|
||||
rnd := rand.Int() % len(this.recommendHumans)
|
||||
for i := rnd; i < len(this.recommendHumans); i++ {
|
||||
if _, ok := excludeHums[this.recommendHumans[i].accountId]; !ok{
|
||||
outHums[this.recommendHumans[i].accountId] = 1
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(this.recommendHumans); i++ {
|
||||
if _, ok := excludeHums[this.recommendHumans[i].accountId]; !ok{
|
||||
if len(outHums) > 5 {
|
||||
break
|
||||
}
|
||||
if _, ok2 := outHums[this.recommendHumans[i].accountId]; !ok2 {
|
||||
outHums[this.recommendHumans[i].accountId] = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rand.Shuffle(randLen, func (i int, j int) {
|
||||
this.recommendHumans[i], this.recommendHumans[j] = this.recommendHumans[j], this.recommendHumans[i]
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user