56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package smithy
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) AtlasAwardCheck(session comm.IUserSession, req *pb.SmithyAtlasAwardReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
// 获取铁匠铺图鉴信息
|
|
func (this *apiComp) AtlasAward(session comm.IUserSession, req *pb.SmithyAtlasAwardReq) (code pb.ErrorCode, data proto.Message) {
|
|
|
|
code = this.AtlasAwardCheck(session, req)
|
|
if code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
atlas, err := this.module.modelAtlas.getSmithyAtlasList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
conf := this.module.configure.GetSmithyAtlasLvConf(atlas.Award)
|
|
if conf == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
nexLv := this.module.configure.GetSmithyAtlasLvConf(atlas.Award + 1)
|
|
if nexLv == nil { //满级
|
|
code = pb.ErrorCode_SmithyAtlasMaxLv
|
|
return
|
|
}
|
|
// 校验能否领取奖励
|
|
if atlas.Score < nexLv.AtlasLv {
|
|
code = pb.ErrorCode_SmithyAtlasLackLv
|
|
return
|
|
}
|
|
if code = this.module.DispenseRes(session, conf.ItemId, true); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
//修改数据
|
|
atlas.Award += 1
|
|
update := make(map[string]interface{}, 0)
|
|
update["award"] = atlas.Award
|
|
this.module.modelAtlas.modifySmithyAtlasList(session.GetUserId(), update)
|
|
|
|
session.SendMsg(string(this.module.GetType()), "atlasaward", &pb.SmithyAtlasAwardResp{Data: atlas})
|
|
return
|
|
}
|