铁匠铺

This commit is contained in:
meixiongfeng 2023-02-14 10:43:43 +08:00
parent 1783ca780b
commit 3c343fb999
7 changed files with 25 additions and 40 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}

View File

@ -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

View File

@ -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)

View File

@ -1,6 +1,6 @@
/*
模块名:Smithy
描述:美食家模块
描述:铁匠铺模块
开发:梅雄风
*/
package smithy