diff --git a/comm/error.go b/comm/error.go index fea348aab..5d9914b01 100644 --- a/comm/error.go +++ b/comm/error.go @@ -30,6 +30,6 @@ func NewNotFoundConfErr(moduleName string, filename string, id interface{}) erro } //执行外部模块异常 -func NewExternalModuleErr(moduleName string, methodname string, parameter ...interface{}) error { - return fmt.Errorf("执行外部模块错误 模块:%s ,配置文件:%s,目标数据:%v", moduleName, methodname, parameter) +func NewExternalModuleErr(moduleName string, methodname string, parameter interface{}) error { + return fmt.Errorf("执行外部模块错误 模块:%s ,配置文件:%s,错误信息:%v", moduleName, methodname, parameter) } diff --git a/modules/chat/api_chanagechannel.go b/modules/chat/api_chanagechannel.go index 221e36513..47d62fd5a 100644 --- a/modules/chat/api_chanagechannel.go +++ b/modules/chat/api_chanagechannel.go @@ -22,11 +22,19 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana if err, ok = this.module.modelChat.chanageChannel(session, req.ChannelId); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if ok { if err = this.module.modelChat.removeCrossChannelMember(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{ diff --git a/modules/chat/api_crosschannel.go b/modules/chat/api_crosschannel.go index 614dd0432..69e5bbc6f 100644 --- a/modules/chat/api_crosschannel.go +++ b/modules/chat/api_crosschannel.go @@ -22,6 +22,10 @@ func (this *apiComp) CrossChannel(session comm.IUserSession, req *pb.ChatCrossCh } if channel, err = this.module.modelChat.addCrossChannelMember(session); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{ diff --git a/modules/chat/api_getlist.go b/modules/chat/api_getlist.go index c9fe29da8..1f4ad66f8 100644 --- a/modules/chat/api_getlist.go +++ b/modules/chat/api_getlist.go @@ -1,6 +1,7 @@ package chat import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" ) @@ -29,18 +30,30 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) case pb.ChatChannel_World: if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } break case pb.ChatChannel_Union: if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), req.UnionId, 0); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } break case pb.ChatChannel_Private: if list, err = this.module.modelChat.queryUserMsg(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } break @@ -48,26 +61,47 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) if result, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { this.module.Errorf("err:%v", err) code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if req.ChannelId != result.Chatchannel { code = pb.ErrorCode_ReqParameterError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("req.ChannelId:%d != result.Chatchannel:%d", req.ChannelId, result.Chatchannel), + } return } if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", req.ChannelId); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } break case pb.ChatChannel_System: if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } break default: + + this.module.Errorf("不存在的聊天频道类型channel:%d ", req.Channel) code = pb.ErrorCode_ReqParameterError - this.module.Errorf("getlist no support channel:%d ", req.Channel) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("不存在的聊天频道类型 channel:%d ", req.Channel), + } return } session.SendMsg(string(this.module.GetType()), "getlist", &pb.ChatGetListResp{Chats: list}) diff --git a/modules/chat/api_send.go b/modules/chat/api_send.go index b159f2708..b847fbcf0 100644 --- a/modules/chat/api_send.go +++ b/modules/chat/api_send.go @@ -2,6 +2,7 @@ package chat import ( "context" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/wordfilter" @@ -49,6 +50,10 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil { code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } @@ -76,16 +81,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code go this.module.modelChat.sendChatToWorld(msg, max_chat) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1) go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype62, 1)) - //随机任务 - // if _, err = this.service.AcrossClusterRpcGo( - // context.Background(), - // session.GetServiecTag(), - // comm.Service_Worker, - // string(comm.Rpc_ModuleRtaskSendTask), - // pb.RPCRTaskReq{Uid: session.GetUserId(), TaskType: int32(comm.Rtype62), Param1: 1}, - // nil); err != nil { - // this.module.Errorln(err) - // } break case pb.ChatChannel_Union: if msg.Ctype == pb.ChatType_Text { //过滤敏感词 @@ -120,8 +115,12 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype106, 1)) break default: + this.module.Errorf("不存在的聊天频道类型channel:%d ", req.Channel) code = pb.ErrorCode_ReqParameterError - this.module.Errorf("getlist no support channel:%d ", req.Channel) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("不存在的聊天频道类型 channel:%d ", req.Channel), + } return } session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true}) diff --git a/modules/chat/configure.go b/modules/chat/configure.go index 977f301d6..a03759a00 100644 --- a/modules/chat/configure.go +++ b/modules/chat/configure.go @@ -1,7 +1,7 @@ package chat import ( - "fmt" + "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" @@ -62,13 +62,15 @@ func (this *configureComp) GetAutoIntoChannelMax() (max int32, err error) { return } else { if configure, ok = v.(*cfg.GameChatChannelCom).GetDataMap()["channel_allocation_max"]; !ok { - err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_allocation_max") + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "channel_allocation_max") + // err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_allocation_max") this.module.Errorf("err:%v", err) return } max = configure.Value if max <= 0 { - err = fmt.Errorf("cfg.GamechatChannelComData channel_allocation_max:%v", v) + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "channel_allocation_max:0") + // err = fmt.Errorf("cfg.GamechatChannelComData channel_allocation_max:%v", v) } } return @@ -86,13 +88,15 @@ func (this *configureComp) GetChanageChannelMax() (max int32, err error) { return } else { if configure, ok = v.(*cfg.GameChatChannelCom).GetDataMap()["channel_switching_max"]; !ok { - err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_switching_max") + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "channel_switching_max") + // err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_switching_max") this.module.Errorf("err:%v", err) return } max = configure.Value if max <= 0 { - err = fmt.Errorf("cfg.GamechatChannelComData channel_switching_max:%v", v) + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "channel_switching_max:0") + // err = fmt.Errorf("cfg.GamechatChannelComData channel_switching_max:%v", v) } } return @@ -110,13 +114,15 @@ func (this *configureComp) GetChannelRecordMax() (max int32, err error) { return } else { if configure, ok = v.(*cfg.GameChatChannelCom).GetDataMap()["max_chat"]; !ok { - err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat") - this.module.Errorf("err:%v", err) + // err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat") + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "max_chat") + this.module.Errorln(err) return } max = configure.Value if max <= 0 { - err = fmt.Errorf("cfg.GamechatChannelComData max_chat:%v", v) + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "max_chat:0") + // err = fmt.Errorf("cfg.GamechatChannelComData max_chat:%v", v) } } return @@ -134,13 +140,15 @@ func (this *configureComp) GetChannelReadRecordNum() (max int32, err error) { return } else { if configure, ok = v.(*cfg.GameChatChannelCom).GetDataMap()["load_chat"]; !ok { - err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat") + // err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat") + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "load_chat") this.module.Errorf("err:%v", err) return } max = configure.Value if max <= 0 { - err = fmt.Errorf("cfg.GamechatChannelComData max_chat:%v", v) + // err = fmt.Errorf("cfg.GamechatChannelComData max_chat:%v", v) + err = comm.NewNotFoundConfErr(moduleName, game_chatchannelcom, "load_chat:0") } } return diff --git a/modules/chat/module.go b/modules/chat/module.go index 303ef3c7f..55fe79513 100644 --- a/modules/chat/module.go +++ b/modules/chat/module.go @@ -16,6 +16,8 @@ import ( "google.golang.org/protobuf/types/known/anypb" ) +const moduleName = "聊天" + /* 模块名:论坛 描述:处理跨服社交论坛相关业务 diff --git a/modules/combat/api_askpass.go b/modules/combat/api_askpass.go index 32981807b..e4d0f4b35 100644 --- a/modules/combat/api_askpass.go +++ b/modules/combat/api_askpass.go @@ -1,6 +1,7 @@ package combat import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -37,7 +38,12 @@ func (this *apiComp) AskPass(session comm.IUserSession, req *pb.CombatAskPassReq } if level, ok = info.Level[req.Level]; !ok { code = pb.ErrorCode_ReqParameterError - this.module.Errorf("no in Level:%s", req.Level) + err = fmt.Errorf("没有目标关卡数据 req.Level: %d", req.Level) + this.module.Errorln(err) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } @@ -46,7 +52,7 @@ func (this *apiComp) AskPass(session comm.IUserSession, req *pb.CombatAskPassReq code = pb.ErrorCode_ExternalModule data = &pb.ErrorData{ Title: code.ToString(), - Message: comm.NewExternalModuleErr("Buried", "CheckCondition", session.GetUserId(), lvconf.Maintask).Error(), + Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Maintask).Error(), } return } diff --git a/modules/combat/api_challenge.go b/modules/combat/api_challenge.go index b452fff49..b1ccaeb1f 100644 --- a/modules/combat/api_challenge.go +++ b/modules/combat/api_challenge.go @@ -39,11 +39,19 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.CombatChalleng } }() if cd = this.ChallengeCheck(session, req); cd != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: cd.ToString(), + Message: req.String(), + } return } if manster, err = this.module.configure.getGameCombatManster(req.Manster); err != nil { cd = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } cd, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{ diff --git a/modules/combat/api_challengereceive.go b/modules/combat/api_challengereceive.go index 86b50a909..15891fdbc 100644 --- a/modules/combat/api_challengereceive.go +++ b/modules/combat/api_challengereceive.go @@ -1,6 +1,7 @@ package combat import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -42,24 +43,45 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC if iswin { if info, err = this.module.modelCombat.queryInfo(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if lv, ok = info.Level[req.Level]; !ok { + err = fmt.Errorf("没有目标关卡数据 req.Level: %d", req.Level) + this.module.Errorln(err) code = pb.ErrorCode_ReqParameterError - this.module.Errorf("no in Level:%s", req.Level) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if lvconf, err = this.module.configure.getCombatLevel(req.Level); err != nil { code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if manster, err = this.module.configure.getGameCombatManster(req.Manster); err != nil { code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } for _, v := range lv.Passmanster { if v == req.Manster { code = pb.ErrorCode_ReqParameterError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("req.Manster:%d 重复", code), + } return } } @@ -67,6 +89,10 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC lv.Passmanster = append(lv.Passmanster, req.Manster) if err = this.module.modelCombat.updateInfo(info); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } @@ -82,6 +108,10 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC lv.Progress = int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), lvconf.Debrisitemid)) if err = this.module.modelCombat.updateInfo(info); err != nil { code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } } diff --git a/modules/equipment/api_ench.go b/modules/equipment/api_ench.go index 6852c3a33..6da35b6e1 100644 --- a/modules/equipment/api_ench.go +++ b/modules/equipment/api_ench.go @@ -1,6 +1,7 @@ package equipment import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" @@ -32,6 +33,10 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) ( } if conf, err = this.module.configure.getEquipenchanting(req.Itemid); err != nil { code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } need = make([]*cfg.Gameatn, 0) @@ -48,10 +53,18 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) ( if equip, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.Eid); err != nil { this.module.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), req.Eid, err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if equip.AdverbEntry[req.Index] == nil || equip.AdverbEntry[req.Index].AttrName != conf.Attrkey { code = pb.ErrorCode_ReqParameterError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: req.String(), + } return } AttrValue = rand.Int31n(conf.AttrMax-conf.AttrMini) + conf.AttrMini @@ -64,12 +77,20 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) ( }); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if equip.HeroId != "" { equipments = make([]*pb.DB_Equipment, 8) if hero, code = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), equip.HeroId); code != pb.ErrorCode_Success { this.module.Errorf("Upgrade code:%d", code) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("英雄唯一 id:%s", equip.HeroId), + } return } for i, v := range hero.EquipID { @@ -78,6 +99,10 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) ( if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("装备唯一 id:%s", v), + } return } } else { diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index cd5028c87..dd08b0a32 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -1,6 +1,7 @@ package equipment import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -35,6 +36,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) ) if code = this.EquipCheck(session, req); code != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: code.ToString(), + Message: req.String(), + } return } //校验数据 @@ -43,6 +48,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) //获取英雄数据 if hero, code = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), req.HeroCardId); code != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("获取英雄数据失败:%s", req.HeroCardId), + } return } @@ -56,6 +65,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) } if equipments[i].HeroId != "" && hero.Id != equipments[i].HeroId { //装备已经有宿主了 code = pb.ErrorCode_EquipmentIsWorn + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("装备已穿戴 装备id:%s 英雄id:%s", hero.Id, equipments[i].HeroId), + } return } if minlv > equipments[i].Lv { @@ -65,6 +78,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil { this.module.Errorf("Equip_Check err:%v", err) code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if minstr > confs[i].Star { @@ -100,6 +117,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { this.module.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } equipment.HeroId = "" @@ -109,6 +130,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { this.module.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } equipment.HeroId = "" @@ -170,40 +195,38 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) //更新装备数据加成 if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code != pb.ErrorCode_Success { this.module.Errorf("Equip ModuleHero UpdateEquipment code%v", code) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: comm.NewExternalModuleErr("ModuleHero", "UpdateEquipment", code).Error(), + } return } //同步数据 if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { this.module.Errorf("Equip err%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype5, equipNum, utils.ToInt32(hero.HeroID))) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype5, utils.ToInt32(hero.HeroID), equipNum) - // for k, v := range equipStr { - // tasks = append(tasks, comm.GetBuriedParam(comm.Rtype41, 1, v, k)) - // // this.module.ModuleRtask.SendToRtask(session, comm.Rtype41, utils.ToInt32(hero.HeroID), v, k) - // } + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype41, 1, equipNum, minstr)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype42, 1, equipNum, minlv)) - // for k, v := range equipLv { - // tasks = append(tasks, comm.GetBuriedParam(comm.Rtype42, 1, v, k)) - // // this.module.ModuleRtask.SendToRtask(session, comm.Rtype42, utils.ToInt32(hero.HeroID), v, k) - // } + if hero.SuiteId != 0 { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype46, 1, hero.Suite1Star, hero.SuiteId)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype98, 1, hero.Suite1Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype169, hero.SuiteId)) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype98, 1, hero.Suite1Lv) + } if hero.SuiteExtId != 0 { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype46, 1, hero.Suite2Star, hero.SuiteExtId)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype98, 1, hero.Suite1Lv)) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype98, 1, hero.Suite1Lv) } if len(tasks) > 0 { diff --git a/modules/equipment/api_forg.go b/modules/equipment/api_forg.go index 0851a1efb..2926e7f33 100644 --- a/modules/equipment/api_forg.go +++ b/modules/equipment/api_forg.go @@ -24,10 +24,18 @@ func (this *apiComp) Forg(session comm.IUserSession, req *pb.EquipmentForgReq) ( err error ) if code = this.ForgCheck(session, req); code != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: code.ToString(), + Message: req.String(), + } return } if conf, err = this.module.configure.GetEquipCompose(req.Forgid); err != nil { code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } need = make([]*cfg.Gameatn, len(conf.Need)) diff --git a/modules/equipment/api_getlist.go b/modules/equipment/api_getlist.go index b61780cc1..dda9522bd 100644 --- a/modules/equipment/api_getlist.go +++ b/modules/equipment/api_getlist.go @@ -20,6 +20,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.EquipmentGetList if items, err = this.module.modelEquipment.QueryUserEquipments(session.GetUserId()); err != nil { this.module.Errorf("QueryUserPackReq err:%v", err) code = pb.ErrorCode_CacheReadError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } session.SendMsg(string(this.module.GetType()), "getlist", &pb.EquipmentGetListResp{Equipments: items}) diff --git a/modules/equipment/api_lock.go b/modules/equipment/api_lock.go index 3eb100e00..556cb8091 100644 --- a/modules/equipment/api_lock.go +++ b/modules/equipment/api_lock.go @@ -25,6 +25,10 @@ func (this *apiComp) Lock(session comm.IUserSession, req *pb.EquipmentLockReq) ( if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { this.module.Errorln(err) code = pb.ErrorCode_EquipmentOnFoundEquipment + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } equipment.Islock = req.IsLock @@ -33,6 +37,10 @@ func (this *apiComp) Lock(session comm.IUserSession, req *pb.EquipmentLockReq) ( }); err != nil { this.module.Errorln(err) code = pb.ErrorCode_DBError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } session.SendMsg(string(this.module.GetType()), "lock", &pb.EquipmentLockResp{IsSucc: true, EquipmentId: req.EquipmentId, IsLock: req.IsLock}) diff --git a/modules/equipment/api_sellI.go b/modules/equipment/api_sellI.go index 87806e9d8..4a86cb9c5 100644 --- a/modules/equipment/api_sellI.go +++ b/modules/equipment/api_sellI.go @@ -1,6 +1,7 @@ package equipment import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -28,6 +29,10 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( } if equipments, err = this.module.modelEquipment.QueryUserEquipmentsByIds(session.GetUserId(), req.EquipIds); err != nil { code = pb.ErrorCode_ReqParameterError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } confs = make([]*cfg.GameEquipData, len(equipments)) @@ -36,15 +41,27 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( if v.HeroId != "" || v.Islock { code = pb.ErrorCode_EquipmentNoCanSell this.module.Errorf("NoCanSell %v", v) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("装备已锁定! 装备id:%s", v), + } return } if confs[i], err = this.module.configure.GetEquipmentConfigureById(v.CId); err != nil { this.module.Errorln(err) code = pb.ErrorCode_EquipmentOnFoundEquipment + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if confs[i].Sale == nil || len(confs[i].Sale) == 0 { code = pb.ErrorCode_EquipmentNoCanSell + data = &pb.ErrorData{ + Title: code.ToString(), + Message: fmt.Sprintf("装备出售配置为空! 装备id:%s", confs[i].Id), + } return } sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale)) diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 2c4678a82..6e6c7398a 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -38,22 +38,38 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) ) if code = this.UpgradeCheck(session, req); code != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: code.ToString(), + Message: req.String(), + } return } if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil { this.module.Errorf("Equip_Check err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if conf, err = this.module.configure.GetEquipmentConfigureById(equipment.CId); err != nil { this.module.Errorf("Equip_Check err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } //找到下一个等级的相关配置 if intensify, err = this.module.configure.GetEquipmentIntensifyConfigureById(conf.EquipId, conf.Star, equipment.Lv); err != nil || intensify.Need == nil || len(intensify.Need) == 0 { this.module.Errorf("Equip_Check err:%v", err) code = pb.ErrorCode_EquipmentLvlimitReached + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if code = this.module.ConsumeRes(session, intensify.Need, true); code != pb.ErrorCode_Success { @@ -74,6 +90,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade }); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } } @@ -89,6 +109,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade }); err != nil { this.module.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } modifyequipments = append(modifyequipments, equipment) @@ -99,12 +123,20 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade modifyequipments = append(modifyequipments, equipment) if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil { code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } this.module.Errorf("Upgrade err:%v", err) return } if err = this.module.modelEquipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil { this.module.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } } else { @@ -113,6 +145,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil { code = pb.ErrorCode_SystemError this.module.Errorf("Upgrade err:%v", err) + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{ @@ -125,6 +161,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade }); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } } @@ -134,11 +174,17 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade if equipment.HeroId != "" { if hero, code = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), equipment.HeroId); code != pb.ErrorCode_Success { this.module.Errorf("Upgrade code:%d", code) + data = &pb.ErrorData{ + Title: code.ToString(), + } return } if conf.Pos >= 8 { code = pb.ErrorCode_ConfigurationException this.module.Errorf("Upgrade equipment Pos:%d", conf.Pos) + data = &pb.ErrorData{ + Title: code.ToString(), + } return } hero.EquipID[conf.Pos] = equipment.Id //拆分后的装备是一个新的 @@ -182,32 +228,21 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade } //随机任务触发 tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype43, equipment.Id, equipment.Lv)) - // tasks = append(tasks, comm.GetBuriedParam(comm.Rtype44, 1, equipment.Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype47, 1)) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype43, 1, equipment.Lv) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype44, equipment.Lv) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype47, 1) + if conf.Pos == 7 { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype102, 1)) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype102, 1) } else if conf.Pos == 6 { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype100, 1)) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype100, 1) } //聊天系统通知 if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { - // var color *cfg.GameGameColorData - // if color, err = this.module.configure.GetColor(conf.Color); err == nil { this.module.chat.SendSysChatToWorld(comm.ChatSystem3, equipment, equipment.Lv, 0, user.Name, conf.Id) - // } else { - // this.module.Errorf("GetColor err:%s", err.Error()) - // } } else { this.module.Errorf("no found userdata uid:%s", session.GetUserId()) } } else { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype96, 1)) - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype96, 1) } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype92, 1)) if len(tasks) > 0 { diff --git a/modules/equipment/api_wash.go b/modules/equipment/api_wash.go index e2aef7d92..d7455572f 100644 --- a/modules/equipment/api_wash.go +++ b/modules/equipment/api_wash.go @@ -26,16 +26,28 @@ func (this *apiComp) Wash(session comm.IUserSession, req *pb.EquipmentWashReq) ( err error ) if code = this.WashCheck(session, req); code != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: code.ToString(), + Message: req.String(), + } return } if equip, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.Eid); err != nil { this.module.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), req.Eid, err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if conf, err = this.module.configure.GetEquipmentConfigureById(equip.CId); err != nil { this.module.Errorf("Equip_Check err:%v", err) code = pb.ErrorCode_ConfigNoFound + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } gole := this.module.ModuleTools.GetGlobalConf().EquipmentConsumption[conf.Color-1] diff --git a/modules/equipment/api_washconfirm.go b/modules/equipment/api_washconfirm.go index cf499e0a7..5155f31d8 100644 --- a/modules/equipment/api_washconfirm.go +++ b/modules/equipment/api_washconfirm.go @@ -23,20 +23,36 @@ func (this *apiComp) WashConfirm(session comm.IUserSession, req *pb.EquipmentWas err error ) if code = this.WashConfirmCheck(session, req); code != pb.ErrorCode_Success { + data = &pb.ErrorData{ + Title: code.ToString(), + Message: req.String(), + } return } if equip, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.Eid); err != nil { this.module.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), req.Eid, err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } if len(equip.AdverbEntry) != len(req.Pids) { code = pb.ErrorCode_ReqParameterError + data = &pb.ErrorData{ + Title: code.ToString(), + } return } for i, v := range equip.AdverbEntry { if attrlibrary, err = this.module.configure.GetEquipmentAttrlibraryConfigureByKey(req.Pids[i]); err != nil { + code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } equip.AdverbEntry[i] = &pb.EquipmentAttributeEntry{ @@ -53,6 +69,10 @@ func (this *apiComp) WashConfirm(session comm.IUserSession, req *pb.EquipmentWas }); err != nil { log.Errorf("Upgrade err:%v", err) code = pb.ErrorCode_SystemError + data = &pb.ErrorData{ + Title: code.ToString(), + Message: err.Error(), + } return } session.SendMsg(string(this.module.GetType()), "washconfirm", &pb.EquipmentWashConfirmResp{Issucc: true}) diff --git a/modules/equipment/configure.go b/modules/equipment/configure.go index ca52f20bd..15335e25f 100644 --- a/modules/equipment/configure.go +++ b/modules/equipment/configure.go @@ -2,6 +2,7 @@ package equipment import ( "fmt" + "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" @@ -122,9 +123,7 @@ func (this *configureComp) GetEquipmentConfigureByIds(equipmentId []string) (con this.module.Errorf("err:%v", err) return } else { - configure = make([]*cfg.GameEquipData, len(equipmentId)) - for i, v := range equipmentId { if c, ok = t.(*cfg.GameEquip).GetDataMap()[v]; ok { configure[i] = c @@ -165,8 +164,8 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (con return } else { if configure, ok = v.(*cfg.GameEquipAttrlibraryS).GetDataMap()[key]; !ok { - - err = fmt.Errorf("EquipmentConfigure GetEquipmentAttrlibraryConfigureByKey not found:%d ", key) + err = comm.NewNotFoundConfErr(moduleName, equip_attrlibrary, key) + // err = fmt.Errorf("EquipmentConfigure GetEquipmentAttrlibraryConfigureByKey not found:%d ", key) this.module.Errorf("err:%v", err) return } @@ -270,7 +269,8 @@ func (this *configureComp) getEquipAttribute(sid string) (result *cfg.GameEquipA return } else { if result, ok = v.(*cfg.GameEquipAttribute).GetDataMap()[sid]; !ok { - err = fmt.Errorf("on found getEquipAttribute id:%s", sid) + // err = fmt.Errorf("on found getEquipAttribute id:%s", sid) + err = comm.NewNotFoundConfErr(moduleName, equip_attrlibrary, sid) this.module.Errorf("err:%v", err) return } @@ -289,7 +289,8 @@ func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipE return } else { if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok { - err = fmt.Errorf("on found getEquipenchanting id:%s", id) + err = comm.NewNotFoundConfErr(moduleName, equip_attrlibrary, id) + // err = fmt.Errorf("on found getEquipenchanting id:%s", id) return } } @@ -307,7 +308,8 @@ func (this *configureComp) getSellcoefficient(id int32) (result *cfg.GameSellCoe return } else { if result, ok = v.(*cfg.GameSellCoefficient).GetDataMap()[id]; !ok { - err = fmt.Errorf("on found getSellcoefficient id:%d", id) + err = comm.NewNotFoundConfErr(moduleName, equip_attrlibrary, id) + // err = fmt.Errorf("on found getSellcoefficient id:%d", id) return } } diff --git a/modules/equipment/module.go b/modules/equipment/module.go index 6713cd8ce..7024f7f48 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -14,6 +14,8 @@ import ( "github.com/go-redis/redis/v8" ) +const moduleName = "装备" + /* 模块名:装备 描述:用户装备管理以及装备升级强化相关