99 lines
2.5 KiB
Go
99 lines
2.5 KiB
Go
package pagoda
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) PassCheckCheck(session comm.IUserSession, req *pb.PagodaPassCheckReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
// 战令领取
|
|
func (this *apiComp) PassCheck(session comm.IUserSession, req *pb.PagodaPassCheckReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
list *pb.DBPagoda
|
|
resCfg []*cfg.Gameatn
|
|
res []*pb.UserAssets
|
|
vip bool // 是否有特权
|
|
resID []int32 // 当前可领取的id
|
|
vipID []int32 // 有vip的情况 可领取的id
|
|
mapData map[string]interface{}
|
|
)
|
|
mapData = make(map[string]interface{}, 0)
|
|
this.PassCheckCheck(session, req)
|
|
|
|
list, _ = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
|
if list.Id == "" {
|
|
code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到
|
|
return
|
|
}
|
|
if list.PagodaId <= list.PassCheckID { // 层数校验
|
|
code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到
|
|
return
|
|
}
|
|
|
|
payPoint := this.module.configure.GetPassCheckPointByTtype(1)
|
|
if payPoint != "" {
|
|
// 获取特权信息
|
|
if privilege := this.module.ModulePrivilege.CheckPrivilege(session, payPoint); privilege != nil {
|
|
vip = true
|
|
}
|
|
}
|
|
conf := this.module.configure.GetPassCheckByTtype(1)
|
|
|
|
for pos, v := range conf {
|
|
if int32(pos) <= list.PassCheckID {
|
|
continue
|
|
}
|
|
if v.Parameter >= list.PagodaId {
|
|
resID = append(resID, v.Id)
|
|
mapData["passCheckID"] = v.Parameter
|
|
}
|
|
}
|
|
if vip {
|
|
for pos, v := range conf {
|
|
if int32(pos) <= list.VipPassCheckID {
|
|
continue
|
|
}
|
|
if v.Parameter >= list.PagodaId {
|
|
vipID = append(vipID, v.Id)
|
|
mapData["vipPassCheckID"] = v.Parameter
|
|
}
|
|
}
|
|
}
|
|
for _, v := range resID {
|
|
if confCheck := this.module.configure.GetPassCheckByID(v); conf != nil {
|
|
resCfg = append(resCfg, confCheck.FreeReward)
|
|
|
|
}
|
|
}
|
|
for _, v := range vipID {
|
|
if confCheck := this.module.configure.GetPassCheckByID(v); conf != nil {
|
|
resCfg = append(resCfg, confCheck.PayReward)
|
|
}
|
|
}
|
|
if code = this.module.DispenseRes(session, resCfg, true); code != pb.ErrorCode_Success { // 发放奖励
|
|
return
|
|
}
|
|
// 转成协议格式
|
|
for _, v := range resCfg {
|
|
res = append(res, &pb.UserAssets{
|
|
A: v.A,
|
|
T: v.T,
|
|
N: v.N,
|
|
})
|
|
}
|
|
code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData)
|
|
session.SendMsg(string(this.module.GetType()), PagodaPassCheckResp, &pb.PagodaPassCheckResp{
|
|
Data: list,
|
|
Itmes: res,
|
|
})
|
|
return
|
|
}
|