diff --git a/modules/atlas/api_atlasactivate.go b/modules/atlas/api_atlasactivate.go index 01fff208c..04abd0170 100644 --- a/modules/atlas/api_atlasactivate.go +++ b/modules/atlas/api_atlasactivate.go @@ -9,40 +9,41 @@ import ( //参数校验 func (this *apiComp) ActivateCheck(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode) { - if req.Id == "" { - code = pb.ErrorCode_ReqParameterError - } + return } -// 激活图鉴信息 +// 一键激活所有激活图鉴信息 func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode, data proto.Message) { + var ( + bUpdate bool + ) if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success { return } - atlasConf := this.module.configure.GetPandoAtlasConf(req.Id) - if atlasConf == nil { - code = pb.ErrorCode_ReqParameterError - return - } list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId()) - if v, ok := list.Collect[req.Id]; ok { + for k, v := range list.Collect { if !v.Activate { - update := make(map[string]interface{}) v.Activate = true // 找到图鉴积分 并更新积分 - list.Score += atlasConf.AtlasScore - update["collect"] = list.Collect - update["score"] = list.Score - this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) - session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{ - Data: list, - }) - return - } else { - code = pb.ErrorCode_SmithyNoActivateAtlas + if atlasConf := this.module.configure.GetPandoAtlasConf(k); atlasConf != nil { + list.Score += atlasConf.AtlasScore + bUpdate = true + } } } - code = pb.ErrorCode_SmithyNoFoundAtlas + if bUpdate { // 更新数据 + update := make(map[string]interface{}) + update["collect"] = list.Collect + update["score"] = list.Score + + this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) + } else { + code = pb.ErrorCode_MartialhallAtlasError + } + + session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{ + Data: list, + }) return } diff --git a/modules/atlas/api_atlasaward.go b/modules/atlas/api_atlasaward.go index 2bb47fc10..1fa36bc4d 100644 --- a/modules/atlas/api_atlasaward.go +++ b/modules/atlas/api_atlasaward.go @@ -3,6 +3,7 @@ package atlas import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" ) @@ -13,27 +14,52 @@ func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.AtlasAwardReq return } -// 获取铁匠铺图鉴信息 +// 一键领取所有可以领取的奖励 func (this *apiComp) Award(session comm.IUserSession, req *pb.AtlasAwardReq) (code pb.ErrorCode, data proto.Message) { - + var ( + res []*cfg.Gameatn + respRes []*pb.UserAssets + ) list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId()) - conf := this.module.configure.GetPandoAtlasAwardConf(list.Award + 1) - if conf == nil { - code = pb.ErrorCode_SmithyAtlasMaxLv + for { + conf := this.module.configure.GetPandoAtlasAwardConf(list.Award + 1) + if conf == nil { + break + } + if list.Score < conf.AtlasScore { // 校验积分够不够 + break + } + list.Award += 1 + res = append(res, conf.ItemId...) + } + if len(res) == 0 { // 没有奖励可领取 + code = pb.ErrorCode_MartialhallAtlasNoReward return } - // 校验积分够不够 - if list.Score < conf.AtlasScore { - code = pb.ErrorCode_SmithyAtlasLackLv - return + this.module.DispenseRes(session, res, true) + + for _, v := range res { + for _, v1 := range respRes { + bFind := false + if v1.A == v.A && v1.T == v.T { + v1.N += v.N + bFind = true + } + if !bFind { + respRes = append(respRes, &pb.UserAssets{ + A: v.A, + T: v.T, + N: v.N, + }) + } + } } - this.module.DispenseRes(session, conf.ItemId, true) update := make(map[string]interface{}) - list.Award += 1 update["award"] = list.Award this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) session.SendMsg(string(this.module.GetType()), "award", &pb.AtlasAwardResp{ Data: list, + Res: respRes, }) return } diff --git a/pb/atlas_msg.pb.go b/pb/atlas_msg.pb.go index 0edb1cad7..1bde889be 100644 --- a/pb/atlas_msg.pb.go +++ b/pb/atlas_msg.pb.go @@ -111,8 +111,6 @@ type AtlasActivateReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` // 图鉴ID } func (x *AtlasActivateReq) Reset() { @@ -147,13 +145,6 @@ func (*AtlasActivateReq) Descriptor() ([]byte, []int) { return file_atlas_atlas_msg_proto_rawDescGZIP(), []int{2} } -func (x *AtlasActivateReq) GetId() string { - if x != nil { - return x.Id - } - return "" -} - type AtlasActivateResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -246,6 +237,7 @@ type AtlasAwardResp struct { unknownFields protoimpl.UnknownFields Data *DBPandaAtlas `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` // 奖励信息 + Res []*UserAssets `protobuf:"bytes,2,rep,name=res,proto3" json:"res"` // 获得的奖励 } func (x *AtlasAwardResp) Reset() { @@ -287,28 +279,37 @@ func (x *AtlasAwardResp) GetData() *DBPandaAtlas { return nil } +func (x *AtlasAwardResp) GetRes() []*UserAssets { + if x != nil { + return x.Res + } + return nil +} + var File_atlas_atlas_msg_proto protoreflect.FileDescriptor var file_atlas_atlas_msg_proto_rawDesc = []byte{ 0x0a, 0x15, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x61, - 0x74, 0x6c, 0x61, 0x73, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x11, 0x0a, - 0x0f, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x22, 0x35, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, - 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x22, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, - 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x36, 0x0a, 0x11, 0x41, - 0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x74, 0x6c, 0x61, 0x73, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63, + 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x11, 0x0a, 0x0f, 0x41, 0x74, 0x6c, + 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x35, 0x0a, 0x10, + 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x22, 0x0f, 0x0a, 0x0d, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x72, - 0x64, 0x52, 0x65, 0x71, 0x22, 0x33, 0x0a, 0x0e, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, - 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, - 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x61, 0x22, 0x12, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x22, 0x36, 0x0a, 0x11, 0x41, 0x74, 0x6c, 0x61, 0x73, + 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, + 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x0f, 0x0a, 0x0d, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, + 0x22, 0x52, 0x0a, 0x0e, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, + 0x03, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -332,16 +333,18 @@ var file_atlas_atlas_msg_proto_goTypes = []interface{}{ (*AtlasAwardReq)(nil), // 4: AtlasAwardReq (*AtlasAwardResp)(nil), // 5: AtlasAwardResp (*DBPandaAtlas)(nil), // 6: DBPandaAtlas + (*UserAssets)(nil), // 7: UserAssets } var file_atlas_atlas_msg_proto_depIdxs = []int32{ 6, // 0: AtlasGetListResp.data:type_name -> DBPandaAtlas 6, // 1: AtlasActivateResp.data:type_name -> DBPandaAtlas 6, // 2: AtlasAwardResp.data:type_name -> DBPandaAtlas - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 7, // 3: AtlasAwardResp.res:type_name -> UserAssets + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_atlas_atlas_msg_proto_init() } @@ -350,6 +353,7 @@ func file_atlas_atlas_msg_proto_init() { return } file_atlas_atlas_db_proto_init() + file_comm_proto_init() if !protoimpl.UnsafeEnabled { file_atlas_atlas_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AtlasGetListReq); i {