From e43de8647a8bd45a906b408ac5c087363c54256f Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 27 Oct 2022 15:48:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80=E5=9C=BA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=92=8C=E8=83=9C=E7=8E=87=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_msgdistrib.json | 6 +++ modules/arena/api_challengereward.go | 33 +++++++------- modules/arena/api_otherinfo.go | 6 ++- modules/arena/modelarena.go | 4 ++ pb/arena_db.pb.go | 67 ++++++++++++++++++++++------ 5 files changed, 85 insertions(+), 31 deletions(-) diff --git a/bin/json/game_msgdistrib.json b/bin/json/game_msgdistrib.json index c89061864..6c4ea094c 100644 --- a/bin/json/game_msgdistrib.json +++ b/bin/json/game_msgdistrib.json @@ -262,5 +262,11 @@ "open": true, "routrules": "~/worker", "describe": "获取在线玩家数据" + }, + { + "msgid": "arena", + "open": true, + "routrules": "~/worker", + "describe": "竞技场" } ] \ No newline at end of file diff --git a/modules/arena/api_challengereward.go b/modules/arena/api_challengereward.go index 27b9dcccb..e1a51fbe6 100644 --- a/modules/arena/api_challengereward.go +++ b/modules/arena/api_challengereward.go @@ -118,14 +118,16 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha this.module.modelRank.updateArenaRank(red, bule) info.Integral = red.Integral info.Rank = red.Rank + info.Attacktotaluum++ + if req.Iswin { + info.Attackwinuum++ + } else { + rival.Defendwinuum++ + } rival.Integral = bule.Integral rival.Rank = bule.Rank - if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { - code = pb.ErrorCode_DBError - } - if err = this.module.modelArena.updateArenaUserInfo(rival); err != nil { - code = pb.ErrorCode_DBError - } + rival.Defendtotaluum++ + redrecord := &pb.DBArenaBattleRecord{ Bid: req.Report.Info.Id, Time: time.Now().Unix(), @@ -151,10 +153,6 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha } } info.Record = append(info.Record, redrecord) - if err = this.module.modelArena.Change(red.Uid, map[string]interface{}{"record": info.Record}); err != nil { - code = pb.ErrorCode_DBError - return - } buleRecord := &pb.DBArenaBattleRecord{ Bid: req.Report.Info.Id, Time: time.Now().Unix(), @@ -180,17 +178,21 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha } } rival.Record = append(rival.Record, buleRecord) - if err = this.module.modelArena.Change(rival.Uid, map[string]interface{}{"record": rival.Record}); err != nil { + if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { + code = pb.ErrorCode_DBError + } + if err = this.module.modelArena.updateArenaUserInfo(rival); err != nil { code = pb.ErrorCode_DBError - return } } else { this.module.modelRank.updateArenaRank(red) info.Integral = red.Integral info.Rank = red.Rank - if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { - code = pb.ErrorCode_DBError + info.Attacktotaluum++ + if req.Iswin { + info.Attackwinuum++ } + redrecord := &pb.DBArenaBattleRecord{ Bid: req.Report.Info.Id, Time: time.Now().Unix(), @@ -216,9 +218,8 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha } } info.Record = append(info.Record, redrecord) - if err = this.module.modelArena.Change(red.Uid, map[string]interface{}{"record": info.Record}); err != nil { + if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { code = pb.ErrorCode_DBError - return } } diff --git a/modules/arena/api_otherinfo.go b/modules/arena/api_otherinfo.go index b11b369f8..4cb570d70 100644 --- a/modules/arena/api_otherinfo.go +++ b/modules/arena/api_otherinfo.go @@ -10,7 +10,9 @@ import ( //参数校验 func (this *apiComp) OtherInfoCheck(session comm.IUserSession, req *pb.ArenaOtherInfoReq) (code pb.ErrorCode) { - + if req.OtherId == "" { + code = pb.ErrorCode_ReqParameterError + } return } @@ -23,7 +25,7 @@ func (this *apiComp) OtherInfo(session comm.IUserSession, req *pb.ArenaOtherInfo if code = this.OtherInfoCheck(session, req); code != pb.ErrorCode_Success { return } - if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil { + if info, err = this.module.modelArena.queryPlayerInfo(req.OtherId); err != nil && err != mgo.MongodbNil { code = pb.ErrorCode_DBError return } diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index e0f828312..38feb6cab 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -115,6 +115,10 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) { "defend": info.Defend, "streak": info.Streak, "record": info.Record, + "attackwinuum": info.Attackwinuum, + "attacktotaluum": info.Attacktotaluum, + "defendwinuum": info.Defendwinuum, + "defendtotaluum": info.Defendtotaluum, }) return } diff --git a/pb/arena_db.pb.go b/pb/arena_db.pb.go index 631452865..964e11050 100644 --- a/pb/arena_db.pb.go +++ b/pb/arena_db.pb.go @@ -481,6 +481,10 @@ type DBArenaUser struct { Buynum int32 `protobuf:"varint,14,opt,name=buynum,proto3" json:"buynum"` //购买次数 Record []*DBArenaBattleRecord `protobuf:"bytes,15,rep,name=record,proto3" json:"record"` //战斗记录 Lastrtickettime int64 `protobuf:"varint,16,opt,name=lastrtickettime,proto3" json:"lastrtickettime"` //最后领劵时间 + Attackwinuum int32 `protobuf:"varint,17,opt,name=attackwinuum,proto3" json:"attackwinuum"` //进攻胜利次数 + Attacktotaluum int32 `protobuf:"varint,18,opt,name=attacktotaluum,proto3" json:"attacktotaluum"` //进攻总次数 + Defendwinuum int32 `protobuf:"varint,19,opt,name=defendwinuum,proto3" json:"defendwinuum"` //防守胜利 + Defendtotaluum int32 `protobuf:"varint,20,opt,name=defendtotaluum,proto3" json:"defendtotaluum"` //防守总 } func (x *DBArenaUser) Reset() { @@ -627,6 +631,34 @@ func (x *DBArenaUser) GetLastrtickettime() int64 { return 0 } +func (x *DBArenaUser) GetAttackwinuum() int32 { + if x != nil { + return x.Attackwinuum + } + return 0 +} + +func (x *DBArenaUser) GetAttacktotaluum() int32 { + if x != nil { + return x.Attacktotaluum + } + return 0 +} + +func (x *DBArenaUser) GetDefendwinuum() int32 { + if x != nil { + return x.Defendwinuum + } + return 0 +} + +func (x *DBArenaUser) GetDefendtotaluum() int32 { + if x != nil { + return x.Defendtotaluum + } + return 0 +} + var File_arena_arena_db_proto protoreflect.FileDescriptor var file_arena_arena_db_proto_rawDesc = []byte{ @@ -680,7 +712,7 @@ var file_arena_arena_db_proto_rawDesc = []byte{ 0x28, 0x05, 0x52, 0x0b, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x28, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x52, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0xd9, 0x03, 0x0a, 0x0b, 0x44, 0x42, + 0x74, 0x65, 0x52, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0xf1, 0x04, 0x0a, 0x0b, 0x44, 0x42, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, @@ -710,18 +742,27 @@ var file_arena_arena_db_proto_rawDesc = []byte{ 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x9f, 0x01, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x41, - 0x74, 0x74, 0x61, 0x63, 0x6b, 0x57, 0x69, 0x6e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x74, - 0x74, 0x61, 0x63, 0x6b, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, - 0x66, 0x65, 0x6e, 0x64, 0x6b, 0x57, 0x69, 0x6e, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, - 0x66, 0x65, 0x6e, 0x64, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x03, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61, - 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x10, 0x04, 0x12, 0x11, - 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, - 0x05, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x53, 0x75, 0x63, 0x63, - 0x65, 0x65, 0x64, 0x65, 0x64, 0x10, 0x06, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x6e, - 0x67, 0x65, 0x45, 0x6e, 0x64, 0x10, 0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x77, + 0x69, 0x6e, 0x75, 0x75, 0x6d, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x61, 0x74, 0x74, + 0x61, 0x63, 0x6b, 0x77, 0x69, 0x6e, 0x75, 0x75, 0x6d, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x74, 0x74, + 0x61, 0x63, 0x6b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x75, 0x75, 0x6d, 0x18, 0x12, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x75, 0x75, + 0x6d, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x77, 0x69, 0x6e, 0x75, 0x75, + 0x6d, 0x18, 0x13, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x64, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x77, + 0x69, 0x6e, 0x75, 0x75, 0x6d, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x74, + 0x6f, 0x74, 0x61, 0x6c, 0x75, 0x75, 0x6d, 0x18, 0x14, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x64, + 0x65, 0x66, 0x65, 0x6e, 0x64, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x75, 0x75, 0x6d, 0x2a, 0x9f, 0x01, + 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x57, 0x69, 0x6e, + 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x4c, 0x6f, 0x73, 0x74, + 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x6b, 0x57, 0x69, 0x6e, + 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x4c, 0x6f, 0x73, 0x74, + 0x10, 0x03, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, + 0x65, 0x6e, 0x67, 0x65, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, + 0x65, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x65, 0x76, + 0x65, 0x6e, 0x67, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x10, 0x06, 0x12, + 0x0e, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x45, 0x6e, 0x64, 0x10, 0x07, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (