From 18b4b318ed6e7505ea4845443f0cac33a9713849 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 13 Dec 2022 14:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E5=90=8C=E8=B5=84=E6=BA=90=E6=95=B4?= =?UTF-8?q?=E5=90=88=E4=B8=80=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/api_warorder.go | 58 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/modules/pagoda/api_warorder.go b/modules/pagoda/api_warorder.go index 9f1cc087a..ade434c61 100644 --- a/modules/pagoda/api_warorder.go +++ b/modules/pagoda/api_warorder.go @@ -24,6 +24,7 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR resID []int32 // 当前可领取的id vipID []int32 // 有vip的情况 可领取的id mapData map[string]interface{} + bReward bool ) mapData = make(map[string]interface{}, 0) //this.WarOrderCheck(session, req) @@ -33,10 +34,6 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 return } - if list.PagodaId <= list.PassCheckID { // 层数校验 - code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 - return - } payPoint := this.module.configure.GetPassCheckPointByTtype(1) if payPoint != "" { @@ -45,25 +42,39 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR vip = true } } + + if list.PagodaId < list.PassCheckID { // 层数校验 + //code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 + //return + bReward = true + } + if vip && bReward { + if list.PagodaId < list.VipPassCheckID { // 层数校验 + code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 + return + } + } conf := this.module.configure.GetPassCheckByTtype(1) - for pos, v := range conf { - if int32(pos) <= list.PassCheckID { + for _, v := range conf { + if v.Parameter <= list.PassCheckID { continue } - if v.Parameter >= list.PagodaId { + if v.Parameter <= list.PagodaId { resID = append(resID, v.Id) mapData["passCheckID"] = v.Parameter + list.PassCheckID = v.Parameter } } if vip { - for pos, v := range conf { - if int32(pos) <= list.VipPassCheckID { + for _, v := range conf { + if v.Parameter <= list.VipPassCheckID { continue } - if v.Parameter >= list.PagodaId { + if v.Parameter <= list.PagodaId { vipID = append(vipID, v.Id) mapData["vipPassCheckID"] = v.Parameter + list.VipPassCheckID = v.Parameter } } } @@ -78,17 +89,36 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR resCfg = append(resCfg, confCheck.PayReward) } } - if code = this.module.DispenseRes(session, resCfg, true); code != pb.ErrorCode_Success { // 发放奖励 - return - } - // 转成协议格式 + // 资源整合 + var totalRes []*cfg.Gameatn for _, v := range resCfg { + b := false + for _, v1 := range totalRes { + if v.A == v1.A && v.T == v1.T { + b = true + v1.N += v.N + break + } + } + if !b { + totalRes = append(totalRes, v) + } + } + if len(totalRes) > 0 { + if code = this.module.DispenseRes(session, totalRes, true); code != pb.ErrorCode_Success { // 发放奖励 + return + } + } + + // 转成协议格式 + for _, v := range totalRes { res = append(res, &pb.UserAssets{ A: v.A, T: v.T, N: v.N, }) } + code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData) session.SendMsg(string(this.module.GetType()), PagodaWarOrderResp, &pb.PagodaWarOrderResp{ Data: list,