From a37d47703d39e5d52535db93fe1cbe7549fbf806 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 28 Feb 2023 17:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=86=8A=E7=8C=AB=E8=B5=84=E6=BA=90=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 4 ++ modules/modulebase.go | 34 ++++++------- modules/practice/api_practice.go | 5 ++ modules/practice/modelPandata.go | 8 +-- modules/practice/module.go | 29 +++++++++++ pb/practice_msg.pb.go | 84 ++++++++++++++++++++++++++++---- services/worker/main.go | 2 + 7 files changed, 134 insertions(+), 32 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 0ac10a8b0..47f4e061b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -420,4 +420,8 @@ type ( IPandaAtlas interface { CheckActivatePandaAtlasCollect(uid string, id string) (code pb.ErrorCode) } + //练功房 + IPractice interface { + AddItems(session IUserSession, items map[string]int32, bPush bool) (code pb.ErrorCode) + } ) diff --git a/modules/modulebase.go b/modules/modulebase.go index 0709826d0..84b4eb170 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -28,18 +28,18 @@ type ModuleBase struct { options IOptions scomp comm.ISC_GateRouteComp //网关服务组件 //常用的一些通用模块 在底层注册好 - ModuleSys comm.ISys //系统 - ModuleUser comm.IUser //用户模块 - ModuleItems comm.IItems //道具背包模块 - ModuleHero comm.IHero //英雄模块 - ModuleEquipment comm.IEquipment //装备模块 - ModuleTask comm.ITask //任务 - ModuleFriend comm.IFriend //好友 - ModuleRtask comm.IRtask //随机任务 - ModuleSociaty comm.ISociaty //公会 - ModulePrivilege comm.IPrivilege // 月卡 - ModuleSmithy comm.ISmithy // - ModulePandaAtlas comm.IPandaAtlas // + ModuleSys comm.ISys //系统 + ModuleUser comm.IUser //用户模块 + ModuleItems comm.IItems //道具背包模块 + ModuleHero comm.IHero //英雄模块 + ModuleEquipment comm.IEquipment //装备模块 + ModuleTask comm.ITask //任务 + ModuleFriend comm.IFriend //好友 + ModuleRtask comm.IRtask //随机任务 + ModuleSociaty comm.ISociaty //公会 + ModulePrivilege comm.IPrivilege // 月卡 + ModuleSmithy comm.ISmithy // + ModulePractice comm.IPractice //练功房 } //重构模块配置对象 @@ -121,10 +121,10 @@ func (this *ModuleBase) Start() (err error) { return } this.ModuleSmithy = module.(comm.ISmithy) - if module, err = this.service.GetModule(comm.ModulePandaAtlas); err != nil { + if module, err = this.service.GetModule(comm.ModulePractice); err != nil { return } - this.ModulePandaAtlas = module.(comm.IPandaAtlas) + this.ModulePractice = module.(comm.IPractice) return } @@ -453,10 +453,8 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat } } if len(panda) > 0 { - for k := range panda { - code = this.ModulePandaAtlas.CheckActivatePandaAtlasCollect(session.GetUserId(), k) - this.Debugf("发放武馆图鉴资源: %v [%v]", k, code) - } + code = this.ModulePractice.AddItems(session, panda, bPush) + this.Debugf("发放武馆资源: %v [%v]", panda, code) } return } diff --git a/modules/practice/api_practice.go b/modules/practice/api_practice.go index 444f0930e..e56f4cdd3 100644 --- a/modules/practice/api_practice.go +++ b/modules/practice/api_practice.go @@ -51,6 +51,11 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic filed = "pillarf" break } + if !pillar.Isunlock { //柱子未解锁 + code = pb.ErrorCode_ReqParameterError + return + } + if pillarconfigure, err = this.module.configure.getGamePandamasMz(pillar.Lv); err != nil { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/practice/modelPandata.go b/modules/practice/modelPandata.go index 7f17f9858..c62275f14 100644 --- a/modules/practice/modelPandata.go +++ b/modules/practice/modelPandata.go @@ -41,10 +41,10 @@ func (this *modelPandata) queryUserMartialhall(uid string) (result *pb.DBPractic Uid: uid, Full: make(map[int32]int32), Knapsack: make(map[string]int32), - Pillar1: &pb.DBPracticePillar{Index: 1}, - Pillar2: &pb.DBPracticePillar{Index: 2}, - Pillar3: &pb.DBPracticePillar{Index: 3}, - Pillarf: &pb.DBPracticePillar{Index: 4}, + Pillar1: &pb.DBPracticePillar{Index: 1, Isunlock: true, Lv: 1}, + Pillar2: &pb.DBPracticePillar{Index: 2, Lv: 1}, + Pillar3: &pb.DBPracticePillar{Index: 3, Lv: 1}, + Pillarf: &pb.DBPracticePillar{Index: 4, Lv: 1}, } if err = this.Add(uid, result); err != nil { this.module.Errorln(err) diff --git a/modules/practice/module.go b/modules/practice/module.go index f51698d39..c377d82b8 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/modules" + "go_dreamfactory/pb" ) /* @@ -21,6 +22,7 @@ type Practice struct { modules.ModuleBase service base.IRPCXService mail comm.Imail + atlas comm.IPandaAtlas api *apiComp configure *configureComp modelPandata *modelPandata @@ -44,6 +46,10 @@ func (this *Practice) Start() (err error) { return } this.mail = module.(comm.Imail) + if module, err = this.service.GetModule(comm.ModulePandaAtlas); err != nil { + return + } + this.atlas = module.(comm.IPandaAtlas) return } @@ -54,3 +60,26 @@ func (this *Practice) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.modelPandata = this.RegisterComp(new(modelPandata)).(*modelPandata) } + +func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32, bPush bool) (code pb.ErrorCode) { + var ( + err error + room *pb.DBPracticeRoom + id []string + ) + if room, err = this.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil { + code = pb.ErrorCode_DBError + return + } + id = make([]string, 0) + for k, _ := range items { + room.Knapsack[k] = 0 + id = append(id, k) + this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), k) + } + this.modelPandata.Change(session.GetUserId(), map[string]interface{}{ + "knapsack": room.Knapsack, + }) + session.SendMsg(string(this.GetType()), "jxitem", &pb.PracticeJXItemPush{Id: id}) + return +} diff --git a/pb/practice_msg.pb.go b/pb/practice_msg.pb.go index 607dadc3a..38cd94106 100644 --- a/pb/practice_msg.pb.go +++ b/pb/practice_msg.pb.go @@ -835,6 +835,54 @@ func (x *PracticeEnrolledResp) GetHero() string { return "" } +///练功道具和教习推送 +type PracticeJXItemPush struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []string `protobuf:"bytes,1,rep,name=id,proto3" json:"id"` +} + +func (x *PracticeJXItemPush) Reset() { + *x = PracticeJXItemPush{} + if protoimpl.UnsafeEnabled { + mi := &file_practice_practice_msg_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PracticeJXItemPush) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PracticeJXItemPush) ProtoMessage() {} + +func (x *PracticeJXItemPush) ProtoReflect() protoreflect.Message { + mi := &file_practice_practice_msg_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PracticeJXItemPush.ProtoReflect.Descriptor instead. +func (*PracticeJXItemPush) Descriptor() ([]byte, []int) { + return file_practice_practice_msg_proto_rawDescGZIP(), []int{16} +} + +func (x *PracticeJXItemPush) GetId() []string { + if x != nil { + return x.Id + } + return nil +} + var File_practice_practice_msg_proto protoreflect.FileDescriptor var file_practice_practice_msg_proto_rawDesc = []byte{ @@ -899,8 +947,11 @@ var file_practice_practice_msg_proto_rawDesc = []byte{ 0x14, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x68, - 0x65, 0x72, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, + 0x24, 0x0a, 0x12, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x4a, 0x58, 0x49, 0x74, 0x65, + 0x6d, 0x50, 0x75, 0x73, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -915,7 +966,7 @@ func file_practice_practice_msg_proto_rawDescGZIP() []byte { return file_practice_practice_msg_proto_rawDescData } -var file_practice_practice_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_practice_practice_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_practice_practice_msg_proto_goTypes = []interface{}{ (*PracticeInfoReq)(nil), // 0: PracticeInfoReq (*PracticeInfoResp)(nil), // 1: PracticeInfoResp @@ -933,14 +984,15 @@ var file_practice_practice_msg_proto_goTypes = []interface{}{ (*PracticeReceiveResp)(nil), // 13: PracticeReceiveResp (*PracticeEnrolledReq)(nil), // 14: PracticeEnrolledReq (*PracticeEnrolledResp)(nil), // 15: PracticeEnrolledResp - (*DBPracticeRoom)(nil), // 16: DBPracticeRoom - (*DBPracticePillar)(nil), // 17: DBPracticePillar + (*PracticeJXItemPush)(nil), // 16: PracticeJXItemPush + (*DBPracticeRoom)(nil), // 17: DBPracticeRoom + (*DBPracticePillar)(nil), // 18: DBPracticePillar } var file_practice_practice_msg_proto_depIdxs = []int32{ - 16, // 0: PracticeInfoResp.info:type_name -> DBPracticeRoom - 16, // 1: PracticeFriendRommResp.info:type_name -> DBPracticeRoom - 17, // 2: PracticePracticeResp.pillar:type_name -> DBPracticePillar - 17, // 3: PracticeLootResp.pillar:type_name -> DBPracticePillar + 17, // 0: PracticeInfoResp.info:type_name -> DBPracticeRoom + 17, // 1: PracticeFriendRommResp.info:type_name -> DBPracticeRoom + 18, // 2: PracticePracticeResp.pillar:type_name -> DBPracticePillar + 18, // 3: PracticeLootResp.pillar:type_name -> DBPracticePillar 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 @@ -1147,6 +1199,18 @@ func file_practice_practice_msg_proto_init() { return nil } } + file_practice_practice_msg_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PracticeJXItemPush); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1154,7 +1218,7 @@ func file_practice_practice_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_practice_practice_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 16, + NumMessages: 17, NumExtensions: 0, NumServices: 0, }, diff --git a/services/worker/main.go b/services/worker/main.go index 8516d578d..69d39d4fb 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -31,6 +31,7 @@ import ( "go_dreamfactory/modules/notify" "go_dreamfactory/modules/pagoda" "go_dreamfactory/modules/pay" + "go_dreamfactory/modules/practice" "go_dreamfactory/modules/privilege" "go_dreamfactory/modules/pvp" "go_dreamfactory/modules/reddot" @@ -116,6 +117,7 @@ func main() { pvp.NewModule(), dispatch.NewModule(), atlas.NewModule(), + practice.NewModule(), ) }