增加英雄羁绊经验
This commit is contained in:
parent
6596eb7290
commit
2ee66ded5a
@ -7,6 +7,7 @@ import (
|
||||
|
||||
const (
|
||||
LibraryGetListResp = "getlist"
|
||||
LibraryUseGiftResp = "usegift"
|
||||
LibraryGetFetterListResp = "getfetterlist"
|
||||
LibraryChallengeResp = "challenge"
|
||||
LibrarySkillLvResp = "skilllv"
|
||||
|
47
modules/library/api_usegift.go
Normal file
47
modules/library/api_usegift.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user