From e4e08a220189b15bbf5c0df1316f174ca262bbca Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 27 Sep 2023 14:11:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80=E5=9C=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=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 | 17 +++++++++ modules/arena/api_challengereward.go | 8 ---- modules/arena/api_setdattformt.go | 56 ---------------------------- modules/arena/api_setdefformt.go | 16 ++++++++ 4 files changed, 33 insertions(+), 64 deletions(-) delete mode 100644 modules/arena/api_setdattformt.go diff --git a/modules/arena/api_challenge.go b/modules/arena/api_challenge.go index bb41eacf8..6a7f60a35 100644 --- a/modules/arena/api_challenge.go +++ b/modules/arena/api_challenge.go @@ -36,6 +36,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge heros []*pb.DBHero record *pb.DBBattleRecord change bool + ok bool err error ) if errdata = this.ChallengeCheck(session, req); errdata != nil { @@ -72,6 +73,22 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge } return } + ok = false + for _, v := range heros { + if 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, diff --git a/modules/arena/api_challengereward.go b/modules/arena/api_challengereward.go index 06a440811..396c47caa 100644 --- a/modules/arena/api_challengereward.go +++ b/modules/arena/api_challengereward.go @@ -222,14 +222,6 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha } return } - if err = this.module.modelArena.updateArenaUserInfo(rival); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), - } - return - } } else { this.module.modelRank.updateArenaRank(red) info.Integral = red.Integral diff --git a/modules/arena/api_setdattformt.go b/modules/arena/api_setdattformt.go deleted file mode 100644 index dd76db36b..000000000 --- a/modules/arena/api_setdattformt.go +++ /dev/null @@ -1,56 +0,0 @@ -package arena - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" -) - -//参数校验 -func (this *apiComp) SetAttFormtCheck(session comm.IUserSession, req *pb.ArenaSetAttFormtReq) (errdata *pb.ErrorData) { - - return -} - -///设置防守阵型 -func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttFormtReq) (errdata *pb.ErrorData) { - var ( - info *pb.DBArenaUser - heros []*pb.DBHero - err error - ) - if errdata = this.SetAttFormtCheck(session, req); errdata != nil { - return - } - if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), - } - - return - } - if heros, err = this.module.modelArena.queryUserHeros(session.GetUserId(), req.Formt); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), - } - return - } - info.Attack = &pb.DBPlayerBattleFormt{ - Leadpos: req.Leadpos, - Formt: heros, - } - - if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), - } - return - } - session.SendMsg(string(this.module.GetType()), "setattformt", &pb.ArenaSetAttFormtResp{Issucc: true}) - return -} diff --git a/modules/arena/api_setdefformt.go b/modules/arena/api_setdefformt.go index d75f85346..e18490067 100644 --- a/modules/arena/api_setdefformt.go +++ b/modules/arena/api_setdefformt.go @@ -32,6 +32,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF var ( info *pb.DBArenaUser heros []*pb.DBHero + ok bool err error ) if errdata = this.SetDefFormtCheck(session, req); errdata != nil { @@ -56,6 +57,21 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF return } + ok = false + for _, v := range heros { + if v.Id != "" { + ok = true + } + } + + if !ok { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: "no found any hero", + } + return + } info.Defend = &pb.DBPlayerBattleFormt{ Leadpos: req.Leadpos, Formt: heros,