66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
package passon
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) ClearCDCheck(session comm.IUserSession, req *pb.PassonClearCDReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) ClearCD(session comm.IUserSession, req *pb.PassonClearCDReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBPasson
|
|
conf *cfg.GamePassonData
|
|
err error
|
|
)
|
|
|
|
if errdata = this.ClearCDCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.GetPassonConf(req.Index + 1); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{conf.Remake}, true); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.modelPasson.getUserPasson(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
info.Student[req.Index].Heroid = ""
|
|
info.Student[req.Index].State = 0
|
|
info.Student[req.Index].Cdtime = 0
|
|
if err = this.module.modelPasson.updateUserPasson(session.GetUserId(), info); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "clearcd", &pb.PassonClearCDResp{Index: req.Index})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResDelType, "PassonClearCDReq", conf.Remake)
|
|
})
|
|
return
|
|
}
|