From 42f616864498d99588f60809383ce4cc0c3c7833 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 5 Jul 2022 12:03:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 2 +- modules/hero/api_awaken.go | 18 +++++++----------- modules/hero/api_resonance.go | 14 ++++++++------ modules/mail/model_mail.go | 8 ++++---- modules/modulebase.go | 6 +++--- pb/errorcode.pb.go | 20 ++++++++++++-------- pb/proto/errorcode.proto | 3 ++- 7 files changed, 37 insertions(+), 34 deletions(-) diff --git a/comm/core.go b/comm/core.go index a17361a21..56dfb2462 100644 --- a/comm/core.go +++ b/comm/core.go @@ -25,7 +25,7 @@ type ISC_GateRouteComp interface { const ( AttrType = "attr" //用户属性资源 例如货币 经验 之类的 ItemType = "item" //道具物品资源 - CardType = "card" //卡片资源 例如英雄卡,检验卡 + HeroType = "hero" //卡片资源 例如英雄卡,检验卡 EquipmentType = "equi" //武器资源 ) diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index 189e35edd..e88cddf5b 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -26,16 +26,16 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c awakenData *cfg.Game_heroAwakenData ) _hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) - - if err != pb.ErrorCode_Success { - code = pb.ErrorCode_HeroNoExist - return - } defer func() { if code == pb.ErrorCode_Success { session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero}) } }() + if err != pb.ErrorCode_Success { + code = pb.ErrorCode_HeroNoExist + return + } + code = this.AwakenCheck(session, req) // check if code != pb.ErrorCode_Success { return @@ -52,15 +52,11 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c } } if awakenData == nil { - code = pb.ErrorCode_ConfigNoFound + code = pb.ErrorCode_HeroMaxAwaken // 达到最大觉醒等级 return } - if _hero == nil || awakenData == nil { - code = pb.ErrorCode_HeroNoExist - return - } - if len(awakenData.Phasebonus) < 2 { + if len(awakenData.Phasebonus) < 2 { // 配置校验 code = pb.ErrorCode_ConfigNoFound return } diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index 8c60c10f0..9747a1c38 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -22,14 +22,15 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceReq) (code pb.ErrorCode, data proto.Message) { _hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 - if code != pb.ErrorCode_Success { - return - } defer func() { if code == pb.ErrorCode_Success { session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero}) } }() + if code != pb.ErrorCode_Success { + return + } + code = this.ResonanceCheck(session, req) // check if code != pb.ErrorCode_Success { return @@ -48,14 +49,14 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR code = pb.ErrorCode_ConfigNoFound return } - if resonConfig.Maxnum >= _hero.ResonateNum { + if resonConfig.Maxnum <= _hero.ResonateNum { code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满 return } // 消耗英雄的配置id for _, v := range resonConfig.Need { - if v.A == "hero" && v.T == strconv.Itoa(int(_costHero.HeroID)) { + if v.A == comm.HeroType && v.T == strconv.Itoa(int(_costHero.HeroID)) { if req.Amount != v.N { code = pb.ErrorCode_HeroNoEnough // 消耗数量不对应 return @@ -81,7 +82,8 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR } _heroMap := map[string]interface{}{ - "resonateNum": _hero.ResonateNum + resonConfig.Energy, + "resonateNum": _hero.ResonateNum + 1, + "distributionResonate": _hero.DistributionResonate + resonConfig.Energy, } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { diff --git a/modules/mail/model_mail.go b/modules/mail/model_mail.go index 55f2862e1..cbbbfe709 100644 --- a/modules/mail/model_mail.go +++ b/modules/mail/model_mail.go @@ -77,11 +77,11 @@ func (this *modelMail) Mail_ReadOneMail(objId string) (mail *pb.DBMailData, err // 查询附件信息 func (this *modelMail) Mail_GetMailAttachment(objId string) (itmes []*pb.UserAssets, err error) { - obj := this.DB.FindOne(DB_MailTable, bson.M{"_id": objId}) var nd *pb.DBMailData - err = obj.Decode(&nd) - itmes = nd.GetItems() - + err = this.DB.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(&nd) + if err == nil { + itmes = nd.GetItems() + } return itmes, err } diff --git a/modules/modulebase.go b/modules/modulebase.go index 0504579fc..8b7173d48 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -152,7 +152,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p code = pb.ErrorCode_ResNoEnough return } - } else if v.A == comm.CardType { //卡片资源 + } else if v.A == comm.HeroType { //卡片资源 if resID, err = strconv.Atoi(v.T); err != nil { code = pb.ErrorCode_ConfigurationException return @@ -181,7 +181,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p } else if v.A == comm.ItemType { //道具资源 resID, _ = strconv.Atoi(v.T) this.ModuleItems.AddItem(source, uid, int32(resID), -1*v.N) - } else if v.A == comm.CardType { //卡片资源 + } else if v.A == comm.HeroType { //卡片资源 resID, _ = strconv.Atoi(v.T) this.ModuleHero.ConsumeCard(uid, int32(resID), -1*v.N) } @@ -210,7 +210,7 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn) (code pb.Er } else if v.A == comm.ItemType { //道具资源 resID, _ = strconv.Atoi(v.T) this.ModuleItems.AddItem(source, uid, int32(resID), v.N) - } else if v.A == comm.CardType { //卡片资源 + } else if v.A == comm.HeroType { //卡片资源 resID, _ = strconv.Atoi(v.T) this.ModuleHero.ConsumeCard(uid, int32(resID), v.N) } else if v.A == comm.EquipmentType { diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 7cf712da2..d0a4bea73 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -80,7 +80,8 @@ const ( ErrorCode_HeroNotNeedResonate ErrorCode = 1308 // 不需要重置共鸣 ErrorCode_HeroNoEnergy ErrorCode = 1309 // 没有能量点数 ErrorCode_HeroCreate ErrorCode = 1310 // 创建卡失败 - ErrorCode_HeroEquipUpdate ErrorCode = 1311 //更新装备失败 + ErrorCode_HeroEquipUpdate ErrorCode = 1311 // 更新装备失败 + ErrorCode_HeroMaxAwaken ErrorCode = 1312 // 达到最大觉醒等级 // equipment ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限 @@ -143,6 +144,7 @@ var ( 1309: "HeroNoEnergy", 1310: "HeroCreate", 1311: "HeroEquipUpdate", + 1312: "HeroMaxAwaken", 1400: "EquipmentOnFoundEquipment", 1401: "EquipmentLvlimitReached", } @@ -201,6 +203,7 @@ var ( "HeroNoEnergy": 1309, "HeroCreate": 1310, "HeroEquipUpdate": 1311, + "HeroMaxAwaken": 1312, "EquipmentOnFoundEquipment": 1400, "EquipmentLvlimitReached": 1401, } @@ -237,7 +240,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0x98, 0x09, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xac, 0x09, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -306,12 +309,13 @@ var file_errorcode_proto_rawDesc = []byte{ 0x65, 0x10, 0x9c, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x10, 0x9d, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x10, 0x9e, 0x0a, 0x12, 0x14, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f, - 0x45, 0x71, 0x75, 0x69, 0x70, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x9f, 0x0a, 0x12, 0x1e, - 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, - 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, - 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, - 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x45, 0x71, 0x75, 0x69, 0x70, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x9f, 0x0a, 0x12, 0x12, + 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x41, 0x77, 0x61, 0x6b, 0x65, 0x6e, 0x10, + 0xa0, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, + 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, + 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, + 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, + 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index d6d66b4f3..4ff16f90f 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -63,7 +63,8 @@ enum ErrorCode { HeroNotNeedResonate = 1308; // 不需要重置共鸣 HeroNoEnergy = 1309; // 没有能量点数 HeroCreate = 1310; // 创建卡失败 - HeroEquipUpdate = 1311; //更新装备失败 + HeroEquipUpdate = 1311; // 更新装备失败 + HeroMaxAwaken = 1312; // 达到最大觉醒等级 // equipment EquipmentOnFoundEquipment = 1400; // 未找到武器