playroom好友优化,随机拜访好友去重
This commit is contained in:
parent
6def839472
commit
cf9dd92090
@ -35,6 +35,9 @@ func (p *Player) GetVisitorPlayer() int {
|
|||||||
if GoUtil.InArray(k, todayVisitedUsers) {
|
if GoUtil.InArray(k, todayVisitedUsers) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if GoUtil.InArray(k, PlayroomMod.RandVisitor) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if v.Time < now-86400 {
|
if v.Time < now-86400 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -66,6 +69,9 @@ func (p *Player) GetVisitorPlayer() int {
|
|||||||
if GoUtil.InArray(uid, todayVisitedUsers) {
|
if GoUtil.InArray(uid, todayVisitedUsers) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if GoUtil.InArray(uid, PlayroomMod.RandVisitor) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
ps := G_GameLogicPtr.GetSimplePlayerByUid(uid)
|
ps := G_GameLogicPtr.GetSimplePlayerByUid(uid)
|
||||||
if ps == nil {
|
if ps == nil {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -62,6 +62,7 @@ type PlayroomMod struct {
|
|||||||
TodayVisitedUsers []int // 今日已拜访过的用户
|
TodayVisitedUsers []int // 今日已拜访过的用户
|
||||||
ADItem map[int]*ItemInfo
|
ADItem map[int]*ItemInfo
|
||||||
WeeklyDiscount map[int]int // 每周折扣
|
WeeklyDiscount map[int]int // 每周折扣
|
||||||
|
RandVisitor []int // 随机访客
|
||||||
}
|
}
|
||||||
|
|
||||||
type DressInfo struct {
|
type DressInfo struct {
|
||||||
@ -604,6 +605,7 @@ func (p *PlayroomMod) ResetGame() {
|
|||||||
p.GameReward = make(map[int]*item.Item)
|
p.GameReward = make(map[int]*item.Item)
|
||||||
p.InteractNum = 0
|
p.InteractNum = 0
|
||||||
p.RevengeUid = 0
|
p.RevengeUid = 0
|
||||||
|
p.RandVisitor = nil
|
||||||
}
|
}
|
||||||
func (p *PlayroomMod) GetGameId() int {
|
func (p *PlayroomMod) GetGameId() int {
|
||||||
return p.GameId
|
return p.GameId
|
||||||
@ -1104,3 +1106,15 @@ func (p *PlayroomMod) AdWatch(Id int) error {
|
|||||||
func (p *PlayroomMod) ResetWeeklyDiscount() {
|
func (p *PlayroomMod) ResetWeeklyDiscount() {
|
||||||
p.WeeklyDiscount = make(map[int]int)
|
p.WeeklyDiscount = make(map[int]int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PlayroomMod) AddRandVisitor(id int) {
|
||||||
|
p.RandVisitor = append(p.RandVisitor, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PlayroomMod) GetRandVisitor() []int {
|
||||||
|
return p.RandVisitor
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PlayroomMod) ResetRandVisitor() {
|
||||||
|
p.RandVisitor = make([]int, 0)
|
||||||
|
}
|
||||||
|
|||||||
@ -3101,6 +3101,12 @@ func ReqPlayroomInfo(player *Player, req *msg.ReqPlayroomInfo) error {
|
|||||||
}
|
}
|
||||||
if req.Uid == -1 {
|
if req.Uid == -1 {
|
||||||
target = player.GetVisitorPlayer()
|
target = player.GetVisitorPlayer()
|
||||||
|
if target == 0 {
|
||||||
|
PlayroomMod.ResetRandVisitor()
|
||||||
|
target = player.GetVisitorPlayer()
|
||||||
|
} else {
|
||||||
|
PlayroomMod.AddRandVisitor(target)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if target == 0 {
|
if target == 0 {
|
||||||
player.PlayroomVisit(target)
|
player.PlayroomVisit(target)
|
||||||
|
|||||||
13
src/server/unit_test/playroom_test.go
Normal file
13
src/server/unit_test/playroom_test.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package unit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"server/game"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPlayroomVisit(t *testing.T) {
|
||||||
|
player := new(game.Player)
|
||||||
|
player.M_DwUin = 100101056
|
||||||
|
player.InitPlayerOnly()
|
||||||
|
player.GetVisitorPlayer()
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user