107 lines
2.8 KiB
Go
107 lines
2.8 KiB
Go
package pagoda
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) RaceRewardCheck(session comm.IUserSession, req *pb.PagodaRaceRewardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 六合塔奖励
|
|
func (this *apiComp) RaceReward(session comm.IUserSession, req *pb.PagodaRaceRewardReq) (errdata *pb.ErrorData) {
|
|
|
|
var (
|
|
atno []*pb.UserAtno
|
|
list *pb.DBPagodaRace
|
|
err error
|
|
szConf []*cfg.GameSixDirectionsRewardData
|
|
res []*cfg.Gameatn
|
|
totalStar int32
|
|
floors []int32
|
|
curStr int32
|
|
)
|
|
if errdata = this.RaceRewardCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
|
|
if list, err = this.module.modelRacePagoda.getPagodaRaceList(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
floors = this.module.configure.GetSixDirectionsGroudConf(req.Groud)
|
|
if len(floors) == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: fmt.Sprintf("conf not fount:%d", req.Groud),
|
|
}
|
|
return
|
|
} // 1 2 3
|
|
if c, err := this.module.configure.GetSixPagodaConf(floors[0]); err == nil {
|
|
szConf = this.module.configure.GetSixDirectionsConf(c.Groudreward)
|
|
}
|
|
|
|
if len(szConf) == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: fmt.Sprintf("conf not fount:%d", req.Groud),
|
|
}
|
|
return
|
|
}
|
|
for _, v := range floors {
|
|
if d, ok := list.Data[v]; ok {
|
|
curStr = 0
|
|
star1 := 0
|
|
for i := 0; i < 3; i++ {
|
|
star1 = 1 << i
|
|
if int(d.Star)&star1 == star1 {
|
|
curStr++
|
|
}
|
|
}
|
|
totalStar += curStr
|
|
}
|
|
}
|
|
for _, v := range szConf {
|
|
if totalStar >= v.Starnum && list.Reward[req.Groud] < v.Starnum {
|
|
list.Reward[req.Groud] = v.Starnum
|
|
res = append(res, v.Reward...)
|
|
}
|
|
}
|
|
if len(res) == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_UserNoReward,
|
|
Title: pb.ErrorCode_UserNoReward.ToString(),
|
|
Message: fmt.Sprintf("UserNoReward:%d", req.Groud),
|
|
}
|
|
return
|
|
}
|
|
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
|
return
|
|
}
|
|
mapData := make(map[string]interface{}, 0)
|
|
mapData["reward"] = list.Reward
|
|
this.module.modelRacePagoda.ModifyPagodaRaceData(session.GetUserId(), mapData)
|
|
|
|
session.SendMsg(string(this.module.GetType()), "racereward", &pb.PagodaRaceRewardResp{
|
|
Data: list,
|
|
Reward: atno,
|
|
})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "PagodaRaceRewardReq", atno)
|
|
})
|
|
|
|
return
|
|
}
|