From aa253f24ecef4fa7b54bdc7352b69b0fcfc0d746 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Mon, 18 Jul 2022 15:02:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=AF=E5=90=A6=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/task.go | 10 ++++++++-- modules/hero/model_hero.go | 25 ++++++++++++------------ modules/task/api_activelist.go | 1 + modules/user/api_login.go | 10 ++++------ pb/proto/task/task_msg.proto | 5 ++++- pb/task_msg.pb.go | 35 +++++++++++++++++++++------------- 6 files changed, 51 insertions(+), 35 deletions(-) diff --git a/cmd/robot/task.go b/cmd/robot/task.go index 59976fe8d..088ce88b9 100644 --- a/cmd/robot/task.go +++ b/cmd/robot/task.go @@ -28,7 +28,7 @@ var ( fmt.Printf("%v \n", v) } }, - enabled: true, + // enabled: true, next: func(robot *Robot, rsp proto.Message) { tcs := []*TestCase{} if v, ok := rsp.(*pb.TaskListResp); ok { @@ -57,7 +57,13 @@ var ( TaskTag: int32(comm.TASK_DAILY), }, rsp: &pb.TaskActiveListResp{}, - // enabled: true, + print: func(rsp proto.Message) { + out := rsp.(*pb.TaskActiveListResp) + for _, v := range out.List { + fmt.Printf("%v 活跃值:%v\n", v, out.Active) + } + }, + enabled: true, }, { desc: "活跃度领取", mainType: string(comm.ModuleTask), diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index be2a36a21..92a012123 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -129,12 +129,9 @@ func (this *ModelHero) createMultiHero(uid string, bPush bool, heroCfgIds ...int if len(heroes) == 0 { for _, v := range heroCfgIds { - if err := this.createOneHero(uid, v, bPush); err != nil { - return err - } + return this.createOneHero(uid, v, bPush) } } else { - findHero := func(heroId int32) (*pb.DBHero, bool) { for _, h := range heroes { if h.HeroID == heroId { @@ -145,17 +142,19 @@ func (this *ModelHero) createMultiHero(uid string, bPush bool, heroCfgIds ...int } for _, v := range heroCfgIds { if h, ok := findHero(v); ok { - h.SameCount++ - data := map[string]interface{}{ - "sameCount": h.SameCount, //叠加数 - } - if err := this.modifyHeroData(uid, h.Id, data); err != nil { - return err + //允许叠加 + if h.IsOverlying { + h.SameCount++ + data := map[string]interface{}{ + "sameCount": h.SameCount, //叠加数 + } + return this.modifyHeroData(uid, h.Id, data) + } else { + return this.createOneHero(uid, v, bPush) } + } else { - if err := this.createOneHero(uid, v, bPush); err != nil { - return err - } + return this.createOneHero(uid, v, bPush) } } } diff --git a/modules/task/api_activelist.go b/modules/task/api_activelist.go index ea48c2d62..417253257 100644 --- a/modules/task/api_activelist.go +++ b/modules/task/api_activelist.go @@ -31,6 +31,7 @@ func (this *apiComp) ActiveList(session comm.IUserSession, req *pb.TaskActiveLis utils.TraceFunc(session.GetUserId(), string(this.moduleTask.GetType()), TaskSubTypeActiveList, req, resp) }() + resp.Active = this.moduleTask.modelTask.countActive(session.GetUserId(), comm.TaskTag(req.TaskTag)) //遍历活跃度奖励表 resp.List = this.moduleTask.modelTaskActive.getUserActiveList(session.GetUserId(), comm.TaskTag(req.TaskTag)) diff --git a/modules/user/api_login.go b/modules/user/api_login.go index b20becc60..bb2b07b05 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -90,14 +90,12 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod return } + //不是新账号 if !isNewUser { //set user other info - update := map[string]interface{}{ - "logintime": time.Now().Unix(), - "lastloginip": session.GetIP(), - } - - //缓存user + user.Logintime = time.Now().Unix() + user.Lastloginip = session.GetIP() + update := utils.StructToMap(user) err = this.module.modelUser.Change(user.Uid, update) if err != nil { code = pb.ErrorCode_DBError diff --git a/pb/proto/task/task_msg.proto b/pb/proto/task/task_msg.proto index 89c028280..576e8907a 100644 --- a/pb/proto/task/task_msg.proto +++ b/pb/proto/task/task_msg.proto @@ -21,7 +21,10 @@ message TaskListResp { repeated DBTask list = 1; } //活跃度 message TaskActiveListReq { int32 taskTag = 1; } -message TaskActiveListResp { repeated DBTaskActive list = 1; } +message TaskActiveListResp { + repeated DBTaskActive list = 1; //活跃度列表 + int32 active = 2; //活跃度值 +} //活跃度领取 message TaskActiveReceiveReq { diff --git a/pb/task_msg.pb.go b/pb/task_msg.pb.go index 878ca2750..2ecc72a1e 100644 --- a/pb/task_msg.pb.go +++ b/pb/task_msg.pb.go @@ -271,7 +271,8 @@ type TaskActiveListResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - List []*DBTaskActive `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` + List []*DBTaskActive `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` //活跃度列表 + Active int32 `protobuf:"varint,2,opt,name=active,proto3" json:"active"` //活跃度值 } func (x *TaskActiveListResp) Reset() { @@ -313,6 +314,13 @@ func (x *TaskActiveListResp) GetList() []*DBTaskActive { return nil } +func (x *TaskActiveListResp) GetActive() int32 { + if x != nil { + return x.Active + } + return 0 +} + //活跃度领取 type TaskActiveReceiveReq struct { state protoimpl.MessageState @@ -444,20 +452,21 @@ var file_task_task_msg_proto_rawDesc = []byte{ 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2d, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, - 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x37, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, + 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x4f, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x54, 0x61, - 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x40, - 0x0a, 0x14, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, - 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, - 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x22, 0x41, 0x0a, 0x15, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, - 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, - 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, - 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, + 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x40, 0x0a, 0x14, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, + 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x41, 0x0a, 0x15, 0x54, 0x61, 0x73, 0x6b, + 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (