From 1c577a821f07b8ceb6b523479e65ed386df8b8a4 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 25 Jul 2022 16:18:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_drawCard.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index 10b9832a4..bdf9da53b 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -8,6 +8,7 @@ import ( "math" "math/big" "strconv" + "time" "google.golang.org/protobuf/proto" ) @@ -31,11 +32,23 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq config4Count int32 // 配置表中4星保底次数 config5Count int32 // 配置表中5星保底次数 race int32 + upDraw []*cfg.Game_drawUpdrawData // 活动数据 英雄抽卡权重增加 ) + upDraw = make([]*cfg.Game_drawUpdrawData, 0) szCards = make([]string, 0) rsp := &pb.HeroDrawCardResp{} this.module.Debugf("当前4星抽卡没中次数:%d, 当前5星抽卡没中次数:%d", curStar4Count, curStar5Count) - + // ======记录活动数据 + cfgData, err := this.module.configure.GetDrawUpDrawConfig() + if err != nil { + // 校验时间 + for _, v := range cfgData.GetDataList() { + if time.Now().Unix() > int64(v.TimeOn) && time.Now().Unix() < int64(v.TimeOff) { // 在这个时间范围之内 + upDraw = append(upDraw, v) // 记录下在这活动范围之内的数据 + } + } + } + // =======活动数据记录完成 rst, _ := this.module.modelHero.GetUserRecord(session.GetUserId()) if req.DrawType%2 == 0 { // 转成对应阵营信息 1~5 race = int32((int(req.DrawType)) / 2) @@ -89,7 +102,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq for _, v := range _conf { totalWeight += int64(v.Weight) // 统计所有权重 } - //this.module.configure.GetDrawUpDrawConfig() + drawTimes = 1 for i := 0; i < int(drawTimes); i++ { n, _ := rand.Int(rand.Reader, big.NewInt(totalWeight)) // [0,totalWeight)