From f93bebeeeab883d6ef0a832449b1558a607079b7 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 21 Feb 2024 16:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80=E5=9C=BA?= =?UTF-8?q?=E6=88=98=E6=96=97=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_challenge.go | 81 +++++++++++++++------------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/modules/arena/api_challenge.go b/modules/arena/api_challenge.go index b74063fbe..e0a0be2d9 100644 --- a/modules/arena/api_challenge.go +++ b/modules/arena/api_challenge.go @@ -35,7 +35,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge bule *pb.ArenaPlayer heros []*pb.DBHero record *pb.DBBattleRecord - change bool + // change bool isopen bool ok bool err error @@ -65,56 +65,47 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), req, comm.GMResDelType, "ArenaChallengeReq", this.module.ModuleTools.GetGlobalConf().ArenaTicketCos) // 消耗资源 }) - if red.Attack != nil { - for i, v := range req.Battle.Format { - if (red.Attack.Formt[i] != nil && red.Attack.Formt[i].Id != v) || (red.Attack.Formt[i] == nil && v != "") { - change = true - } + + // if red.Defend == nil || change { + if heros, err = this.module.modelArena.queryUserHeros(session.GetUserId(), req.Battle.Format); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + ok = false + for _, v := range heros { + if v != nil && v.Id != "" { + ok = true } - } else { - change = true } - if red.Defend == nil || change { - if heros, err = this.module.modelArena.queryUserHeros(session.GetUserId(), req.Battle.Format); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), - } - return - } - ok = false - for _, v := range heros { - if v != nil && v.Id != "" { - ok = true - } - } - - if !ok { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: "no found any hero", - } - return - } - - if red.Defend == nil { - red.Defend = &pb.DBPlayerBattleFormt{ - Leadpos: req.Battle.Leadpos, - Formt: heros, - } - red.Isdef = true - } - if change { - red.Attack = &pb.DBPlayerBattleFormt{ - Leadpos: req.Battle.Leadpos, - Formt: heros, - } + if !ok { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: "no found any hero", } + return } + if red.Defend == nil { + red.Defend = &pb.DBPlayerBattleFormt{ + Leadpos: req.Battle.Leadpos, + Formt: heros, + } + red.Isdef = true + } + // if change { + red.Attack = &pb.DBPlayerBattleFormt{ + Leadpos: req.Battle.Leadpos, + Formt: heros, + } + // } + // } + if !req.Isai { if bule, err = this.module.modelArena.queryArenaPlayer(req.Playerid); err != nil { errdata = &pb.ErrorData{