diff --git a/src/server/game/friend_func.go b/src/server/game/friend_func.go index b2268963..7e70456c 100644 --- a/src/server/game/friend_func.go +++ b/src/server/game/friend_func.go @@ -35,6 +35,9 @@ func (p *Player) GetVisitorPlayer() int { if GoUtil.InArray(k, todayVisitedUsers) { continue } + if GoUtil.InArray(k, PlayroomMod.RandVisitor) { + continue + } if v.Time < now-86400 { continue } @@ -66,6 +69,9 @@ func (p *Player) GetVisitorPlayer() int { if GoUtil.InArray(uid, todayVisitedUsers) { continue } + if GoUtil.InArray(uid, PlayroomMod.RandVisitor) { + continue + } ps := G_GameLogicPtr.GetSimplePlayerByUid(uid) if ps == nil { continue diff --git a/src/server/game/mod/playroom/playroom.go b/src/server/game/mod/playroom/playroom.go index 1d022700..7fb17dda 100644 --- a/src/server/game/mod/playroom/playroom.go +++ b/src/server/game/mod/playroom/playroom.go @@ -62,6 +62,7 @@ type PlayroomMod struct { TodayVisitedUsers []int // 今日已拜访过的用户 ADItem map[int]*ItemInfo WeeklyDiscount map[int]int // 每周折扣 + RandVisitor []int // 随机访客 } type DressInfo struct { @@ -604,6 +605,7 @@ func (p *PlayroomMod) ResetGame() { p.GameReward = make(map[int]*item.Item) p.InteractNum = 0 p.RevengeUid = 0 + p.RandVisitor = nil } func (p *PlayroomMod) GetGameId() int { return p.GameId @@ -1104,3 +1106,15 @@ func (p *PlayroomMod) AdWatch(Id int) error { func (p *PlayroomMod) ResetWeeklyDiscount() { 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) +} diff --git a/src/server/game/register_network_func.go b/src/server/game/register_network_func.go index 2cd0c933..790523bd 100644 --- a/src/server/game/register_network_func.go +++ b/src/server/game/register_network_func.go @@ -3101,6 +3101,12 @@ func ReqPlayroomInfo(player *Player, req *msg.ReqPlayroomInfo) error { } if req.Uid == -1 { target = player.GetVisitorPlayer() + if target == 0 { + PlayroomMod.ResetRandVisitor() + target = player.GetVisitorPlayer() + } else { + PlayroomMod.AddRandVisitor(target) + } } if target == 0 { player.PlayroomVisit(target) diff --git a/src/server/unit_test/playroom_test.go b/src/server/unit_test/playroom_test.go new file mode 100644 index 00000000..80c563d0 --- /dev/null +++ b/src/server/unit_test/playroom_test.go @@ -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() +}