74 lines
1.9 KiB
Go
74 lines
1.9 KiB
Go
package realarena
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) DanReceiveCheck(session comm.IUserSession, req *pb.ArenaDanReceiveReq) (errdata *pb.ErrorData) {
|
|
if req.Dan == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) DanReceive(session comm.IUserSession, req *pb.ArenaDanReceiveReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameArenarealtimeConfigData
|
|
info *pb.DBRealArena
|
|
err error
|
|
atno []*pb.UserAtno
|
|
)
|
|
if errdata = this.DanReceiveCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if info, err = this.module.model.getinfo(session); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info.Danaward[req.Dan] == 1 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: fmt.Sprintf("%d received", req.Dan),
|
|
}
|
|
return
|
|
}
|
|
info.Danaward[req.Dan] = 1
|
|
if conf, err = this.module.configure.getGameArenarealtimeConfig(req.Dan); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if errdata, atno = this.module.DispenseAtno(session, conf.ExReward, true); errdata != nil {
|
|
return
|
|
}
|
|
if err = this.module.model.change(session.GetUserId(), map[string]interface{}{
|
|
"danaward": info.Danaward,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "danreceive", &pb.ArenaDanReceiveResp{Dan: req.Dan, Award: atno})
|
|
return
|
|
}
|