From 7cca06d54880d7af10a8c3732455c5e3dcccf6f1 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 6 Dec 2022 16:22:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=9C=88=E4=B9=8B=E7=A7=98?= =?UTF-8?q?=E5=A2=83=E8=A7=A6=E5=8F=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 3 +- comm/imodule.go | 2 + modules/moonfantasy/modelDream.go | 53 +++++++++++++++++++ modules/moonfantasy/module.go | 36 +++++++++++++ pb/moonfantasy_db.pb.go | 85 ++++++++++++++++++++++++++++--- 5 files changed, 172 insertions(+), 7 deletions(-) diff --git a/comm/const.go b/comm/const.go index 42ea69c38..df91ddb2f 100644 --- a/comm/const.go +++ b/comm/const.go @@ -220,7 +220,8 @@ const ( //Rpc //Chat 命令 Rpc_ModuleChatPushChat core.Rpc_Key = "Rpc_ModuleChatPushChat" //推送聊天消息 //Moonfantasy 月之秘境 - Rpc_ModuleMoonfantasyTrigger core.Rpc_Key = "Rpc_ModuleMoonfantasyTrigger" //月之秘境触发消息 + Rpc_ModuleMoonfantasyTrigger core.Rpc_Key = "Rpc_ModuleMoonfantasyTrigger" //月之秘境触发消息 + Rpc_ModuleMoonfantasyTriggerMF core.Rpc_Key = "Rpc_ModuleMoonfantasyTriggerMF" //月之秘境触发消息 //rtask 上传随机任务代码 Rpc_ModuleRtaskSendTask core.Rpc_Key = "Rpc_ModuleRtaskSendTask" //随机任务触发 // friend diff --git a/comm/imodule.go b/comm/imodule.go index 0b507e9fe..a60cd1c97 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -234,6 +234,8 @@ type ( IMoonFantasy interface { //触发月之秘境 Trigger(session IUserSession, source *pb.BattleReport) + //GM触发月之秘境 + TriggerMF(session IUserSession, Boosid string) (err error) } IViking interface { CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank) // 查询玩家最佳通关记录 diff --git a/modules/moonfantasy/modelDream.go b/modules/moonfantasy/modelDream.go index b009ad11a..a49016a1f 100644 --- a/modules/moonfantasy/modelDream.go +++ b/modules/moonfantasy/modelDream.go @@ -138,6 +138,59 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) { return } +//触发月之秘境 +func (this *modelDreamComp) triggerbyid(session comm.IUserSession, boosid string) (err error) { + var ( + user *pb.DBUser + umfantasy *pb.DBUserMFantasy + globalconf *cfg.GameGlobalData + boss *cfg.GameDreamlandBoosData + mdata *pb.DBMoonFantasy + chat *pb.DBChat + ) + globalconf = this.module.configure.GetGlobalConf() + + if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { + return + } + this.module.modelUserMF.recoverTicket(session, umfantasy) + if umfantasy.TriggerNum >= globalconf.DreamlandTriggernum { + return + } + + if boss, err = this.module.configure.GetMonsterById(boosid); err != nil { + this.module.Errorln(err) + return + } + if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { + this.module.Errorf("no found uer:%d", session.GetUserId()) + return + } + + if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}, boss); err != nil { + return + } + // umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + umfantasy.TriggerNum++ + umfantasy.LastTrigger = configure.Now().Unix() + this.module.modelUserMF.updateUserInfo(umfantasy) + chat = &pb.DBChat{ + Ctype: pb.ChatType_Moonfantasy, + Suid: session.GetUserId(), + Avatar: user.Avatar, + Uname: user.Name, + Slv: user.Lv, + Ctime: configure.Now().Unix(), + Stag: session.GetServiecTag(), + Content: mdata.Monster, + AppendStr: mdata.Id, + } + this.module.modelDream.noticeuserfriend(session, mdata.Id, chat) + session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerPush{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster}) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype87, 1) + return +} + ///查询好友数据 func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid string, chat *pb.DBChat) (code pb.ErrorCode) { var ( diff --git a/modules/moonfantasy/module.go b/modules/moonfantasy/module.go index d1f363d76..84ba71e24 100644 --- a/modules/moonfantasy/module.go +++ b/modules/moonfantasy/module.go @@ -65,6 +65,7 @@ func (this *Moonfantasy) Start() (err error) { } this.battle = module.(comm.IBattle) this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTrigger), this.Rpc_ModuleMoonfantasyTrigger) + this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTriggerMF), this.Rpc_ModuleMoonfantasyTriggerMF) return } @@ -119,3 +120,38 @@ func (this *Moonfantasy) Rpc_ModuleMoonfantasyTrigger(ctx context.Context, args } return } + +//触发月之秘境 +func (this *Moonfantasy) Rpc_ModuleMoonfantasyTriggerMF(ctx context.Context, args *pb.RPCTargetMFReq, reply *pb.EmptyResp) (err error) { + var ( + session comm.IUserSession + ok bool + ) + if session, ok = this.GetUserSession(args.Uid); !ok { + err = fmt.Errorf("no found user%s", args.Uid) + this.Errorln(err) + return + } + if err = this.modelDream.triggerbyid(session, args.Boosid); err != nil { + this.Errorln(err) + } + return +} + +//触发月之秘境 +func (this *Moonfantasy) TriggerMF(session comm.IUserSession, Boosid string) (err error) { + if this.IsCross() { + err = this.modelDream.triggerbyid(session, Boosid) + } else { + if _, err = this.service.AcrossClusterRpcGo(context.Background(), + this.GetCrossTag(), + comm.Service_Worker, + string(comm.Rpc_ModuleMoonfantasyTriggerMF), + pb.RPCTargetMFReq{Uid: session.GetUserId(), Boosid: Boosid}, + nil, + ); err != nil { + this.Errorln(err) + } + } + return +} diff --git a/pb/moonfantasy_db.pb.go b/pb/moonfantasy_db.pb.go index a48ede6cf..30ddc79c1 100644 --- a/pb/moonfantasy_db.pb.go +++ b/pb/moonfantasy_db.pb.go @@ -292,6 +292,62 @@ func (x *DBUserMFantasy) GetLastrtickettime() int64 { return 0 } +//RPC 触发请求 +type RPCTargetMFReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id + Boosid string `protobuf:"bytes,2,opt,name=boosid,proto3" json:"boosid"` //怪物id +} + +func (x *RPCTargetMFReq) Reset() { + *x = RPCTargetMFReq{} + if protoimpl.UnsafeEnabled { + mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RPCTargetMFReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RPCTargetMFReq) ProtoMessage() {} + +func (x *RPCTargetMFReq) ProtoReflect() protoreflect.Message { + mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[3] + 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 RPCTargetMFReq.ProtoReflect.Descriptor instead. +func (*RPCTargetMFReq) Descriptor() ([]byte, []int) { + return file_moonfantasy_moonfantasy_db_proto_rawDescGZIP(), []int{3} +} + +func (x *RPCTargetMFReq) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *RPCTargetMFReq) GetBoosid() string { + if x != nil { + return x.Boosid + } + return "" +} + var File_moonfantasy_moonfantasy_db_proto protoreflect.FileDescriptor var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ @@ -333,8 +389,12 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6c, 0x61, - 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x3a, 0x0a, + 0x0e, 0x52, 0x50, 0x43, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x46, 0x52, 0x65, 0x71, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, + 0x64, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -349,16 +409,17 @@ func file_moonfantasy_moonfantasy_db_proto_rawDescGZIP() []byte { return file_moonfantasy_moonfantasy_db_proto_rawDescData } -var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_moonfantasy_moonfantasy_db_proto_goTypes = []interface{}{ (*UserInfo)(nil), // 0: UserInfo (*DBMoonFantasy)(nil), // 1: DBMoonFantasy (*DBUserMFantasy)(nil), // 2: DBUserMFantasy - nil, // 3: DBMoonFantasy.RecordEntry + (*RPCTargetMFReq)(nil), // 3: RPCTargetMFReq + nil, // 4: DBMoonFantasy.RecordEntry } var file_moonfantasy_moonfantasy_db_proto_depIdxs = []int32{ 0, // 0: DBMoonFantasy.join:type_name -> UserInfo - 3, // 1: DBMoonFantasy.record:type_name -> DBMoonFantasy.RecordEntry + 4, // 1: DBMoonFantasy.record:type_name -> DBMoonFantasy.RecordEntry 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -408,6 +469,18 @@ func file_moonfantasy_moonfantasy_db_proto_init() { return nil } } + file_moonfantasy_moonfantasy_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RPCTargetMFReq); 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{ @@ -415,7 +488,7 @@ func file_moonfantasy_moonfantasy_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_moonfantasy_moonfantasy_db_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, },