猫草大作战-好友同意优化
This commit is contained in:
parent
745ebaced4
commit
f8363ff994
@ -287,7 +287,7 @@ func (ad *GameLogic) SetUserData(Uid int, Op int, Data interface{}) {
|
||||
}
|
||||
|
||||
func (ad *GameLogic) SetDataSync(Uid int, Op int, Data interface{}) error {
|
||||
_, err := ad.FriendMgr.Call(&MsgMod.Msg{
|
||||
_, err := ad.VarMgr.Call(&MsgMod.Msg{
|
||||
From: Uid,
|
||||
To: Uid,
|
||||
Type: MsgMod.HANDLE_TYPE_VAR_EXPIRE_SET,
|
||||
@ -297,6 +297,21 @@ func (ad *GameLogic) SetDataSync(Uid int, Op int, Data interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (ad *GameLogic) SetCatnipPartner(Uid int, GameId int, PartnerUid int) error {
|
||||
_, err := ad.VarMgr.Call(&MsgMod.Msg{
|
||||
From: Uid,
|
||||
To: Uid,
|
||||
Type: MsgMod.HANDLE_TYPE_SET_CATNIP_PARTNER,
|
||||
SendT: GoUtil.Now(),
|
||||
Extra: map[string]interface{}{
|
||||
"uid": Uid,
|
||||
"game_id": GameId,
|
||||
"partner_uid": PartnerUid,
|
||||
},
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (ad *GameLogic) GetUserData(Uid int) *VarUserData {
|
||||
result, err := ad.FriendMgr.Call(&MsgMod.Msg{
|
||||
From: Uid,
|
||||
|
||||
@ -332,6 +332,8 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
return nil
|
||||
}
|
||||
CatnipMod.BeInvited(CatnipMsg.GameId, int(m.From), m.SendT)
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.AddReplyInfo(m.From, friend.REPLY_TYPE_CATNIP, fmt.Sprintf("%d", CatnipMsg.GameId), m.End)
|
||||
case msg.HANDLE_TYPE_CATNIP_AGREE: // 同意好友参与猫咪游戏
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMsgInfo := m.Extra.(CatnipMsg)
|
||||
@ -379,7 +381,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
case msg.HANDLE_TYPE_FRIEND_GREETING_REPLY:
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
if v, ok := m.Extra.(friend.ReplyInfo); ok {
|
||||
FriendMod.AddReplyInfo(v.Uid, v.Type, v.Param)
|
||||
FriendMod.AddReplyInfo(v.Uid, v.Type, v.Param, GoUtil.Now()+24*3600)
|
||||
FriendLogBackData(p)
|
||||
}
|
||||
case msg.HANDLE_TYPE_FRIEND_SPONSOER:
|
||||
|
||||
@ -1830,7 +1830,7 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
|
||||
}
|
||||
FriendMgrSend(m)
|
||||
FriendMod.AddFriend(Uid)
|
||||
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "")
|
||||
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600)
|
||||
player.PushClientRes(&msg.ResAgreeFriend{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Uid: req.Uid,
|
||||
@ -4684,8 +4684,8 @@ func ReqAddNpc(player *Player, buf []byte) error {
|
||||
player.TeLog("add_npc", map[string]interface{}{
|
||||
"NpcId": int(req.NpcId),
|
||||
})
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING, "")
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING_Get, "")
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600)
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING_Get, "", GoUtil.Now()+24*3600)
|
||||
player.AddLog(int(req.NpcId), friend.LOG_TYPE_FRIEND_BECOME_NPC, GoUtil.String(req.NpcId), GoUtil.Now())
|
||||
player.PushClientRes(&msg.ResAddNpc{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
@ -5004,6 +5004,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error {
|
||||
req := &msg.ReqCatnipInvite{}
|
||||
proto.Unmarshal(buf, req)
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_MINING)
|
||||
ActivityInfo := GetActivityInfo(player, ActivityId)
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
err := CatnipMod.Invite(int(req.Id), int(req.Uid))
|
||||
if err != nil {
|
||||
@ -5020,6 +5021,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error {
|
||||
From: int(player.M_DwUin),
|
||||
To: int(req.Uid),
|
||||
Type: MsqMod.HANDLE_TYPE_CATNIP_INVITE,
|
||||
End: ActivityInfo.EndT,
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: ActivityId,
|
||||
GameId: int(req.Id),
|
||||
@ -5047,6 +5049,14 @@ func ReqCatnipAgree(player *Player, buf []byte) error {
|
||||
})
|
||||
return err
|
||||
}
|
||||
err = G_GameLogicPtr.SetCatnipPartner(int(player.M_DwUin), int(req.Id), int(req.Uid))
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResCatnipAgree{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
player.TeLog("catnip_agree", map[string]interface{}{
|
||||
"Id": int(req.Id),
|
||||
})
|
||||
@ -5073,6 +5083,7 @@ func ReqCatnipAgree(player *Player, buf []byte) error {
|
||||
SendT: GoUtil.Now(),
|
||||
})
|
||||
}
|
||||
player.CatnipBackData()
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipAgree{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
@ -5301,6 +5312,47 @@ func ReqFriendReplyHandle(player *Player, buf []byte) error {
|
||||
SendT: GoUtil.Now(),
|
||||
Extra: ReplyData,
|
||||
})
|
||||
case friend.REPLY_TYPE_CATNIP: // 猫草大作战同意邀请
|
||||
GameId := GoUtil.Int(ReplyInfo.Param)
|
||||
err := G_GameLogicPtr.SetCatnipPartner(int(player.M_DwUin), GameId, ReplyInfo.Uid)
|
||||
if err != nil {
|
||||
player.PushClientRes(&msg.ResFriendReplyHandle{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
} else {
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_MINING)
|
||||
UserList, _ := CatnipMod.Agree(GameId, ReplyInfo.Uid)
|
||||
player.TeLog("catnip_agree", map[string]interface{}{
|
||||
"Id": int(GameId),
|
||||
})
|
||||
FriendMgrSend(&MsqMod.Msg{
|
||||
From: int(player.M_DwUin),
|
||||
To: int(ReplyInfo.Uid),
|
||||
Type: MsqMod.HANDLE_TYPE_CATNIP_AGREE,
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: ActivityId,
|
||||
GameId: int(GameId),
|
||||
},
|
||||
SendT: GoUtil.Now(),
|
||||
})
|
||||
|
||||
for _, v := range UserList {
|
||||
FriendMgrSend(&MsqMod.Msg{
|
||||
From: int(player.M_DwUin),
|
||||
To: int(v),
|
||||
Type: MsqMod.HANDLE_TYPE_CATNIP_AGREE,
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: ActivityId,
|
||||
GameId: int(GameId),
|
||||
},
|
||||
SendT: GoUtil.Now(),
|
||||
})
|
||||
}
|
||||
player.CatnipBackData()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Items := baseCfg.GetFriendReplyReward()
|
||||
|
||||
@ -2,6 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"server/GoUtil"
|
||||
"server/game/mod/card"
|
||||
"server/game/mod/msg"
|
||||
@ -51,6 +52,7 @@ func (f *VarMgr) Init() {
|
||||
f.ZeroUpdate(&msg.Msg{})
|
||||
}
|
||||
f.RegisterHandler(msg.SERVER_ZERO_UPDATE, f.ZeroUpdate)
|
||||
f.RegisterHandler(msg.HANDLE_TYPE_SET_CATNIP_PARTNER, f.SetCatnipPartner)
|
||||
|
||||
f.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
|
||||
f.Send(&msg.Msg{
|
||||
@ -79,6 +81,30 @@ func (f *VarMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (f *VarMgr) SetCatnipPartner(m *msg.Msg) (interface{}, error) {
|
||||
if Param, ok := m.Extra.(map[string]interface{}); ok {
|
||||
MyUid := GoUtil.Int(Param["uid"])
|
||||
CatnipGameId := GoUtil.Int(Param["game_id"])
|
||||
CatnipPartnerId := GoUtil.Int(Param["partner_uid"])
|
||||
myKey := fmt.Sprintf("catnip_partner_%d_%d", MyUid, CatnipGameId)
|
||||
key := fmt.Sprintf("catnip_partner_%d_%d", CatnipPartnerId, CatnipGameId)
|
||||
PartnerInfo := f.GetExpireVar(key)
|
||||
if PartnerInfo.D != nil {
|
||||
return nil, fmt.Errorf("catnip partner already set for uid %d in game %d", CatnipPartnerId, CatnipGameId)
|
||||
}
|
||||
f.SetExpireVar(key, &VarExpireData{
|
||||
D: MyUid,
|
||||
T: m.End,
|
||||
})
|
||||
f.SetExpireVar(myKey, &VarExpireData{
|
||||
D: CatnipPartnerId,
|
||||
T: m.End,
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("invalid parameters for setting catnip partner")
|
||||
}
|
||||
|
||||
func (f *VarMgr) SetVar(key string, value interface{}) {
|
||||
f.getData().Var[key] = value
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ type ApplyInfo struct {
|
||||
const (
|
||||
REPLY_TYPE_GREETING = 1 // 问候
|
||||
REPLY_TYPE_GREETING_Get = 2 // 收到问候
|
||||
REPLY_TYPE_CATNIP = 3 // 猫薄荷
|
||||
)
|
||||
|
||||
// 24小时内与玩家进行过以下互动的用户,若被选中参加本次宠物宝藏,在其头像旁添加礼物盒
|
||||
@ -499,9 +500,9 @@ func (f *FriendMod) GetActLogLast() *ActLogInfo {
|
||||
return f.ActivityLog[len(f.ActivityLog)-1]
|
||||
}
|
||||
|
||||
func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string) {
|
||||
func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64) {
|
||||
f.AutoId++
|
||||
EndTime := GoUtil.Now() + 24*3600
|
||||
|
||||
f.ReplyList = append(f.ReplyList, &ReplyInfo{
|
||||
Id: f.AutoId,
|
||||
Uid: Uid,
|
||||
|
||||
@ -110,7 +110,7 @@ const (
|
||||
|
||||
HANDLE_TYPE_CHAMPSHIP_LOGIN // 锦标赛登录
|
||||
HANDLE_TYPE_CHAMPSHIP_RANK_INFO // 锦标赛排名信息
|
||||
|
||||
HANDLE_TYPE_SET_CATNIP_PARTNER
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user