宠物宝藏优化
This commit is contained in:
parent
02b7884357
commit
0c56cbd224
@ -75,6 +75,7 @@ func (f *FriendMgr) Init() {
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_TREASURE_RESULT, f.sendToPlayer)
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_FACEBOOK_UNBIND, f.sendToPlayer)
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_PLAYROOM_KISS, f.sendToPlayerOnline)
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_PLAYROOM_GAME, f.sendToPlayerOnline)
|
||||
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_VAR_USER_GET, f.GetVarUserData)
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_VAR_USER_SET, f.SetVarUserData)
|
||||
|
||||
@ -83,6 +83,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
CardInfo := m.Extra.(card.CardInfo)
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.SetCardInfo(&CardInfo)
|
||||
FriendMod.Interact(CardInfo.AUid, friend.INTERACT_TYPE_CARD, m.SendT)
|
||||
p.PushClientRes(
|
||||
&proto.NotifyFriendCard{
|
||||
Info: GetCardInfoMsg(&CardInfo),
|
||||
@ -149,6 +150,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
CardInfo := m.Extra.(card.CardInfo)
|
||||
FriendMod.SetCardInfo(&CardInfo)
|
||||
FriendMod.Interact(CardInfo.AUid, friend.INTERACT_TYPE_EX, m.SendT)
|
||||
p.PlayMod.save()
|
||||
p.PushClientRes(
|
||||
&proto.NotifyFriendCard{
|
||||
@ -227,9 +229,14 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
} else {
|
||||
PlayroomMod.Lose(Items)
|
||||
}
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.Interact(m.From, friend.INTERACT_TYPE_VISIT, m.SendT)
|
||||
p.UpdateUserInfo()
|
||||
p.Kafka(PLAYROOM_LOST, map[string]interface{}{"uid": m.From, "item": Items})
|
||||
p.PushClientRes(PlayroomMod.NotifyLose())
|
||||
case msg.HANDLE_TYPE_PLAYROOM_GAME:
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.Interact(m.From, friend.INTERACT_TYPE_VISIT, m.SendT)
|
||||
case msg.FRIEND_TREASURE_HANDLE: // # 好友宝藏
|
||||
Items := make([]*item.Item, 0)
|
||||
if m.Extra != nil {
|
||||
@ -240,6 +247,8 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
data := m.Extra.(msg.HandbookMsg)
|
||||
p.AddLog(m.From, friend.LOG_TYPE_HANDBOOK, data.Type)
|
||||
case msg.HANDLE_TYPE_HANDBOOK_UPVOTE: // 图鉴点赞
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.Interact(m.From, friend.INTERACT_TYPE_UPVOTE, m.SendT)
|
||||
p.AddLog(m.From, friend.LOG_TYPE_HANDBOOK_UPVOTE, "")
|
||||
case msg.HANDLE_TYPE_SEND_CHARGE: // 收到好友赠送的充值礼包
|
||||
C := &ChargeExtra{}
|
||||
@ -271,6 +280,8 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
p.AddLog(m.From, friend.LOG_TYPE_PLAYROOM_UPVOTE, "")
|
||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.AddUpvote()
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.Interact(m.From, friend.INTERACT_TYPE_VISIT, m.SendT)
|
||||
p.UpdateUserInfo()
|
||||
case msg.HANDLE_TYPE_WISHLIST_AGREE:
|
||||
ChargeMod := p.PlayMod.getChargeMod()
|
||||
@ -408,6 +419,7 @@ func FriendListBackData(p *Player) {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
||||
if ps != nil {
|
||||
ps.AddTime = v.AddTime
|
||||
ps.Interact = FriendMod.GetInteractTime(k)
|
||||
fl = append(fl, ps)
|
||||
}
|
||||
}
|
||||
|
||||
@ -3250,9 +3250,13 @@ func ReqPlayroomGame(player *Player, buf []byte) error {
|
||||
})
|
||||
return err
|
||||
}
|
||||
G_GameLogicPtr.FriendMgrSend(&MsqMod.Msg{
|
||||
From: int(player.M_DwUin),
|
||||
To: Target,
|
||||
Type: MsqMod.HANDLE_TYPE_PLAYROOM_GAME,
|
||||
SendT: GoUtil.Now(),
|
||||
})
|
||||
player.PlayMod.save()
|
||||
// PlayroomBackData(player)
|
||||
// PlayroomVisit(player, PlayroomMod.GetTarget())
|
||||
ItemsMsg := make(map[int32]*msg.ItemInfo, 0)
|
||||
for k, v := range PlayroomMod.GameReward {
|
||||
ItemsMsg[int32(k)] = &msg.ItemInfo{
|
||||
|
||||
@ -22,7 +22,13 @@ type FriendMod struct {
|
||||
}
|
||||
|
||||
type FriendInfo struct {
|
||||
AddTime int64
|
||||
AddTime int64
|
||||
Interact []*Interact // 拜访记录
|
||||
}
|
||||
|
||||
type Interact struct {
|
||||
VisitTime int64 // 拜访时间
|
||||
Type int // 1:拜访 2:点赞
|
||||
}
|
||||
|
||||
type ApplyInfo struct {
|
||||
@ -31,6 +37,15 @@ type ApplyInfo struct {
|
||||
Uid int64
|
||||
}
|
||||
|
||||
// 24小时内与玩家进行过以下互动的用户,若被选中参加本次宠物宝藏,在其头像旁添加礼物盒
|
||||
const (
|
||||
INTERACT_TYPE_VISIT = 1 // 拜访过玩家的Pet Playroom并进行过小游戏或点赞的用户
|
||||
INTERACT_TYPE_UPVOTE = 2 // 为玩家的图鉴全收集信息点过赞的用户
|
||||
INTERACT_TYPE_CARD = 3 // 向玩家赠送过卡牌的用户
|
||||
INTERACT_TYPE_EX = 4 // 向玩家发起过卡牌交换
|
||||
INTERACT_TYPE_WISH = 5 // 邀请玩家一同参加活动的用户
|
||||
)
|
||||
|
||||
const (
|
||||
LOG_TYPE_FRIEND_APPLY = 1 // 收到申请好友
|
||||
LOG_TYPE_FRIEND_BECOME = 2 // 成为好友
|
||||
@ -117,6 +132,36 @@ func (f *FriendMod) SetSyncId(Id int64) {
|
||||
f.Id = Id
|
||||
}
|
||||
|
||||
func (f *FriendMod) Interact(id, t int, T int64) {
|
||||
if _, ok := f.NewFriendList[id]; !ok {
|
||||
return
|
||||
}
|
||||
for _, v := range f.NewFriendList[id].Interact {
|
||||
if v.Type == t && v.VisitTime < T {
|
||||
v.VisitTime = T
|
||||
return
|
||||
}
|
||||
}
|
||||
f.NewFriendList[id].Interact = append(f.NewFriendList[id].Interact, &Interact{
|
||||
VisitTime: T,
|
||||
Type: t,
|
||||
})
|
||||
}
|
||||
|
||||
func (f *FriendMod) GetInteractTime(id int) int64 {
|
||||
if _, ok := f.NewFriendList[id]; !ok {
|
||||
return 0
|
||||
}
|
||||
LastTime := int64(0)
|
||||
// 获取最近一次拜访或点赞的时间
|
||||
for _, v := range f.NewFriendList[id].Interact {
|
||||
if v.VisitTime > LastTime {
|
||||
LastTime = v.VisitTime
|
||||
}
|
||||
}
|
||||
return LastTime
|
||||
}
|
||||
|
||||
func (f *FriendMod) AddFriend(id int) {
|
||||
f.NewFriendList[id] = &FriendInfo{
|
||||
AddTime: GoUtil.Now(),
|
||||
|
||||
@ -92,6 +92,7 @@ const (
|
||||
HANDLE_TYPE_VAR_USER_GET // 获取玩家数据
|
||||
|
||||
HANDLE_TYPE_PLAYROOM_KISS // playroom亲吻
|
||||
HANDLE_TYPE_PLAYROOM_GAME // playroom游戏
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@ -12149,6 +12149,7 @@ type ResPlayerSimple struct {
|
||||
Facebook string `protobuf:"bytes,9,opt,name=Facebook,proto3" json:"Facebook,omitempty"`
|
||||
Emoji map[int32]int32 `protobuf:"bytes,10,rep,name=Emoji,proto3" json:"Emoji,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` // 表情
|
||||
AddTime int64 `protobuf:"varint,11,opt,name=AddTime,proto3" json:"AddTime,omitempty"` // 添加时间
|
||||
Interact int64 `protobuf:"varint,12,opt,name=Interact,proto3" json:"Interact,omitempty"` // 最后一次互动的时间
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -12260,6 +12261,13 @@ func (x *ResPlayerSimple) GetAddTime() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ResPlayerSimple) GetInteract() int64 {
|
||||
if x != nil {
|
||||
return x.Interact
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ResPlayerRank struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Uid int64 `protobuf:"varint,1,opt,name=Uid,proto3" json:"Uid,omitempty"`
|
||||
@ -24222,7 +24230,7 @@ const file_proto_Gameapi_proto_rawDesc = "" +
|
||||
"\x03Uid\x18\x01 \x01(\tR\x03Uid\"T\n" +
|
||||
"\x0fResSearchPlayer\x12\x12\n" +
|
||||
"\x04Code\x18\x01 \x01(\x05R\x04Code\x12-\n" +
|
||||
"\x04List\x18\x02 \x03(\v2\x19.tutorial.ResPlayerSimpleR\x04List\"\xf3\x02\n" +
|
||||
"\x04List\x18\x02 \x03(\v2\x19.tutorial.ResPlayerSimpleR\x04List\"\x8f\x03\n" +
|
||||
"\x0fResPlayerSimple\x12\x10\n" +
|
||||
"\x03Uid\x18\x01 \x01(\x03R\x03Uid\x12\x12\n" +
|
||||
"\x04Name\x18\x02 \x01(\tR\x04Name\x12\x12\n" +
|
||||
@ -24235,7 +24243,8 @@ const file_proto_Gameapi_proto_rawDesc = "" +
|
||||
"\bFacebook\x18\t \x01(\tR\bFacebook\x12:\n" +
|
||||
"\x05Emoji\x18\n" +
|
||||
" \x03(\v2$.tutorial.ResPlayerSimple.EmojiEntryR\x05Emoji\x12\x18\n" +
|
||||
"\aAddTime\x18\v \x01(\x03R\aAddTime\x1a8\n" +
|
||||
"\aAddTime\x18\v \x01(\x03R\aAddTime\x12\x1a\n" +
|
||||
"\bInteract\x18\f \x01(\x03R\bInteract\x1a8\n" +
|
||||
"\n" +
|
||||
"EmojiEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\x05R\x03key\x12\x14\n" +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user