52 lines
1.4 KiB
Go
52 lines
1.4 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 (
|
|
conf *cfg.GameAchieveTaskData
|
|
atno []*pb.UserAtno
|
|
progress []*pb.ConIProgress
|
|
err error
|
|
)
|
|
if errdata = this.AwardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
conf, err = this.module.configure.getAchieveTaskById(req.Id)
|
|
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
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.AchieveAwardResp{Id: req.Id, Award: atno})
|
|
return
|
|
}
|