爬塔奖励领取
This commit is contained in:
parent
8e44899d3c
commit
bb24e0943b
@ -3,6 +3,7 @@ package pagoda
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
@ -19,57 +20,67 @@ func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.PagodaGet
|
|||||||
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.PagodaGetRewardReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.PagodaGetRewardReq) (errdata *pb.ErrorData) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
atno []*pb.UserAtno
|
atno []*pb.UserAtno
|
||||||
|
pagoda *pb.DBPagoda
|
||||||
|
err error
|
||||||
|
_cfg *cfg.GamePagodaTaskRewardData
|
||||||
)
|
)
|
||||||
if errdata = this.GetRewardCheck(session, req); errdata != nil {
|
if errdata = this.GetRewardCheck(session, req); errdata != nil {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
if pagoda, err := this.module.modelPagoda.getPagodaList(session.GetUserId()); err != nil {
|
if pagoda, err = this.module.modelPagoda.getPagodaList(session.GetUserId()); err != nil {
|
||||||
_cfg, err := this.module.configure.GetPagodaRewardconfig(req.Id)
|
errdata = &pb.ErrorData{
|
||||||
if err != nil {
|
Code: pb.ErrorCode_DBError,
|
||||||
errdata = &pb.ErrorData{
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
Message: err.Error(),
|
||||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// 校验是否能领取
|
return
|
||||||
if _cfg.LayerNum > pagoda.PagodaId {
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_PagodaConditionErr,
|
|
||||||
Title: pb.ErrorCode_PagodaConditionErr.ToString(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := pagoda.Reward[req.Id]; ok { // 校验是否重复领取
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_PagodaGetRewardErr,
|
|
||||||
Title: pb.ErrorCode_PagodaGetRewardErr.ToString(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if pagoda.Reward == nil {
|
|
||||||
pagoda.Reward = make(map[int32]bool, 0)
|
|
||||||
}
|
|
||||||
// 发奖励
|
|
||||||
if errdata, atno = this.module.DispenseAtno(session, _cfg.Reward, true); errdata != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pagoda.Reward[req.Id] = true
|
|
||||||
mapData := make(map[string]interface{}, 0)
|
|
||||||
mapData["reward"] = pagoda.Reward
|
|
||||||
errdata = this.module.ModifyPagodaData(session.GetUserId(), mapData)
|
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{
|
|
||||||
Data: pagoda,
|
|
||||||
Atno: atno,
|
|
||||||
})
|
|
||||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
||||||
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "PagodaGetRewardReq", atno)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
_cfg, err = this.module.configure.GetPagodaRewardconfig(req.Id)
|
||||||
|
if err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 校验是否能领取
|
||||||
|
if _cfg.LayerNum > pagoda.PagodaId {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_PagodaConditionErr,
|
||||||
|
Title: pb.ErrorCode_PagodaConditionErr.ToString(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := pagoda.Reward[req.Id]; ok { // 校验是否重复领取
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_PagodaGetRewardErr,
|
||||||
|
Title: pb.ErrorCode_PagodaGetRewardErr.ToString(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if pagoda.Reward == nil {
|
||||||
|
pagoda.Reward = make(map[int32]bool, 0)
|
||||||
|
}
|
||||||
|
// 发奖励
|
||||||
|
if errdata, atno = this.module.DispenseAtno(session, _cfg.Reward, true); errdata != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pagoda.Reward[req.Id] = true
|
||||||
|
mapData := make(map[string]interface{}, 0)
|
||||||
|
mapData["reward"] = pagoda.Reward
|
||||||
|
errdata = this.module.ModifyPagodaData(session.GetUserId(), mapData)
|
||||||
|
|
||||||
|
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{
|
||||||
|
Data: pagoda,
|
||||||
|
Atno: atno,
|
||||||
|
})
|
||||||
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||||
|
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "PagodaGetRewardReq", atno)
|
||||||
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user