From b2881f5f6810cfa38c5163a76a2586ac5ea7411f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 26 Dec 2023 18:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/integral/api_challengeover.go | 48 ++++++++-- modules/library/model_library.go | 9 ++ modules/library/module.go | 24 +++-- pb/integral_msg.pb.go | 123 ++++++++++++++++---------- 4 files changed, 143 insertions(+), 61 deletions(-) diff --git a/modules/integral/api_challengeover.go b/modules/integral/api_challengeover.go index fa26c0704..aca953a90 100644 --- a/modules/integral/api_challengeover.go +++ b/modules/integral/api_challengeover.go @@ -21,11 +21,14 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Integ ///挑战主线关卡 func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralChallengeOverReq) (errdata *pb.ErrorData) { var ( - update map[string]interface{} - res []*cfg.Gameatn - first bool // 是否是首通 - line []*pb.LineUp // 阵容数据 - harm int32 + update map[string]interface{} + res []*cfg.Gameatn + first bool // 是否是首通 + line []*pb.LineUp // 阵容数据 + harm int32 + changExp map[string]int32 + atno []*pb.UserAtno // atno 类型 + curAddExp []int32 ) harm = req.Report.Harm update = make(map[string]interface{}, 0) @@ -116,11 +119,44 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralCh this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "IntegralChallengeOverReq", res) }) } + if first { + res = append(res, cfgData.Firstprize...) + } + if user, err := this.module.ModuleUser.GetUser(session.GetUserId()); err == nil { + reward = this.module.ModuleTools.GetGroupDataByLottery(cfgData.Drop, user.Vip, user.Lv) + res = append(res, reward...) + } + + if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { + return + } + // 加经验 + if cfgData.Heroexp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if v.HeroID != "" { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + changExp[v.Oid] = 0 + } + } + } + } + if curAddExp, errdata = this.module.ModuleHero.AddHerosExp(session, heroObjs, cfgData.Heroexp); errdata != nil { + return + } + for pos, v := range heroObjs { + changExp[v] = curAddExp[pos] + } + } err = this.module.modelIntegral.modifyIntegralData(session.GetUserId(), update) session.SendMsg(string(this.module.GetType()), "challengeover", &pb.IntegralChallengeOverResp{ - Data: list, + Data: list, + Atno: atno, + Heroexp: changExp, }) return diff --git a/modules/library/model_library.go b/modules/library/model_library.go index a306cb769..4e5629ae4 100644 --- a/modules/library/model_library.go +++ b/modules/library/model_library.go @@ -50,6 +50,15 @@ func (this *modelLibrary) createLibrary(uid string, fetter *pb.DBLibrary) (err e return } +// 通过objid 找对应的数据 +func (this *modelLibrary) getLibrarysByOid(uid string, oids []string) (fetters []*pb.DBLibrary) { + + if err := this.GetListObjs(uid, oids, fetters); err != nil { + return nil + } + return +} + // 通过objid 找对应的数据 func (this *modelLibrary) getOneLibrary(uid, oid string) *pb.DBLibrary { fetter := &pb.DBLibrary{} diff --git a/modules/library/module.go b/modules/library/module.go index 7c09e2645..1ef89596f 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -98,15 +98,22 @@ func (this *Library) GetLibraryListByHid(uid string, hid string) *pb.DBLibrary { return nil } -// func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibrary, fetter []*pb.DBHeroFetter) { var ( - oid *pb.DBHeroFetter + oid *pb.DBHeroFetter + list []*pb.DBLibrary + lib *pb.DBLibrary ) oid = this.CheckHeroFetter(uid, hid) // 校验羁绊数据 szFid := this.configure.GetHeroFetterID(hid) + list = this.modelLibrary.getLibraryList(uid) for fid := range szFid { - if list := this.GetLibraryListByFid(uid, fid); list == nil { // 没有这条羁绊数据 + for _, v := range list { + if v.Fid == fid { + lib = v + } + } + if lib == nil { tmp := &pb.DBLibrary{ // 创建一条羁绊数据 Id: primitive.NewObjectID().Hex(), Uid: uid, @@ -125,16 +132,17 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr continue } dbLibrary = append(dbLibrary, tmp) + list = append(list, tmp) } else { // 有这条羁绊数据 - if _, ok := list.Herofetter[hid]; !ok { + if _, ok := lib.Herofetter[hid]; !ok { if oid != nil { - list.Herofetter[hid] = oid.Id + lib.Herofetter[hid] = oid.Id fetter = append(fetter, oid) } mapData := make(map[string]interface{}, 0) - mapData["herofetter"] = list.Herofetter - this.modelLibrary.modifyLibraryDataByObjId(uid, list.Id, mapData) // 更新新的羁绊信息 - dbLibrary = append(dbLibrary, list) + mapData["herofetter"] = lib.Herofetter + this.modelLibrary.modifyLibraryDataByObjId(uid, lib.Id, mapData) // 更新新的羁绊信息 + dbLibrary = append(dbLibrary, lib) } } } diff --git a/pb/integral_msg.pb.go b/pb/integral_msg.pb.go index 2a18f4188..f9cfd0c1c 100644 --- a/pb/integral_msg.pb.go +++ b/pb/integral_msg.pb.go @@ -277,7 +277,9 @@ type IntegralChallengeOverResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data *DBIntegralBoss `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` + Data *DBIntegralBoss `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` + Atno []*UserAtno `protobuf:"bytes,2,rep,name=atno,proto3" json:"atno"` // 推送atno + Heroexp map[string]int32 `protobuf:"bytes,3,rep,name=heroexp,proto3" json:"heroexp" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 英雄获得经验 } func (x *IntegralChallengeOverResp) Reset() { @@ -319,6 +321,20 @@ func (x *IntegralChallengeOverResp) GetData() *DBIntegralBoss { return nil } +func (x *IntegralChallengeOverResp) GetAtno() []*UserAtno { + if x != nil { + return x.Atno + } + return nil +} + +func (x *IntegralChallengeOverResp) GetHeroexp() map[string]int32 { + if x != nil { + return x.Heroexp + } + return nil +} + // 领取奖励 type IntegralGetRewardReq struct { state protoimpl.MessageState @@ -555,30 +571,40 @@ var file_integral_integral_msg_proto_rawDesc = []byte{ 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x64, 0x75, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 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, 0x40, 0x0a, 0x19, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x43, 0x68, 0x61, - 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, - 0x42, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0a, 0x14, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x47, - 0x65, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x69, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x74, 0x79, 0x70, - 0x65, 0x22, 0x5d, 0x0a, 0x15, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x47, 0x65, 0x74, - 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x49, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x61, 0x6c, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, - 0x1f, 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, - 0x22, 0x2b, 0x0a, 0x13, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x64, 0x75, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x64, 0x75, 0x22, 0x68, 0x0a, - 0x14, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, - 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x12, 0x29, 0x0a, 0x07, - 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, - 0x44, 0x42, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x07, - 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x22, 0xde, 0x01, 0x0a, 0x19, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x43, 0x68, + 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, + 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, + 0x44, 0x42, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x04, 0x61, 0x74, 0x6e, 0x6f, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x04, 0x61, + 0x74, 0x6e, 0x6f, 0x12, 0x41, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x78, 0x70, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x43, + 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x65, 0x78, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, + 0x65, 0x72, 0x6f, 0x65, 0x78, 0x70, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x65, 0x78, + 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x2c, 0x0a, 0x14, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x47, 0x65, + 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x74, 0x79, 0x70, 0x65, + 0x22, 0x5d, 0x0a, 0x15, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x47, 0x65, 0x74, 0x52, + 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x49, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x61, 0x6c, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1f, + 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x22, + 0x2b, 0x0a, 0x13, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x64, 0x75, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x64, 0x75, 0x22, 0x68, 0x0a, 0x14, + 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, + 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, + 0x42, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x07, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -593,7 +619,7 @@ func file_integral_integral_msg_proto_rawDescGZIP() []byte { return file_integral_integral_msg_proto_rawDescData } -var file_integral_integral_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_integral_integral_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_integral_integral_msg_proto_goTypes = []interface{}{ (*IntegralGetListReq)(nil), // 0: IntegralGetListReq (*IntegralGetListResp)(nil), // 1: IntegralGetListResp @@ -605,28 +631,31 @@ var file_integral_integral_msg_proto_goTypes = []interface{}{ (*IntegralGetRewardResp)(nil), // 7: IntegralGetRewardResp (*IntegralRankListReq)(nil), // 8: IntegralRankListReq (*IntegralRankListResp)(nil), // 9: IntegralRankListResp - (*DBIntegralBoss)(nil), // 10: DBIntegralBoss - (*BattleFormation)(nil), // 11: BattleFormation - (*BattleInfo)(nil), // 12: BattleInfo - (*BattleReport)(nil), // 13: BattleReport - (*UserAtno)(nil), // 14: UserAtno - (*DBIntegralRank)(nil), // 15: DBIntegralRank + nil, // 10: IntegralChallengeOverResp.HeroexpEntry + (*DBIntegralBoss)(nil), // 11: DBIntegralBoss + (*BattleFormation)(nil), // 12: BattleFormation + (*BattleInfo)(nil), // 13: BattleInfo + (*BattleReport)(nil), // 14: BattleReport + (*UserAtno)(nil), // 15: UserAtno + (*DBIntegralRank)(nil), // 16: DBIntegralRank } var file_integral_integral_msg_proto_depIdxs = []int32{ - 10, // 0: IntegralGetListResp.data:type_name -> DBIntegralBoss - 11, // 1: IntegralChallengeReq.battle:type_name -> BattleFormation - 12, // 2: IntegralChallengeResp.info:type_name -> BattleInfo - 13, // 3: IntegralChallengeOverReq.report:type_name -> BattleReport - 10, // 4: IntegralChallengeOverResp.data:type_name -> DBIntegralBoss - 10, // 5: IntegralGetRewardResp.data:type_name -> DBIntegralBoss - 14, // 6: IntegralGetRewardResp.award:type_name -> UserAtno - 15, // 7: IntegralRankListResp.ranks:type_name -> DBIntegralRank - 15, // 8: IntegralRankListResp.friends:type_name -> DBIntegralRank - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 11, // 0: IntegralGetListResp.data:type_name -> DBIntegralBoss + 12, // 1: IntegralChallengeReq.battle:type_name -> BattleFormation + 13, // 2: IntegralChallengeResp.info:type_name -> BattleInfo + 14, // 3: IntegralChallengeOverReq.report:type_name -> BattleReport + 11, // 4: IntegralChallengeOverResp.data:type_name -> DBIntegralBoss + 15, // 5: IntegralChallengeOverResp.atno:type_name -> UserAtno + 10, // 6: IntegralChallengeOverResp.heroexp:type_name -> IntegralChallengeOverResp.HeroexpEntry + 11, // 7: IntegralGetRewardResp.data:type_name -> DBIntegralBoss + 15, // 8: IntegralGetRewardResp.award:type_name -> UserAtno + 16, // 9: IntegralRankListResp.ranks:type_name -> DBIntegralRank + 16, // 10: IntegralRankListResp.friends:type_name -> DBIntegralRank + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_integral_integral_msg_proto_init() } @@ -765,7 +794,7 @@ func file_integral_integral_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_integral_integral_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, },