64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
package whackamole
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.WhackamoleAwardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取系统公告
|
|
func (this *apiComp) Award(session comm.IUserSession, req *pb.WhackamoleAwardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBWhackamole
|
|
conf *cfg.GameTDRewardData
|
|
atns []*cfg.Gameatn
|
|
award []*pb.UserAtno
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.AwardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if conf, err = this.module.configure.getGameTDRewardData(req.Id); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if _, ok = info.Levels[req.Id]; ok {
|
|
atns = conf.Reward
|
|
} else {
|
|
atns = conf.Reward
|
|
}
|
|
|
|
if errdata, award = this.module.DispenseAtno(session, atns, true); errdata != nil {
|
|
return
|
|
}
|
|
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"levels": info.Levels,
|
|
})
|
|
|
|
session.SendMsg(string(this.module.GetType()), "award", &pb.WhackamoleAwardResp{Id: req.Id, Award: award})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "WhackamoleAwardReq", award)
|
|
})
|
|
return
|
|
}
|