go_dreamfactory/modules/library/api_getstoryreward.go

53 lines
1.2 KiB
Go

package library
/*
* 单个英雄剧情id 奖励
*/
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) GetStoryRewardCheck(session comm.IUserSession, req *pb.LibraryGetStoryRewardReq) (code pb.ErrorCode) {
if req.Hid == "" || req.StoryId == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) GetStoryReward(session comm.IUserSession, req *pb.LibraryGetStoryRewardReq) (code pb.ErrorCode, data proto.Message) {
code = this.GetStoryRewardCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
conf := this.module.configure.GetLibraryHero(req.Hid)
for k, v := range expand.Tujian {
if k == req.Hid && conf.Rightend == v {
code = this.module.DispenseRes(session, conf.Stroyprize, true)
// 修改storyID
sz := make(map[string]interface{}, 0)
for k, v := range expand.Tujian {
sz[k] = v
}
sz[req.Hid] = conf.Rightend
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), sz)
break
}
}
return
}