铁匠铺
This commit is contained in:
parent
1783ca780b
commit
3c343fb999
@ -23,17 +23,14 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
|
|||||||
res []*cfg.Gameatn
|
res []*cfg.Gameatn
|
||||||
costTime int32
|
costTime int32
|
||||||
privilegeAddItme int32 // 特权额外增加的时间
|
privilegeAddItme int32 // 特权额外增加的时间
|
||||||
|
_smithy *pb.DBSmithy
|
||||||
)
|
)
|
||||||
|
|
||||||
code = this.CreateOrderCheck(session, req)
|
code = this.CreateOrderCheck(session, req)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
_smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId())
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_skillCfg := this.module.configure.GetSmithyStoveConfigData(_smithy.StoveLv)
|
_skillCfg := this.module.configure.GetSmithyStoveConfigData(_smithy.StoveLv)
|
||||||
needTime := _skillCfg.Time // 订单需要的时间
|
needTime := _skillCfg.Time // 订单需要的时间
|
||||||
for _, order := range req.Order {
|
for _, order := range req.Order {
|
||||||
|
@ -22,16 +22,12 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk
|
|||||||
var (
|
var (
|
||||||
bFindSkill bool
|
bFindSkill bool
|
||||||
curSkillCfg *cfg.GameSmithyData
|
curSkillCfg *cfg.GameSmithyData
|
||||||
|
_smithy *pb.DBSmithy
|
||||||
)
|
)
|
||||||
code = this.DeskSkillLvCheck(session, req)
|
code = this.DeskSkillLvCheck(session, req)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
_smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId())
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range _smithy.Skill {
|
for k, v := range _smithy.Skill {
|
||||||
if k == req.DeskType {
|
if k == req.DeskType {
|
||||||
|
@ -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) {
|
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)
|
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 {
|
if len(_gourmet.Items) > 0 {
|
||||||
res := make([]*cfg.Gameatn, 0)
|
res := make([]*cfg.Gameatn, 0)
|
||||||
for _, v := range _gourmet.Items {
|
for _, v := range _gourmet.Items {
|
||||||
|
@ -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
|
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 {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
_smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId())
|
_smithy, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 计算订单信息
|
session.SendMsg(string(this.module.GetType()), "getstoveinfo", &pb.SmithyGetStoveInfoResp{Data: _smithy})
|
||||||
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)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
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)
|
code = this.StoveSkillLvCheck(session, req)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
_smithy, err := this.module.modelSmithy.getSmithyList(session.GetUserId())
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
curLvData := this.module.configure.GetSmithyStoveConfigData(_smithy.StoveLv)
|
curLvData := this.module.configure.GetSmithyStoveConfigData(_smithy.StoveLv)
|
||||||
if curLvData == nil {
|
if curLvData == nil {
|
||||||
code = pb.ErrorCode_GourmetSkillMaxLv
|
code = pb.ErrorCode_GourmetSkillMaxLv
|
||||||
|
@ -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) {
|
func (this *modelSmithy) getSmithyStoveList(uid string) (result *pb.DBStove, err error) {
|
||||||
result = &pb.DBSmithy{}
|
result = &pb.DBStove{}
|
||||||
if err = this.Get(uid, result); err != nil {
|
if err = this.Get(uid, result); err != nil {
|
||||||
if redis.RedisNil != err { // 没有数据直接创建新的数据
|
if redis.RedisNil != err { // 没有数据直接创建新的数据
|
||||||
|
|
||||||
result.Id = primitive.NewObjectID().Hex()
|
result.Id = primitive.NewObjectID().Hex()
|
||||||
result.Uid = uid
|
result.Uid = uid
|
||||||
|
result.Data = make(map[int32]int32, 0)
|
||||||
result.Skill = make(map[int32]int32, 0)
|
result.Skill = make(map[int32]int32, 0)
|
||||||
result.StoveLv = 1 // storv 等级默认1级
|
result.Lv = 1
|
||||||
result.DeskFloor = make(map[int32]int32, 0)
|
result.Temperature = 20000 // 配置
|
||||||
mapType := this.module.configure.GetSmithyTypeConfigData() // 找类型
|
result.Business = 0
|
||||||
for key := range mapType {
|
result.RecoveTime = 0
|
||||||
result.Skill[key] = 1
|
|
||||||
result.DeskFloor[key] = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = this.Add(uid, result); err != nil {
|
if err = this.Add(uid, result); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
模块名:Smithy
|
模块名:Smithy
|
||||||
描述:美食家模块
|
描述:铁匠铺模块
|
||||||
开发:梅雄风
|
开发:梅雄风
|
||||||
*/
|
*/
|
||||||
package smithy
|
package smithy
|
||||||
|
Loading…
Reference in New Issue
Block a user