好友功能优化
This commit is contained in:
parent
4422dbc527
commit
e892469ff9
@ -67,7 +67,7 @@ func (p *Player) handle(m *msg.Msg) error {
|
|||||||
if ok {
|
if ok {
|
||||||
addType = GoUtil.Int(info["type"])
|
addType = GoUtil.Int(info["type"])
|
||||||
}
|
}
|
||||||
ok = FriendMod.AddFriendApply(m.From, addType)
|
ok = FriendMod.AddFriendApply(m.From, addType, m.SendT)
|
||||||
// 已申请
|
// 已申请
|
||||||
if ok {
|
if ok {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -67,6 +67,7 @@ type FriendInfo struct {
|
|||||||
AddTime int64
|
AddTime int64
|
||||||
DelTime int64
|
DelTime int64
|
||||||
Interact []*Interact // 拜访记录
|
Interact []*Interact // 拜访记录
|
||||||
|
Greeting bool // 是否打过招呼
|
||||||
}
|
}
|
||||||
|
|
||||||
type Interact struct {
|
type Interact struct {
|
||||||
@ -356,6 +357,12 @@ func (f *FriendMod) DelCardInfo(Id string) {
|
|||||||
// 删除好友
|
// 删除好友
|
||||||
func (f *FriendMod) DelFriend(id int) {
|
func (f *FriendMod) DelFriend(id int) {
|
||||||
f.NewFriendList[id].DelTime = GoUtil.Now()
|
f.NewFriendList[id].DelTime = GoUtil.Now()
|
||||||
|
// 删除好友后清除打招呼
|
||||||
|
for _, v := range f.ReplyList {
|
||||||
|
if v.Uid == id && (v.Type == REPLY_TYPE_GREETING || v.Type == REPLY_TYPE_GREETING_Get) {
|
||||||
|
v.Status = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否好友
|
// 检查是否好友
|
||||||
@ -420,7 +427,7 @@ func (f *FriendMod) CheckAddBefore(uid int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 收到申请
|
// 收到申请
|
||||||
func (f *FriendMod) AddFriendApply(Uid, Type int) bool {
|
func (f *FriendMod) AddFriendApply(Uid, Type int, sendTime int64) bool {
|
||||||
if f.DailyGetApply >= friendCfg.GetDailyGetApplyLimit() {
|
if f.DailyGetApply >= friendCfg.GetDailyGetApplyLimit() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -450,7 +457,7 @@ func (f *FriendMod) AddFriendApply(Uid, Type int) bool {
|
|||||||
}
|
}
|
||||||
f.NewApplyList[Uid] = &ApplyInfo{
|
f.NewApplyList[Uid] = &ApplyInfo{
|
||||||
Type: Type,
|
Type: Type,
|
||||||
Time: GoUtil.Now(),
|
Time: sendTime,
|
||||||
}
|
}
|
||||||
f.DailyGetApply++
|
f.DailyGetApply++
|
||||||
return false
|
return false
|
||||||
@ -635,7 +642,7 @@ func (f *FriendMod) GetActLogLast() *ActLogInfo {
|
|||||||
// 增加待回复请求
|
// 增加待回复请求
|
||||||
func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64, Items []*item.Item) *ReplyInfo {
|
func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64, Items []*item.Item) *ReplyInfo {
|
||||||
f.AutoId++
|
f.AutoId++
|
||||||
ReplyInfo := &ReplyInfo{
|
Reply := &ReplyInfo{
|
||||||
Id: f.AutoId,
|
Id: f.AutoId,
|
||||||
Uid: Uid,
|
Uid: Uid,
|
||||||
Type: Type,
|
Type: Type,
|
||||||
@ -644,8 +651,11 @@ func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64,
|
|||||||
EndTime: EndTime,
|
EndTime: EndTime,
|
||||||
Items: Items,
|
Items: Items,
|
||||||
}
|
}
|
||||||
f.ReplyList = append(f.ReplyList, ReplyInfo)
|
f.ReplyList = append(f.ReplyList, Reply)
|
||||||
return ReplyInfo
|
if len(f.ReplyList) > 20 {
|
||||||
|
f.ReplyList = f.ReplyList[len(f.ReplyList)-20:]
|
||||||
|
}
|
||||||
|
return Reply
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回复请求
|
// 回复请求
|
||||||
@ -715,3 +725,16 @@ func (f *FriendMod) AddDailyRecommend() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FriendMod) GreetingFriend(Uid int) {
|
||||||
|
if v, ok := f.NewFriendList[Uid]; ok {
|
||||||
|
v.Greeting = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FriendMod) CheckGreeting(Uid int) bool {
|
||||||
|
if v, ok := f.NewFriendList[Uid]; ok {
|
||||||
|
return v.Greeting
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@ -218,7 +218,7 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
|
|||||||
return fmt.Errorf("friend list full")
|
return fmt.Errorf("friend list full")
|
||||||
}
|
}
|
||||||
// 新好友才可以打招呼
|
// 新好友才可以打招呼
|
||||||
if !FriendMod.CheckAddBefore(Uid) {
|
if !FriendMod.CheckGreeting(Uid) {
|
||||||
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+oneday, nil)
|
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+oneday, nil)
|
||||||
}
|
}
|
||||||
FriendMod.AddFriend(Uid)
|
FriendMod.AddFriend(Uid)
|
||||||
@ -433,6 +433,7 @@ func ReqFriendReplyHandle(player *Player, buf []byte) error {
|
|||||||
End: now + sevendays,
|
End: now + sevendays,
|
||||||
Extra: ReplyData,
|
Extra: ReplyData,
|
||||||
})
|
})
|
||||||
|
FriendMod.GreetingFriend(int(ReplyInfo.Uid))
|
||||||
case friend.REPLY_TYPE_CATNIP: // 猫草大作战同意邀请
|
case friend.REPLY_TYPE_CATNIP: // 猫草大作战同意邀请
|
||||||
GameId := GoUtil.Int(ReplyInfo.Param)
|
GameId := GoUtil.Int(ReplyInfo.Param)
|
||||||
activityInfo := player.GetActivityInfo(player.GetActivityId(activity.ACT_TYPE_CATNIP))
|
activityInfo := player.GetActivityInfo(player.GetActivityId(activity.ACT_TYPE_CATNIP))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user