From 203e75da21f649a8721cea00a63b45eec294af3e Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 26 Dec 2022 15:28:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E5=A5=96=E5=8A=B1=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/viking/api_challengeover.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/modules/viking/api_challengeover.go b/modules/viking/api_challengeover.go index a5b66cd5a..d88f0c34a 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "strconv" "google.golang.org/protobuf/proto" ) @@ -21,11 +22,10 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Vikin ///挑战完成 func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChallengeOverReq) (code pb.ErrorCode, data proto.Message) { var ( - mapData map[string]interface{} - newChallenge bool // 新的关卡 - reward []*cfg.Gameatn - asset []*pb.UserAssets - bWin bool // 战斗是否胜利 + mapData map[string]interface{} + reward []*cfg.Gameatn + asset []*pb.UserAssets + bWin bool // 战斗是否胜利 ) mapData = make(map[string]interface{}, 0) reward = make([]*cfg.Gameatn, 0) @@ -63,9 +63,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal if !ok { // 类型校验 viking.Boss[req.BossId] = 1 } - if value == req.Difficulty { - newChallenge = true - } else if value < req.Difficulty { + if value < req.Difficulty { code = pb.ErrorCode_HuntingLvErr return } @@ -90,11 +88,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal mapData["recoveryTime"] = viking.RecoveryTime } } - if bWin { - this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, viking, req.Report) - } - mapData["bossTime"] = viking.BossTime // 更新时间 - if newChallenge && bWin { // 新关卡挑战通过 发放首通奖励 + key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty)) + if viking.BossTime[key] == 0 { // 新关卡挑战通过 发放首通奖励 viking.Boss[req.BossId]++ mapData["boss"] = viking.Boss if code = this.module.DispenseRes(session, vikingCfg.Firstprize, true); code != pb.ErrorCode_Success { @@ -107,7 +102,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal N: v.N, }) } - } else { + } + if bWin { + this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, viking, req.Report) reward = this.module.configure.GetDropReward(vikingCfg.Drop) // 获取掉落奖励 if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success { return @@ -120,6 +117,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal }) } } + mapData["bossTime"] = viking.BossTime // 更新时间 + code = this.module.ModifyVikingData(session.GetUserId(), mapData) // 发放通关随机奖励 session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingChallengeOverResp{