From 7b0826724e9f7d7428eaf0cbf7a086761e08c66b Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 11 Jul 2023 17:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=A4=B1=E8=B4=A5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_challengereward.go | 6 +-- modules/chat/module.go | 59 ++++++++++++++++++---------- modules/hero/api_strengthenUplv.go | 6 +-- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/modules/arena/api_challengereward.go b/modules/arena/api_challengereward.go index cf266b34f..e1cb8e77c 100644 --- a/modules/arena/api_challengereward.go +++ b/modules/arena/api_challengereward.go @@ -8,13 +8,13 @@ import ( cfg "go_dreamfactory/sys/configure/structs" ) -//参数校验 +// 参数校验 func (this *apiComp) ChallengeRewardCheck(session comm.IUserSession, req *pb.ArenaChallengeRewardReq) (errdata *pb.ErrorData) { return } -///挑战奖励领取 +// /挑战奖励领取 func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaChallengeRewardReq) (errdata *pb.ErrorData) { var ( reward *cfg.GameArenaActiveRewardData @@ -46,7 +46,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha errdata = &pb.ErrorData{ Code: pb.ErrorCode_BattleValidationFailed, Title: pb.ErrorCode_BattleValidationFailed.ToString(), - Message: err.Error(), + Message: "CheckBattleReport check fail", } return } diff --git a/modules/chat/module.go b/modules/chat/module.go index b5bdcfd53..43a32fa28 100644 --- a/modules/chat/module.go +++ b/modules/chat/module.go @@ -39,17 +39,17 @@ type Chat struct { modelChat *modelChatComp } -//重构模块配置对象 +// 重构模块配置对象 func (this *Chat) NewOptions() (options core.IModuleOptions) { return new(Options) } -//模块名 +// 模块名 func (this *Chat) GetType() core.M_Modules { return comm.ModuleChat } -//模块初始化接口 注册用户创建角色事件 +// 模块初始化接口 注册用户创建角色事件 func (this *Chat) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) @@ -73,7 +73,7 @@ func (this *Chat) Start() (err error) { return } -//装备组件 +// 装备组件 func (this *Chat) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) @@ -81,15 +81,15 @@ func (this *Chat) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } -//Event------------------------------------------------------------------------------------------------------------ +// Event------------------------------------------------------------------------------------------------------------ func (this *Chat) EventUserOffline(uid, sessionid string) { if err := this.modelChat.removeCrossChannelMember(uid); err != nil { this.Error("EventUserOffline", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) } } -//RPC-------------------------------------------------------------------------------------------------------------- -//推送聊天消息 +// RPC-------------------------------------------------------------------------------------------------------------- +// 推送聊天消息 func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, reply *pb.EmptyResp) (err error) { var ( max_chat int32 @@ -133,8 +133,8 @@ func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, r return } -//对外接口---------------------------------------------------------------------------------------------------------- -//向世界频道发送聊天消息 +// 对外接口---------------------------------------------------------------------------------------------------------- +// 向世界频道发送聊天消息 func (this *Chat) SendWorldChat(msg *pb.DBChat) (errdata *pb.ErrorData) { var ( max_chat int32 @@ -173,7 +173,7 @@ func (this *Chat) SendWorldChat(msg *pb.DBChat) (errdata *pb.ErrorData) { return } -//向工会发送聊天消息 +// 向工会发送聊天消息 func (this *Chat) SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData) { var ( max_chat int32 @@ -212,7 +212,7 @@ func (this *Chat) SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData) { return } -//向个人发送聊天消息 +// 向个人发送聊天消息 func (this *Chat) SendUserChat(msg *pb.DBChat) (errdata *pb.ErrorData) { var ( err error @@ -246,7 +246,7 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (errdata *pb.ErrorData) { return } -//广播系统消息 +// 广播系统消息 func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value0 int32, value1 int32, agrs ...string) (errdata *pb.ErrorData) { var ( jsonStr []byte @@ -263,7 +263,9 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter AppendInt: int64(st.Key), AppendStrs: agrs, } - if ctype == comm.ChatSystem3 { //装备分享 + + switch ctype { + case comm.ChatSystem3: msg.Ctype = pb.ChatType_Share if appenddata != nil { if jsonStr, err = json.Marshal(appenddata); err != nil { @@ -280,6 +282,23 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter msg.AppendStr = string(jsonStr) } } + case comm.ChatSystem7, comm.ChatSystem8, comm.ChatSystem9, comm.ChatSystem10, comm.ChatSystem11: + msg.Ctype = pb.ChatType_Share + if appenddata != nil { + if jsonStr, err = json.Marshal(appenddata); err != nil { + this.Errorf("err:%v", err) + } else { + data := map[string]interface{}{ + agrs[1]: map[string]interface{}{ + "key": agrs[1], + "appendStr": string(jsonStr), + "itemType": pb.ChatType_HeroShare, + }, + } + jsonStr, _ = json.Marshal(data) + msg.AppendStr = string(jsonStr) + } + } } if this.IsCross() { @@ -307,7 +326,7 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter return } -//广播系统消息 +// 广播系统消息 func (this *Chat) SendSysChatToUser(session comm.IUserSession, ctype comm.ChatSystemType, value0, value1 int32, agrs ...string) (errdata *pb.ErrorData) { if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value0, value1); ok { msg := &pb.DBChat{ @@ -320,8 +339,8 @@ func (this *Chat) SendSysChatToUser(session comm.IUserSession, ctype comm.ChatSy return } -//Push-------------------------------------------------------------------------------------------------------------- -//推送消息到世界 +// Push-------------------------------------------------------------------------------------------------------------- +// 推送消息到世界 func (this *Chat) pushChatToWorld(msg *pb.DBChat) (err error) { data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg}) if err = this.service.AcrossClusterBroadcast(context.Background(), msg.Stag, comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ @@ -334,7 +353,7 @@ func (this *Chat) pushChatToWorld(msg *pb.DBChat) (err error) { return } -//推送消息到工会 +// 推送消息到工会 func (this *Chat) pushChatToUnion(msg *pb.DBChat) (err error) { if members := this.sociaty.MembersBySociatyId(msg.UnionId); members != nil { users := make([]string, 0, len(members)) @@ -348,7 +367,7 @@ func (this *Chat) pushChatToUnion(msg *pb.DBChat) (err error) { return } -//推送私聊消息 +// 推送私聊消息 func (this *Chat) pushChatToPrivate(msg *pb.DBChat) (err error) { var ( session comm.IUserSession @@ -369,7 +388,7 @@ func (this *Chat) pushChatToPrivate(msg *pb.DBChat) (err error) { return } -//推送跨服频道消息 +// 推送跨服频道消息 func (this *Chat) pushChatToCross(msg *pb.DBChat) (err error) { var ( users []*pb.CacheUser @@ -383,7 +402,7 @@ func (this *Chat) pushChatToCross(msg *pb.DBChat) (err error) { return } -//推送系统消息 +// 推送系统消息 func (this *Chat) pushChatToSystem(msg *pb.DBChat) (err error) { data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg}) if err = this.service.ClusterBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ diff --git a/modules/hero/api_strengthenUplv.go b/modules/hero/api_strengthenUplv.go index ef0f6762c..f9721c2e5 100644 --- a/modules/hero/api_strengthenUplv.go +++ b/modules/hero/api_strengthenUplv.go @@ -7,7 +7,7 @@ import ( cfg "go_dreamfactory/sys/configure/structs" ) -//参数校验 +// 参数校验 func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (errdata *pb.ErrorData) { if req.HeroObjID == "" || len(req.Item) == 0 { errdata = &pb.ErrorData{ @@ -20,7 +20,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero return } -/// 英雄升级 +// / 英雄升级 func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (errdata *pb.ErrorData) { var ( @@ -96,7 +96,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren //英雄升级 【玩家名称】已将【英雄名称】培养至60级! if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { - this.chat.SendSysChatToWorld(comm.ChatSystem7, nil, _hero.Lv, 0, user.Name, _hero.HeroID) + this.chat.SendSysChatToWorld(comm.ChatSystem7, _hero, _hero.Lv, 0, user.Name, _hero.HeroID) } else { this.module.Errorf("no found userdata uid:%s", session.GetUserId()) }