45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package parkour
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.ParkourGetRewardReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
///积分领奖
|
|
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.ParkourGetRewardReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBParkour
|
|
err error
|
|
)
|
|
if code = this.GetRewardCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if info, err = this.module.parkourComp.queryinfo(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
_conf := this.module.configure.getGameBuzkashiReward(req.Rid)
|
|
if _conf == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if _conf.Schedule <= info.Integral && (info.Reward+1 == req.Rid) {
|
|
info.Reward += 1
|
|
if err = this.module.parkourComp.Change(session.GetUserId(), map[string]interface{}{
|
|
"reward": info.Reward,
|
|
}); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "getreward", &pb.ParkourGetRewardResp{
|
|
Info: info,
|
|
})
|
|
return
|
|
}
|