451 lines
13 KiB
Go
451 lines
13 KiB
Go
package game
|
|
|
|
import (
|
|
chargeCfg "server/conf/charge"
|
|
playroomCfg "server/conf/playroom"
|
|
"server/game/mod/activity"
|
|
"server/game/mod/item"
|
|
limitedTimeEvent "server/game/mod/limited_time_event"
|
|
GoUtil "server/game_util"
|
|
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 (p *Player) PlayroomBackData() {
|
|
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, len(PlayroomMod.Visitor))
|
|
FriendList := make([]*proto.FriendRoom, 0, len(FriendMod.GetFriendList()))
|
|
if PlayroomMod.Target == 0 {
|
|
PlayroomMod.SetTarget(p.GetVisitorPlayer())
|
|
}
|
|
targetRoom := &proto.FriendRoom{}
|
|
if PlayroomMod.Target != 0 {
|
|
playerData := G_GameLogicPtr.GetSimplePlayerByUid(PlayroomMod.Target)
|
|
if playerData != nil {
|
|
targetRoom.Uid = int64(playerData.Uid)
|
|
targetRoom.Name = playerData.Name
|
|
targetRoom.Face = int32(playerData.Face)
|
|
targetRoom.Avatar = int32(playerData.Avatar)
|
|
} else {
|
|
PlayroomMod.Target = 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
|
|
r.Target = targetRoom
|
|
|
|
collectList := PlayroomMod.GetCollect()
|
|
collect := make([]*proto.PlayroomCollectInfo, 0, len(collectList))
|
|
for _, v := range collectList {
|
|
collect = append(collect, &proto.PlayroomCollectInfo{
|
|
Id: int32(v.Id),
|
|
AddTime: v.AddTime,
|
|
EndTime: v.EndTime,
|
|
Label: v.Label,
|
|
})
|
|
}
|
|
r.Collect = collect
|
|
dress := make(map[int32]*proto.PlayroomDress)
|
|
for _, v := range PlayroomMod.GetDress() {
|
|
PlayroomDress, ok := dress[int32(v.Part)]
|
|
if !ok {
|
|
PlayroomDress = &proto.PlayroomDress{}
|
|
}
|
|
PlayroomDress.List = append(PlayroomDress.List, &proto.PlayroomDressInfo{
|
|
Id: int32(v.Id),
|
|
AddTime: int64(v.AddTime),
|
|
EndTime: int64(v.EndTime),
|
|
Label: v.Label,
|
|
})
|
|
dress[int32(v.Part)] = PlayroomDress
|
|
}
|
|
chipMessage := make([]*proto.ChipInfo, 0, len(PlayroomMod.ChipList))
|
|
for _, v := range PlayroomMod.ChipList {
|
|
chipMessage = append(chipMessage, &proto.ChipInfo{
|
|
Uid: int64(v.Uid),
|
|
EmojiId: int32(v.Emoji),
|
|
})
|
|
}
|
|
adWatch := make([]*proto.AdItem, 0, len(PlayroomMod.ADItem))
|
|
for k, v := range PlayroomMod.ADItem {
|
|
adWatch = append(adWatch, &proto.AdItem{
|
|
Watch: int32(v.Watch),
|
|
LastWatch: int32(v.LastTime),
|
|
ItemId: int32(k),
|
|
})
|
|
}
|
|
|
|
r.Dress = dress
|
|
r.DressSet = GoUtil.MapIntToInt32(PlayroomMod.GetDressSet())
|
|
petAirList := PlayroomMod.GetPetAir()
|
|
PetAir := make([]*proto.PlayroomAirInfo, 0, len(petAirList))
|
|
for _, v := range petAirList {
|
|
PetAir = append(PetAir, &proto.PlayroomAirInfo{
|
|
Id: int32(v.Id),
|
|
AddTime: int64(v.AddTime),
|
|
Label: v.Label,
|
|
})
|
|
}
|
|
weeklyDiscount := make(map[int32]*proto.WeeklyDiscountInfo)
|
|
ChargeMod := p.PlayMod.getChargeMod()
|
|
LimitedEventMod := p.PlayMod.getLimitedTimeEventMod()
|
|
// 优惠日开启或者猫咪闪促开启
|
|
if ChargeMod.IsWeeklyDiscountDay() || LimitedEventMod.CheckExist(limitedTimeEvent.EVENT_TYPE_CAT_DAY_SALE) {
|
|
w1 := playroomCfg.GetShopWeeklyLimit()
|
|
for k, v := range w1 {
|
|
limitNum := PlayroomMod.WeeklyDiscount[k]
|
|
weeklyDiscount[int32(k)] = &proto.WeeklyDiscountInfo{
|
|
Id: int32(k),
|
|
Discount: int32(v.Discount),
|
|
Count: int32(v.WeeklyLimit - limitNum),
|
|
}
|
|
}
|
|
}
|
|
r.WeeklyDiscount = weeklyDiscount
|
|
r.PetAir = PetAir
|
|
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(p.GetPlayroomKiss(int(p.M_DwUin)))
|
|
r.Revenge = PlayroomMod.RevengeUid
|
|
r.InteractNum = int32(PlayroomMod.InteractNum)
|
|
r.AdItem = adWatch
|
|
p.PushClientRes(r)
|
|
}
|
|
|
|
func (p *Player) PlayroomVisit(uid int) {
|
|
if uid == 0 {
|
|
p.PushClientRes(&proto.ResPlayroomInfo{})
|
|
return
|
|
}
|
|
PlayroomMod := p.PlayMod.getPlayroomMod()
|
|
r := &proto.ResPlayroomInfo{}
|
|
PlayerData := G_GameLogicPtr.GetSimplePlayerByUid(uid)
|
|
if PlayerData == nil {
|
|
p.PushClientRes(&proto.ResPlayroomInfo{})
|
|
return
|
|
}
|
|
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)
|
|
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)
|
|
r.UpvoteCount = int32(p.GetPlayroomUpvote(uid))
|
|
r.Chip = int32(p.GetPlayroomChip(uid))
|
|
r.Kiss = int32(p.GetPlayroomKiss(uid))
|
|
r.DressSet = GoUtil.MapIntToInt32(PlayerData.DressSet)
|
|
r.Fur = int32(PlayerData.PetFur)
|
|
r.Star = int32(PlayerData.Star)
|
|
p.PushClientRes(r)
|
|
}
|
|
|
|
func (p *Player) NotifyPlayroomKiss() {
|
|
m := &proto.NotifyPlayroomKiss{
|
|
Kiss: int32(p.GetPlayroomKiss(int(p.M_DwUin))),
|
|
}
|
|
p.PushClientRes(m)
|
|
}
|
|
|
|
func (p *Player) BackUserInfo() {
|
|
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,
|
|
})
|
|
}
|
|
|
|
func (p *Player) ChargeBackData() {
|
|
c := p.PlayMod.getChargeMod()
|
|
LimitedEventMod := p.PlayMod.getLimitedTimeEventMod()
|
|
specialShop := make(map[int32]*proto.ResSpecialShop)
|
|
chessShop := make(map[int32]*proto.ResChessShop)
|
|
for k, v := range c.SpecialShop {
|
|
specialShop[int32(k)] = &proto.ResSpecialShop{
|
|
Grade: int32(v.Grade),
|
|
Count: int32(v.Count),
|
|
}
|
|
}
|
|
|
|
for k, v := range c.ChessShop {
|
|
chessShop[int32(k)] = &proto.ResChessShop{
|
|
Diamond: int32(v.Diamond),
|
|
Count: int32(v.Count),
|
|
ChessId: int32(v.Id),
|
|
}
|
|
}
|
|
resWish := &proto.WishList{}
|
|
if c.WishList != nil {
|
|
resWish = &proto.WishList{
|
|
Id: int32(c.WishList.ItemId),
|
|
Count: int32(c.WishList.Count),
|
|
Uid: c.WishList.SendList,
|
|
}
|
|
}
|
|
weeklyDiscount := make(map[int32]*proto.WeeklyDiscountInfo)
|
|
weeklyDiscountInfo := chargeCfg.GetWeeklyInfoAll()
|
|
// 优惠日开启或者猫咪闪促开启
|
|
if c.IsWeeklyDiscountDay() || LimitedEventMod.CheckExist(limitedTimeEvent.EVENT_TYPE_CAT_DAY_SALE) {
|
|
for k, v := range weeklyDiscountInfo {
|
|
LimitNum := c.WeeklyDiscount[k]
|
|
weeklyDiscount[int32(k)] = &proto.WeeklyDiscountInfo{
|
|
Discount: int32(v.Discount),
|
|
Count: int32(v.WeeklyLimit - LimitNum),
|
|
Id: int32(k),
|
|
}
|
|
}
|
|
}
|
|
catDaySaleEndTime := LimitedEventMod.GetCatDaySaleEndTime()
|
|
var specialChargeWeek int32
|
|
if c.LastSpecialCharge != 0 {
|
|
specialChargeWeek = int32(GoUtil.FullWeeksSince(c.LastSpecialCharge))
|
|
}
|
|
p.PushClientRes(&proto.ResCharge{
|
|
Charge: float32(c.Charge),
|
|
Total: int32(c.Total),
|
|
First: GoUtil.MapIntToSlice(c.EnergyShop),
|
|
SpecialShop: specialShop,
|
|
FreeShop: int32(c.FreeShop),
|
|
ChessShop: chessShop,
|
|
Gift: GoUtil.MapIntToInt32(c.Gift),
|
|
Ad: c.Ad,
|
|
SpecialCharge: float32(c.SpecialCharge),
|
|
SpecialChargeWeek: specialChargeWeek,
|
|
TodayCharge: float32(c.TodayCharge),
|
|
MonthCharge: float32(c.MonthCharge),
|
|
Wish: resWish,
|
|
AdEndTime: c.AdEndTime,
|
|
WeeklyDiscount: weeklyDiscount,
|
|
PetWorkRemainTime: c.PetWorkTime,
|
|
WeeklyEndTime: max(c.WeeklyEndTime, catDaySaleEndTime),
|
|
})
|
|
}
|
|
|
|
func (p *Player) BackChampship() {
|
|
ChampshipMod := p.PlayMod.getChampshipMod()
|
|
rank, preRank := p.GetChampshipRank()
|
|
todayActivityId, yesterdayActivityId := p.GetChampshipActivityId()
|
|
activityInfo := p.GetActivityInfo(activity.ACT_TYPE_CHAMPION)
|
|
res := ChampshipMod.BackData(rank, preRank, todayActivityId, yesterdayActivityId)
|
|
cfg := G_GameLogicPtr.ActivityMgr.GetChampshipCfg(todayActivityId)
|
|
res.EndTime = int32(GoUtil.ZeroTimestamp() + 86400)
|
|
if cfg != nil && GoUtil.Now()-GoUtil.ZeroTimestamp() >= int64(cfg.ClearTime) {
|
|
res.Status = 1
|
|
} else {
|
|
cfg = G_GameLogicPtr.ActivityMgr.GetChampshipCfg(yesterdayActivityId)
|
|
}
|
|
if cfg != nil {
|
|
res.Title = cfg.Title
|
|
}
|
|
if activityInfo != nil {
|
|
res.StartTime = int32(activityInfo.StartT)
|
|
res.EndTime = int32(activityInfo.EndT)
|
|
}
|
|
res.Cfg = cfg
|
|
p.PushClientRes(res)
|
|
}
|
|
|
|
// 获取冠军赛排名 redis缓存
|
|
func (p *Player) GetChampshipRank() (int, int) {
|
|
preRank, rank, _, _ := GetRankCache(int(p.M_DwUin))
|
|
return rank, preRank
|
|
}
|
|
|
|
// 返回好友信息
|
|
func (p *Player) FriendListBackData() {
|
|
FriendMod := p.PlayMod.getFriendMod()
|
|
friendList := FriendMod.GetFriendList()
|
|
fl := make([]*proto.ResPlayerSimple, 0, len(friendList))
|
|
for k, v := range friendList {
|
|
if k == int(p.M_DwUin) {
|
|
continue
|
|
}
|
|
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
|
if ps != nil {
|
|
ps.AddTime = v.AddTime
|
|
ps.Interact = FriendMod.GetInteractTime(k)
|
|
fl = append(fl, ps)
|
|
}
|
|
}
|
|
now := GoUtil.Now()
|
|
reqFriendList := make([]int64, 0, len(FriendMod.SendApply))
|
|
for k, v := range FriendMod.SendApply {
|
|
if now-v > oneday {
|
|
continue
|
|
}
|
|
reqFriendList = append(reqFriendList, int64(k))
|
|
}
|
|
p.PushClientRes(&proto.ResFriendList{
|
|
FriendList: fl,
|
|
ReqApplyList: reqFriendList,
|
|
Npc: GoUtil.IntToInt32(FriendMod.GetNpc()),
|
|
Sponsor: int32(FriendMod.GetSponsor()),
|
|
})
|
|
}
|
|
|
|
func (p *Player) FriendApplyBackData() {
|
|
FriendMod := p.PlayMod.getFriendMod()
|
|
al := make([]*proto.ResFriendApplyInfo, 0, len(FriendMod.NewApplyList))
|
|
for k, v := range FriendMod.NewApplyList {
|
|
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
|
if ps != nil {
|
|
al = append(al, &proto.ResFriendApplyInfo{
|
|
Player: ps,
|
|
Time: int32(v.Time),
|
|
})
|
|
}
|
|
}
|
|
p.PushClientRes(&proto.ResFriendApply{
|
|
ApplyList: al,
|
|
})
|
|
}
|
|
|
|
func (p *Player) FriendLogBackData() {
|
|
FriendMod := p.PlayMod.getFriendMod()
|
|
log := make([]*proto.ResFriendLog, 0, len(FriendMod.Log))
|
|
for _, v := range FriendMod.Log {
|
|
ps := G_GameLogicPtr.GetResSimplePlayerByUid(v.Uid)
|
|
if ps == nil {
|
|
ps = &proto.ResPlayerSimple{
|
|
Uid: int64(v.Uid),
|
|
}
|
|
}
|
|
log = append(log, &proto.ResFriendLog{
|
|
Player: ps,
|
|
Type: int32(v.Type),
|
|
Time: int32(v.Time),
|
|
Param: v.Param,
|
|
Id: int32(v.Id),
|
|
Upvote: v.Upvote,
|
|
})
|
|
}
|
|
reply := make([]*proto.ResFriendReply, 0, len(FriendMod.ReplyList))
|
|
for _, v := range FriendMod.ReplyList {
|
|
ps := G_GameLogicPtr.GetResSimplePlayerByUid(v.Uid)
|
|
if ps == nil {
|
|
ps = &proto.ResPlayerSimple{
|
|
Uid: int64(v.Uid),
|
|
}
|
|
}
|
|
if !FriendMod.CheckFriend(v.Uid) && v.Uid > 10000 {
|
|
continue
|
|
}
|
|
reply = append(reply, &proto.ResFriendReply{
|
|
Player: ps,
|
|
Type: int32(v.Type),
|
|
Param: v.Param,
|
|
Id: int32(v.Id),
|
|
Status: int32(v.Status),
|
|
AddTime: v.AddTime,
|
|
EndTime: v.EndTime,
|
|
})
|
|
}
|
|
p.PushClientRes(&proto.ResFriendTimeLine{
|
|
Log: log,
|
|
Reply: reply,
|
|
})
|
|
}
|
|
|
|
func (p *Player) FriendCardBackData() {
|
|
FriendMod := p.PlayMod.getFriendMod()
|
|
msgList := make([]*proto.ResFriendCard, 0, len(FriendMod.Card))
|
|
for _, v := range FriendMod.Card {
|
|
if !FriendMod.CheckFriend(v.AUid) && v.AUid != int(p.M_DwUin) {
|
|
continue
|
|
}
|
|
if !FriendMod.CheckFriend(v.BUid) && v.BUid != int(p.M_DwUin) {
|
|
continue
|
|
}
|
|
msgList = append(msgList, GetCardInfoMsg(v))
|
|
}
|
|
p.PushClientRes(&proto.ResFriendCardMsg{
|
|
MsgList: msgList,
|
|
})
|
|
}
|