67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package uniongve
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) RouletteCheck(session comm.IUserSession, req *pb.UniongveRouletteReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 获取工会 转轮
|
|
func (this *apiComp) Roulette(session comm.IUserSession, req *pb.UniongveRouletteReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
confs []*cfg.GameGuildBossRouletteData
|
|
award []*pb.UserAssets = make([]*pb.UserAssets, 0)
|
|
weight []int32 = make([]int32, 0)
|
|
index int32
|
|
err error
|
|
)
|
|
|
|
if errdata = this.RouletteCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
need := this.module.ModuleTools.GetGlobalConf().GuildbossRoulette
|
|
|
|
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{need}, true); err != nil {
|
|
return
|
|
}
|
|
if confs, err = this.module.configure.getguildbossroulette(); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
for _, v := range confs {
|
|
weight = append(weight, v.Weight)
|
|
}
|
|
|
|
index = comm.GetRandW(weight)
|
|
|
|
for _, v := range confs[index].Reward {
|
|
award = append(award, &pb.UserAssets{
|
|
A: v.A,
|
|
T: v.T,
|
|
N: v.N,
|
|
})
|
|
}
|
|
|
|
if errdata = this.module.DispenseRes(session, confs[index].Reward, true); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if confs[index].Push == 1 { //推送通知
|
|
go this.module.modelUnionroulette.roulettechangePush(req.Unionid, session.GetUserId(), award)
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "roulette", &pb.UniongveRouletteResp{Cid: confs[index].Id, Award: award})
|
|
return
|
|
}
|