pet_home_server/src/server/game/PlayerBack.go
2025-07-28 10:38:24 +08:00

183 lines
5.1 KiB
Go

package game
import (
"server/GoUtil"
"server/game/mod/item"
proto "server/msg"
)
func (p *Player) NotifyPlayroomTask() {
PlayroomMod := p.PlayMod.getPlayroomMod()
m := &proto.NotifyPlayroomTask{
DailyTask: PlayroomMod.BackDataTask(),
DailyTaskReward: GoUtil.IntToInt32(PlayroomMod.DailyTaskReward),
}
p.PushClientRes(m)
}
func PlayroomBackData(p *Player) {
r := &proto.ResPlayroom{}
PlayroomMod := p.PlayMod.getPlayroomMod()
FriendMod := p.PlayMod.getFriendMod()
r.Status = int32(PlayroomMod.Status)
r.Items = item.ItemToMsg(PlayroomMod.Reward)
Opponent := make([]*proto.RoomOpponent, 0)
FriendList := make([]*proto.FriendRoom, 0)
for k, v := range PlayroomMod.Visitor {
ps := G_GameLogicPtr.GetSimplePlayerByUid(k)
if ps == nil {
continue
}
if !FriendMod.CheckFriend(k) {
Opponent = append(Opponent, &proto.RoomOpponent{
Uid: int64(k),
Name: ps.Name,
Face: int32(ps.Face),
Avatar: int32(ps.Avatar),
LastTime: int32(v.Time),
})
}
}
Friend := FriendMod.GetFriendList()
for k := range Friend {
ps := G_GameLogicPtr.GetSimplePlayerByUid(k)
if ps == nil {
continue
}
Times, _ := PlayroomMod.GetVisitorInfo(k)
FriendList = append(FriendList, &proto.FriendRoom{
Uid: int64(k),
Name: ps.Name,
Face: int32(ps.Face),
Avatar: int32(ps.Avatar),
Times: int32(Times),
})
}
r.Opponent = Opponent
r.Friend = FriendList
Collect := make([]int32, 0)
for k, v := range PlayroomMod.GetCollect() {
if v > 0 {
Collect = append(Collect, int32(k))
}
}
r.Collect = Collect
Dress := make(map[int32]*proto.PlayroomDress)
for k, v := range PlayroomMod.GetDress() {
Dress[int32(k)] = &proto.PlayroomDress{
List: GoUtil.IntToInt32(v),
}
}
ChipMessage := make([]*proto.ChipInfo, 0)
for _, v := range PlayroomMod.ChipList {
ChipMessage = append(ChipMessage, &proto.ChipInfo{
Uid: int64(v.Uid),
EmojiId: int32(v.Emoji),
})
}
AdWatch := make([]*proto.AdItem, 0)
for k, v := range PlayroomMod.ADItem {
AdWatch = append(AdWatch, &proto.AdItem{
Watch: int32(v.Watch),
LastWatch: int32(v.LastTime),
ItemId: int32(k),
})
}
data := G_GameLogicPtr.GetUserData(int(p.M_DwUin))
r.Dress = Dress
r.DressSet = GoUtil.MapIntToInt32(PlayroomMod.GetDressSet())
r.PetAir = GoUtil.IntToInt32(PlayroomMod.GetPetAir())
r.PetAirSet = int32(PlayroomMod.GetPetAirSet())
r.Chip = ChipMessage
r.StartTime = int32(PlayroomMod.Starttime)
r.WorkStatus = int32(PlayroomMod.WorkStatus)
r.Playroom = GoUtil.MapIntToInt32(PlayroomMod.GetRoom())
r.Mood = GoUtil.MapIntToInt32(PlayroomMod.GetMood())
r.Physiology = GoUtil.MapIntToInt32(PlayroomMod.GetPhysiologyList())
r.AllMood = int32(PlayroomMod.AllMood)
r.Jackpot = int32(PlayroomMod.JackpotNum)
r.Upvote = int32(PlayroomMod.Upvote)
r.RoomPoint = int32(PlayroomMod.RoomPoint)
r.Unlock = PlayroomMod.GetUnlockIds()
r.DailyTaskReward = GoUtil.IntToInt32(PlayroomMod.DailyTaskReward)
r.DailyTask = PlayroomMod.BackDataTask()
r.Kiss = int32(data.Kiss)
r.Revenge = PlayroomMod.RevengeUid
r.InteractNum = int32(PlayroomMod.InteractNum)
r.AdItem = AdWatch
p.PushClientRes(r)
}
func PlayroomVisit(p *Player, Uid int) {
if Uid == 0 {
p.PushClientRes(&proto.ResPlayroomInfo{})
return
}
PlayroomMod := p.PlayMod.getPlayroomMod()
r := &proto.ResPlayroomInfo{}
PlayerData := G_GameLogicPtr.GetSimplePlayerByUid(Uid)
Now := GoUtil.Now()
Work := false
if PlayerData.WorkStart > 0 && PlayerData.WorkStart+86400 > Now {
Work = true
}
r.Uid = int64(Uid)
r.Name = PlayerData.Name
r.Face = int32(PlayerData.Face)
r.Avatar = int32(PlayerData.Avatar)
r.Playroom = GoUtil.MapIntToInt32(PlayerData.Playroom)
r.GameId = int32(PlayroomMod.GameId)
r.Defense = Work
r.Emoji = GoUtil.MapIntToInt32(PlayerData.Emoji)
r.PetName = PlayerData.PetName
Items := make(map[int32]*proto.ItemInfo, 0)
for k, v := range PlayroomMod.GameReward {
Items[int32(k)] = &proto.ItemInfo{
Id: int32(v.Id),
Num: int32(v.Num),
}
}
r.Upvote = GoUtil.InArray(Uid, PlayroomMod.UpvoteList)
r.Items = Items
r.Status = int32(PlayroomMod.GameStatus)
data := G_GameLogicPtr.GetUserData(Uid)
r.UpvoteCount = int32(data.Upvote)
r.Chip = int32(data.Chip)
r.Kiss = int32(data.Kiss)
r.DressSet = GoUtil.MapIntToInt32(PlayerData.DressSet)
p.PushClientRes(r)
}
func (p *Player) NotifyPlayroomKiss() {
data := G_GameLogicPtr.GetUserData(int(p.M_DwUin))
m := &proto.NotifyPlayroomKiss{
Kiss: int32(data.Kiss),
}
p.PushClientRes(m)
}
func BackUserInfo(p *Player) {
BaseMod := p.PlayMod.getBaseMod()
FaceMod := p.PlayMod.getFaceMod()
AvatarMod := p.PlayMod.getAvatarMod()
DecorateMod := p.PlayMod.getDecorateMod()
p.PushClientRes(&proto.UserInfo{
Uid: p.M_DwUin,
Nickname: BaseMod.NickName,
Avatar: int32(AvatarMod.SetId),
Face: int32(FaceMod.SetId),
DecorateCnt: int32(DecorateMod.DecorateNum),
AvatarList: AvatarMod.BackData(),
FaceList: FaceMod.BackData(),
EmojiList: p.PlayMod.getEmojiMod().BackData(),
SetEmoji: p.PlayMod.getEmojiMod().GetEmojiSet(),
Login: int32(BaseMod.GetLoginTime()),
PetName: BaseMod.PetName,
IdNum: BaseMod.IdCardNum,
AddCode: BaseMod.AddCode,
})
}