非好友助战处理
This commit is contained in:
parent
00553c7a41
commit
efcffa27ca
@ -10,7 +10,6 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -145,44 +144,58 @@ func (this *Friend) RpcFriendDB(ctx context.Context, req *pb.RPCGeneralReqA1, re
|
||||
// 使用好友助战英雄
|
||||
// friendId 好友Id
|
||||
func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) {
|
||||
//指定好友
|
||||
friend, _ := this.modelFriend.GetFriend(friendId)
|
||||
|
||||
for _, fId := range friend.FriendIds {
|
||||
// 判断uid是否在指定玩家的好友列表中
|
||||
if fId == uid {
|
||||
//好友没有设置助战英雄
|
||||
if friend.AssistHeroId == "" {
|
||||
break
|
||||
}
|
||||
//遍历助战记录
|
||||
for _, r := range friend.Record {
|
||||
if r.AssistHeroId == friend.AssistHeroId {
|
||||
if utils.IsToday(r.AssistTime) {
|
||||
log.Warn("今日已助战",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "friendId", Value: friend},
|
||||
log.Field{Key: "assistHeroId", Value: r.AssistHeroId},
|
||||
)
|
||||
return nil, errors.New("今日已助战")
|
||||
}
|
||||
}
|
||||
}
|
||||
//更新助战记录和助战分数
|
||||
friend.AssistScore++
|
||||
// 设置助战记录
|
||||
friend.Record = append(friend.Record, &pb.AssistRecord{
|
||||
Uid: uid,
|
||||
AssistHeroId: friend.AssistHeroId,
|
||||
AssistTime: configure.Now().Unix(),
|
||||
})
|
||||
update := map[string]interface{}{
|
||||
"assistScore": friend.AssistScore,
|
||||
"record": friend.Record,
|
||||
}
|
||||
return friend.Hero, this.modelFriend.Change(friendId, update)
|
||||
if friend, err := this.modelFriend.GetFriend(friendId); err == nil {
|
||||
friend.AssistScore++
|
||||
// 设置助战记录
|
||||
friend.Record = append(friend.Record, &pb.AssistRecord{
|
||||
Uid: uid,
|
||||
AssistHeroId: friend.AssistHeroId,
|
||||
AssistTime: configure.Now().Unix(),
|
||||
})
|
||||
update := map[string]interface{}{
|
||||
"assistScore": friend.AssistScore,
|
||||
"record": friend.Record,
|
||||
}
|
||||
err = this.modelFriend.Change(friendId, update)
|
||||
return friend.Hero, err
|
||||
}
|
||||
|
||||
// for _, fId := range friend.FriendIds {
|
||||
// // 判断uid是否在指定玩家的好友列表中
|
||||
// if fId == uid {
|
||||
// //好友没有设置助战英雄
|
||||
// if friend.AssistHeroId == "" {
|
||||
// break
|
||||
// }
|
||||
// //遍历助战记录
|
||||
// for _, r := range friend.Record {
|
||||
// if r.AssistHeroId == friend.AssistHeroId {
|
||||
// if utils.IsToday(r.AssistTime) {
|
||||
// log.Warn("今日已助战",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "friendId", Value: friend},
|
||||
// log.Field{Key: "assistHeroId", Value: r.AssistHeroId},
|
||||
// )
|
||||
// return nil, errors.New("今日已助战")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //更新助战记录和助战分数
|
||||
// friend.AssistScore++
|
||||
// // 设置助战记录
|
||||
// friend.Record = append(friend.Record, &pb.AssistRecord{
|
||||
// Uid: uid,
|
||||
// AssistHeroId: friend.AssistHeroId,
|
||||
// AssistTime: configure.Now().Unix(),
|
||||
// })
|
||||
// update := map[string]interface{}{
|
||||
// "assistScore": friend.AssistScore,
|
||||
// "record": friend.Record,
|
||||
// }
|
||||
// return friend.Hero, this.modelFriend.Change(friendId, update)
|
||||
// }
|
||||
// }
|
||||
log.Errorf("[friendId:%v]不是你[uid:%v]的好友", uid, friendId)
|
||||
return nil, errors.New("非好友")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user