From 121dc36216ee64fe2192b80b911365642a13c099 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 19 Dec 2022 16:41:53 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=B0=E4=BD=9C?= =?UTF-8?q?=E5=9B=BE=E5=8D=87=E7=BA=A7=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/horoscope/configure.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/horoscope/configure.go b/modules/horoscope/configure.go index 07d24e141..f30c0eaf8 100644 --- a/modules/horoscope/configure.go +++ b/modules/horoscope/configure.go @@ -45,7 +45,7 @@ func (this *configureComp) getHoroscope(id int32) (result *cfg.GameHoroscopeData } //查询星座信息 -func (this *configureComp) getHoroscopebylv(grow, lv int32) (result *cfg.GameHoroscopeData, err error) { +func (this *configureComp) getHoroscopebylv(nodeid, lv int32) (result *cfg.GameHoroscopeData, err error) { var ( v interface{} ) @@ -53,13 +53,13 @@ func (this *configureComp) getHoroscopebylv(grow, lv int32) (result *cfg.GameHor this.module.Errorln(err) } else { for _, v := range v.(*cfg.GameHoroscope).GetDataMap() { - if v.GrowType == grow && v.Lv == lv { + if v.NodeId == nodeid && v.Lv == lv { result = v return } } } - err = fmt.Errorf("No found Horoscope grow:%d lv:%d", grow, lv) + err = fmt.Errorf("No found Horoscope nodeid:%d lv:%d", nodeid, lv) return } From bb8b26dd992ccab2fe572b5f667c3bdd6db57d69 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 19 Dec 2022 16:54:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/configure/structs/Game.CombatLevelData.go | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/sys/configure/structs/Game.CombatLevelData.go b/sys/configure/structs/Game.CombatLevelData.go index a69c3e9e0..20a1c1c48 100644 --- a/sys/configure/structs/Game.CombatLevelData.go +++ b/sys/configure/structs/Game.CombatLevelData.go @@ -14,8 +14,6 @@ type GameCombatLevelData struct { Id int32 Scene string Levelname string - FormatList []int32 - Droplist []int32 PassformatList []int32 Passdroplist []int32 Award []*Gameatn @@ -33,34 +31,6 @@ func (_v *GameCombatLevelData)Deserialize(_buf map[string]interface{}) (err erro { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } { var _ok_ bool; if _v.Scene, _ok_ = _buf["scene"].(string); !_ok_ { err = errors.New("scene error"); return } } { var _ok_ bool; if _v.Levelname, _ok_ = _buf["levelname"].(string); !_ok_ { err = errors.New("levelname error"); return } } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["formatList"].([]interface{}); !_ok_ { err = errors.New("formatList error"); return } - - _v.FormatList = make([]int32, 0, len(_arr_)) - - for _, _e_ := range _arr_ { - var _list_v_ int32 - { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } - _v.FormatList = append(_v.FormatList, _list_v_) - } - } - - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["droplist"].([]interface{}); !_ok_ { err = errors.New("droplist error"); return } - - _v.Droplist = make([]int32, 0, len(_arr_)) - - for _, _e_ := range _arr_ { - var _list_v_ int32 - { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } - _v.Droplist = append(_v.Droplist, _list_v_) - } - } - { var _arr_ []interface{} var _ok_ bool From e0c9a544d3fede41ee5c6078c99d51005c0133ee Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 19 Dec 2022 17:43:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=B8=96=E7=95=8C?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A5=96=E5=8A=B1=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worldtask/api_finish.go | 24 ++++++++- pb/worldtask_msg.pb.go | 93 ++++++++++++++++++++------------- 2 files changed, 78 insertions(+), 39 deletions(-) diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 8be3636cc..02a02e8ef 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -36,7 +36,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe code = pb.ErrorCode_UserSessionNobeing return } - + rsp.Olv = user.Lv // 当前任务配置 curTaskConf, err := this.module.configure.getWorldtaskById(req.TaskId) if err != nil || curTaskConf == nil { @@ -73,7 +73,12 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe return } } - + var ( + hero []string + newhero []string + ) + hero = make([]string, 0) + newhero = make([]string, 0) var nextTaskId int32 nextTaskId = curTaskConf.IdAfter finishRsp := func() { @@ -114,6 +119,21 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe ) return } + + for _, v := range curTaskConf.Reword { + if v.A == comm.HeroType { + hero = append(hero, v.T) + } + } + if len(hero) > 0 { + ishave := this.module.ModuleUser.CheckTujianHero(session, hero) + for i, v := range ishave { + if v { + newhero = append(newhero, hero[i]) + } + } + } + rsp.Newheros = newhero // 发奖 if code = this.module.DispenseRes(session, curTaskConf.Reword, true); code != pb.ErrorCode_Success { this.module.Error("资源发放", diff --git a/pb/worldtask_msg.pb.go b/pb/worldtask_msg.pb.go index 8cd966591..26541ec2f 100644 --- a/pb/worldtask_msg.pb.go +++ b/pb/worldtask_msg.pb.go @@ -167,8 +167,10 @@ type WorldtaskFinishResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GroupId int32 `protobuf:"varint,1,opt,name=groupId,proto3" json:"groupId"` - TaskId int32 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId"` + GroupId int32 `protobuf:"varint,1,opt,name=groupId,proto3" json:"groupId"` + TaskId int32 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId"` + Newheros []string `protobuf:"bytes,3,rep,name=newheros,proto3" json:"newheros"` //获得的新英雄 + Olv int32 `protobuf:"varint,4,opt,name=olv,proto3" json:"olv"` //以前的等级 } func (x *WorldtaskFinishResp) Reset() { @@ -217,6 +219,20 @@ func (x *WorldtaskFinishResp) GetTaskId() int32 { return 0 } +func (x *WorldtaskFinishResp) GetNewheros() []string { + if x != nil { + return x.Newheros + } + return nil +} + +func (x *WorldtaskFinishResp) GetOlv() int32 { + if x != nil { + return x.Olv + } + return 0 +} + //任务完成条件达成的推送 type WorldtaskNexttaskPush struct { state protoimpl.MessageState @@ -560,45 +576,48 @@ var file_worldtask_worldtask_msg_proto_rawDesc = []byte{ 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x13, 0x57, 0x6f, 0x72, + 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x75, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, - 0x49, 0x64, 0x22, 0x37, 0x0a, 0x15, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4e, - 0x65, 0x78, 0x74, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, - 0x65, 0x78, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x67, 0x0a, 0x17, 0x57, - 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, - 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, - 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x61, - 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x06, 0x62, 0x61, - 0x74, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, - 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x62, 0x61, - 0x74, 0x74, 0x6c, 0x65, 0x22, 0x3b, 0x0a, 0x18, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, - 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, - 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, - 0x6f, 0x22, 0x7d, 0x0a, 0x18, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, - 0x74, 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, - 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, - 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, - 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x61, 0x74, - 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x74, 0x74, - 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x22, 0x61, 0x0a, 0x19, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, - 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, - 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, - 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, - 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x6f, 0x6c, 0x76, 0x22, 0x40, 0x0a, 0x16, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, - 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x49, 0x64, 0x73, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, - 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0a, 0x2e, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x08, 0x74, 0x61, 0x73, - 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x12, 0x10, + 0x0a, 0x03, 0x6f, 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, 0x6c, 0x76, + 0x22, 0x37, 0x0a, 0x15, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4e, 0x65, 0x78, + 0x74, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x65, 0x78, + 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6e, + 0x65, 0x78, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x67, 0x0a, 0x17, 0x57, 0x6f, 0x72, + 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x61, 0x74, 0x74, + 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x06, 0x62, 0x61, 0x74, 0x74, + 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x62, 0x61, 0x74, 0x74, + 0x6c, 0x65, 0x22, 0x3b, 0x0a, 0x18, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, + 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, + 0x7d, 0x0a, 0x18, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, + 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, + 0x6b, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, + 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x61, + 0x0a, 0x19, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, + 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x12, + 0x10, 0x0a, 0x03, 0x6f, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, 0x6c, + 0x76, 0x22, 0x40, 0x0a, 0x16, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, + 0x6e, 0x69, 0x73, 0x68, 0x49, 0x64, 0x73, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x08, 0x74, + 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, + 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, + 0x69, 0x73, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( From 178a325df95b700894552a5760be652661bd7d5a Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 19 Dec 2022 21:00:26 +0800 Subject: [PATCH 4/4] update --- modules/rtask/updateHandle.go | 4 +- modules/task/api_activereceive.go | 65 +++++++++++++++---------------- modules/task/api_receive.go | 19 +++++++-- modules/task/model_active.go | 10 +++++ modules/task/model_task.go | 12 ++++-- 5 files changed, 69 insertions(+), 41 deletions(-) diff --git a/modules/rtask/updateHandle.go b/modules/rtask/updateHandle.go index 96c9c46dd..97f89f82b 100644 --- a/modules/rtask/updateHandle.go +++ b/modules/rtask/updateHandle.go @@ -64,7 +64,7 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond } } log.Debug("覆盖数值更新", log.Fields{"uid": uid, "condiId": cfg.Id, "params": vals, "updated": record.Vals[cfg.Id]}) - this.listenTask(uid, cfg.Id) + // this.listenTask(uid, cfg.Id) return } @@ -112,7 +112,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData } log.Debug("累计次数更新", log.Fields{"uid": uid, "condiId": cfg.Id, "params": vals, "updated": record.Vals[cfg.Id]}) - this.listenTask(uid, cfg.Id) + // this.listenTask(uid, cfg.Id) return } diff --git a/modules/task/api_activereceive.go b/modules/task/api_activereceive.go index b002b5e93..f21f61f36 100644 --- a/modules/task/api_activereceive.go +++ b/modules/task/api_activereceive.go @@ -36,49 +36,48 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive return } var rewards []*cfg.Gameatn + var flag bool + update := map[string]interface{}{} // 玩家的 - activeList := this.moduleTask.modelTaskActive.getActiveListByTag(uid, comm.TaskTag(req.TaskTag)) - var activityData *pb.ActivityData + activeList := this.moduleTask.modelTaskActive.getActiveList(uid) + // var activityData *pb.ActivityData for _, v := range activeList { if v.TaskId == req.Id { - activityData = v + if v.Received != 1 { + conf := this.moduleTask.configure.getTaskActiveById(v.TaskId) + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + if req.TaskTag == int32(comm.TASK_DAILY) { + if ue.Activeday < conf.Active { + code = pb.ErrorCode_TaskActiveNoenough + return + } + } else if req.TaskTag == int32(comm.TASK_WEEKLY) { + if ue.Activeweek < conf.Active { + code = pb.ErrorCode_TaskActiveNoenough + return + } + } + + v.Received = 1 + flag = true + rewards = append(rewards, conf.Reword...) + } break } } - if activityData == nil { - code = pb.ErrorCode_TaskNotFound - return - } + if flag { + update["activityList"] = activeList - if activityData.Received != 1 { //未领取 - conf := this.moduleTask.configure.getTaskActiveById(activityData.TaskId) - if conf == nil { - code = pb.ErrorCode_ConfigNoFound + if err := this.moduleTask.modelTaskActive.Change(session.GetUserId(), update); err != nil { + this.moduleTask.Errorf("updateReceive err %v", err) + code = pb.ErrorCode_DBError return } - - update := make(map[string]interface{}) - if req.TaskTag == int32(comm.TASK_DAILY) { - if ue.Activeday < conf.Active { - code = pb.ErrorCode_TaskActiveNoenough - return - } - } else if req.TaskTag == int32(comm.TASK_WEEKLY) { - if ue.Activeweek < conf.Active { - code = pb.ErrorCode_TaskActiveNoenough - return - } - } - update["received"] = 1 - if len(update) > 0 { - if err := this.moduleTask.modelTaskActive.updateReceive(session.GetUserId(), update); err != nil { - this.moduleTask.Errorf("updateReceive err %v", err) - code = pb.ErrorCode_DBError - return - } - } - rewards = append(rewards, conf.Reword...) } if len(rewards) > 0 { diff --git a/modules/task/api_receive.go b/modules/task/api_receive.go index 15e681099..b62120ddb 100644 --- a/modules/task/api_receive.go +++ b/modules/task/api_receive.go @@ -104,10 +104,23 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) } //更新用户领取状态 - update := map[string]interface{}{ - "received": 1, + for _, v := range taskDataList { + if v.TaskId == req.Id { + v.Received = 1 + break + } } - if err := this.moduleTask.modelTask.modifyUserTask(session.GetUserId(), taskData.TaskId, update); err != nil { + update := map[string]interface{}{} + switch req.TaskTag { + case int32(comm.TASK_DAILY): + update["dayList"] = taskDataList + case int32(comm.TASK_WEEKLY): + update["weekList"] = taskDataList + case int32(comm.TASK_ACHIEVE): + update["achieveList"] = taskDataList + } + + if err := this.moduleTask.modelTask.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_DBError return } diff --git a/modules/task/model_active.go b/modules/task/model_active.go index 9fb0f1dea..2b11bb3fe 100644 --- a/modules/task/model_active.go +++ b/modules/task/model_active.go @@ -62,6 +62,16 @@ func (this *ModelTaskActive) initActiveReward(uid string, taskTag comm.TaskTag) } } +func (this *ModelTaskActive) getActiveList(uid string) (list []*pb.ActivityData) { + task := &pb.DBActivity{} + if err := this.Get(uid, task); err != nil { + this.moduleTask.Errorf("getTaskList err %v", err) + return + } + + return task.ActivityList +} + //获取玩家活跃度列表 func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag) (list []*pb.ActivityData) { task := &pb.DBActivity{} diff --git a/modules/task/model_task.go b/modules/task/model_task.go index 3b0e212d8..fab1a51e7 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -82,6 +82,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB return nil } + update := map[string]interface{}{} var dataList []*pb.TaskData if taskTag == comm.TASK_DAILY { dataList = task.DayList @@ -90,7 +91,6 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB } // 筛选出指定tag的任务 - update := map[string]interface{}{} var flag bool for _, v := range dataList { oldVal := v.Progress @@ -112,8 +112,13 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB } } if flag { - update["dayList"] = task.DayList - if err := this.moduleTask.modelTask.Change("uid", update); err != nil { + if taskTag == comm.TASK_DAILY { + update["dayList"] = dataList + } else if taskTag == comm.TASK_WEEKLY { + update["weekList"] = dataList + } + + if err := this.moduleTask.modelTask.Change(uid, update); err != nil { log.Error("更新每日任务", log.Fields{"uid": uid}) } } @@ -325,6 +330,7 @@ func (this *ModelTask) checkTask(uid string, taskId int32) (*pb.TaskData, bool) } //更改用户任务 +// Deprecated func (this *ModelTask) modifyUserTask(uid string, taskId int32, data map[string]interface{}) error { var task *pb.DBTask if err := this.GetList(uid, &task); err != nil {