go_dreamfactory/modules/library/api_activationfetter.go

61 lines
1.6 KiB
Go

package library
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) ActivationFetterCheck(session comm.IUserSession, req *pb.LibraryActivationFetterReq) (code pb.ErrorCode) {
if req.Oid == "" {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) ActivationFetter(session comm.IUserSession, req *pb.LibraryActivationFetterReq) (code pb.ErrorCode, data proto.Message) {
code = this.ActivationFetterCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
rsp := &pb.LibraryActivationFetterResp{}
defer session.SendMsg(string(this.module.GetType()), LibraryActivationFetterResp, rsp)
fetter := this.module.modelLibrary.getOneLibrary(session.GetUserId(), req.Oid)
if fetter == nil {
code = pb.ErrorCode_LibraryNoData
return
}
if fetter.Activation {
code = pb.ErrorCode_LibraryActivation
return
}
fetter.Activation = true
mapData := make(map[string]interface{}, 0)
mapData["activation"] = fetter.Activation
// 激活的时候算一下 当前羁绊等级
list := this.module.modelFetter.getHeroFetterList(session.GetUserId())
conf := this.configure.GetLibraryFetter(fetter.Fid, 1)
var minLv int32
for _, v1 := range conf.Hid {
for _, v := range list {
if v.Heroid == v1 {
if minLv == 0 {
minLv = v.Favorlv
}
if minLv > v.Favorlv {
minLv = v.Favorlv
}
break
}
}
}
fetter.Fetterlv = minLv
mapData["fetterlv"] = fetter.Fetterlv
this.module.modelLibrary.modifyLibraryDataByObjId(session.GetUserId(), fetter.Id, mapData)
rsp.Data = fetter
return
}