增加英雄羁绊经验

This commit is contained in:
meixiongfeng 2022-10-12 10:49:20 +08:00
parent 6596eb7290
commit 2ee66ded5a
2 changed files with 48 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
const ( const (
LibraryGetListResp = "getlist" LibraryGetListResp = "getlist"
LibraryUseGiftResp = "usegift"
LibraryGetFetterListResp = "getfetterlist" LibraryGetFetterListResp = "getfetterlist"
LibraryChallengeResp = "challenge" LibraryChallengeResp = "challenge"
LibrarySkillLvResp = "skilllv" LibrarySkillLvResp = "skilllv"

View File

@ -0,0 +1,47 @@
package library
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) UseGiftCheck(session comm.IUserSession, req *pb.LibraryUseGiftReq) (code pb.ErrorCode) {
if req.Heroid == "" || len(req.Items) == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftReq) (code pb.ErrorCode, data proto.Message) {
var (
res []*cfg.Gameatn
)
code = this.UseGiftCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
rsp := &pb.LibraryUseGiftResp{}
_heroObj := this.module.modelFetter.getOneHeroFetter(session.GetUserId(), req.Heroid)
if _heroObj == nil {
code = pb.ErrorCode_HeroNoExist // 没找到对应的英雄信息
return
}
for k, v := range req.Items { // 校验数量
res = append(res, &cfg.Gameatn{
A: "item",
T: k,
N: v,
})
}
if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回
return
}
session.SendMsg(string(this.module.GetType()), LibraryUseGiftResp, rsp)
return
}