83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
package achieve
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.AchieveAwardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Award(session comm.IUserSession, req *pb.AchieveAwardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBAchieveData
|
|
conf *cfg.GameAchieveTaskData
|
|
atno []*pb.UserAtno
|
|
progress []*pb.ConIProgress
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.AwardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getAchieveTaskById(req.Id); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.String(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.model.getmodel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.String(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if ok = info.Receive[req.Id]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.String(),
|
|
Message: "Claimed",
|
|
}
|
|
return
|
|
}
|
|
|
|
if progress, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), conf.TaskBuried); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ExternalModule,
|
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
for _, v := range progress {
|
|
if v.State == pb.BuriedItemFinishState_buried_unfinish {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "task unfinish!",
|
|
}
|
|
return
|
|
}
|
|
}
|
|
if errdata, atno = this.module.DispenseAtno(session, conf.TaskReward, true); errdata != nil {
|
|
return
|
|
}
|
|
info.Receive[req.Id] = true
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"receive": info.Receive,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "award", &pb.AchieveAwardResp{Id: req.Id, Award: atno})
|
|
return
|
|
}
|