From 3c343fb999dc4fb0f0ca7444cf6c92158297372f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 14 Feb 2023 10:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=81=E5=8C=A0=E9=93=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/smithyv2/api_createorder.go | 7 ++----- modules/smithyv2/api_deskskilllv.go | 6 +----- modules/smithyv2/api_getReward.go | 9 ++++----- modules/smithyv2/api_getlist.go | 14 +++++--------- modules/smithyv2/api_stoveskilllv.go | 11 +++++------ modules/smithyv2/model_smithy.go | 16 +++++++--------- modules/smithyv2/module.go | 2 +- 7 files changed, 25 insertions(+), 40 deletions(-) diff --git a/modules/smithyv2/api_createorder.go b/modules/smithyv2/api_createorder.go index c315ba6b8..652e9ba70 100644 --- a/modules/smithyv2/api_createorder.go +++ b/modules/smithyv2/api_createorder.go @@ -23,17 +23,14 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate res []*cfg.Gameatn costTime int32 privilegeAddItme int32 // 特权额外增加的时间 + _smithy *pb.DBSmithy ) code = this.CreateOrderCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } - _smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } + _skillCfg := this.module.configure.GetSmithyStoveConfigData(_smithy.StoveLv) needTime := _skillCfg.Time // 订单需要的时间 for _, order := range req.Order { diff --git a/modules/smithyv2/api_deskskilllv.go b/modules/smithyv2/api_deskskilllv.go index 4e185f2ba..2942405f3 100644 --- a/modules/smithyv2/api_deskskilllv.go +++ b/modules/smithyv2/api_deskskilllv.go @@ -22,16 +22,12 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk var ( bFindSkill bool curSkillCfg *cfg.GameSmithyData + _smithy *pb.DBSmithy ) code = this.DeskSkillLvCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } - _smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } for k, v := range _smithy.Skill { if k == req.DeskType { diff --git a/modules/smithyv2/api_getReward.go b/modules/smithyv2/api_getReward.go index 474ce7f9a..8981ae4ed 100644 --- a/modules/smithyv2/api_getReward.go +++ b/modules/smithyv2/api_getReward.go @@ -16,12 +16,11 @@ func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.SmithyGet ///美食城领取奖励 func (this *apiComp) GetReward(session comm.IUserSession, req *pb.SmithyGetRewardReq) (code pb.ErrorCode, data proto.Message) { + var ( + _gourmet *pb.DBSmithy + ) code = this.GetRewardCheck(session, req) - _gourmet, err := this.module.modelSmithy.getSmithyList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } + if len(_gourmet.Items) > 0 { res := make([]*cfg.Gameatn, 0) for _, v := range _gourmet.Items { diff --git a/modules/smithyv2/api_getlist.go b/modules/smithyv2/api_getlist.go index f95832ef1..177223f8f 100644 --- a/modules/smithyv2/api_getlist.go +++ b/modules/smithyv2/api_getlist.go @@ -8,27 +8,23 @@ import ( ) //参数校验 -func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.SmithyGetListReq) (code pb.ErrorCode) { +func (this *apiComp) GetStoveInfoCheck(session comm.IUserSession, req *pb.SmithyGetStoveInfoReq) (code pb.ErrorCode) { return } ///获取美食城基本信息 -func (this *apiComp) GetList(session comm.IUserSession, req *pb.SmithyGetListReq) (code pb.ErrorCode, data proto.Message) { +func (this *apiComp) GetStoveInfo(session comm.IUserSession, req *pb.SmithyGetStoveInfoReq) (code pb.ErrorCode, data proto.Message) { - code = this.GetListCheck(session, req) + code = this.GetStoveInfoCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } - _smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId()) + _smithy, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId()) if err != nil { code = pb.ErrorCode_DBError return } - // 计算订单信息 - this.module.modelSmithy.CalculationSmithy(session.GetUserId(), _smithy) - session.SendMsg(string(this.module.GetType()), SmithyGetListResp, &pb.SmithyGetListResp{Data: _smithy}) - - this.module.ModuleRtask.SendToRtask(session, comm.Rtype137, _smithy.TotalTime) + session.SendMsg(string(this.module.GetType()), "getstoveinfo", &pb.SmithyGetStoveInfoResp{Data: _smithy}) return } diff --git a/modules/smithyv2/api_stoveskilllv.go b/modules/smithyv2/api_stoveskilllv.go index 90254df9f..285b3693d 100644 --- a/modules/smithyv2/api_stoveskilllv.go +++ b/modules/smithyv2/api_stoveskilllv.go @@ -16,16 +16,15 @@ func (this *apiComp) StoveSkillLvCheck(session comm.IUserSession, req *pb.Smithy } func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode, dat proto.Message) { - var bLevelUp bool + var ( + bLevelUp bool + _smithy *pb.DBSmithy + ) code = this.StoveSkillLvCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } - _smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } + curLvData := this.module.configure.GetSmithyStoveConfigData(_smithy.StoveLv) if curLvData == nil { code = pb.ErrorCode_GourmetSkillMaxLv diff --git a/modules/smithyv2/model_smithy.go b/modules/smithyv2/model_smithy.go index 728863f21..4328c3be4 100644 --- a/modules/smithyv2/model_smithy.go +++ b/modules/smithyv2/model_smithy.go @@ -31,21 +31,19 @@ func (this *modelSmithy) Init(service core.IService, module core.IModule, comp c } // 获取铁匠铺信息 -func (this *modelSmithy) getSmithyList(uid string) (result *pb.DBSmithy, err error) { - result = &pb.DBSmithy{} +func (this *modelSmithy) getSmithyStoveList(uid string) (result *pb.DBStove, err error) { + result = &pb.DBStove{} if err = this.Get(uid, result); err != nil { if redis.RedisNil != err { // 没有数据直接创建新的数据 result.Id = primitive.NewObjectID().Hex() result.Uid = uid + result.Data = make(map[int32]int32, 0) result.Skill = make(map[int32]int32, 0) - result.StoveLv = 1 // storv 等级默认1级 - result.DeskFloor = make(map[int32]int32, 0) - mapType := this.module.configure.GetSmithyTypeConfigData() // 找类型 - for key := range mapType { - result.Skill[key] = 1 - result.DeskFloor[key] = 0 - } + result.Lv = 1 + result.Temperature = 20000 // 配置 + result.Business = 0 + result.RecoveTime = 0 if err = this.Add(uid, result); err != nil { this.module.Errorf("err:%v", err) diff --git a/modules/smithyv2/module.go b/modules/smithyv2/module.go index 1bcebeaaf..c6cc7c76b 100644 --- a/modules/smithyv2/module.go +++ b/modules/smithyv2/module.go @@ -1,6 +1,6 @@ /* 模块名:Smithy -描述:美食家模块 +描述:铁匠铺模块 开发:梅雄风 */ package smithy