70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package caninerabbit
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.CanineRabbitAwardReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Award(session comm.IUserSession, req *pb.CanineRabbitAwardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameCatchrabbitrewardData
|
|
info *pb.DBCanineRabbit
|
|
atno []*pb.UserAtno
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.AwardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameGColorRewardData(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_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if _, ok = info.Award[req.Id]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "Allaward Claimed!",
|
|
}
|
|
}
|
|
if conf.Type == 1 {
|
|
if info.Rabbitintegral < conf.Condition {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ActivityCantReward,
|
|
Message: "Rabbitintegral no enough",
|
|
}
|
|
return
|
|
}
|
|
} else {
|
|
if info.Houndintegral < conf.Condition {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ActivityCantReward,
|
|
Message: "Houndintegral no enough",
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
if errdata, atno = this.module.DispenseAtno(session, conf.Reward, true); errdata != nil {
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "award", &pb.CanineRabbitAwardResp{Id: req.Id, Award: atno})
|
|
return
|
|
}
|