From 308c5258eb3d1d525ad23debe3fff55cf606902d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 22 Dec 2023 14:06:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E6=B6=88=E8=AE=B0=E5=BD=95=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E6=98=BE=E7=A4=BA=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 64 ++++++++++++++++++++----------- pb/entertain_db.pb.go | 72 +++++++++++++++++++++++++++-------- 2 files changed, 98 insertions(+), 38 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index e3ab534d4..8209e9c9b 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -556,7 +556,15 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { } pl = append(pl, p) } - + } else { + if conf, err := this.module.configure.GetGameConsumeintegral(winner.Consumeexp); err == nil { + for _, v := range conf.Rewards { + if v.A == "attr" && v.T == "consumeexp" { + winScore = v.N + break + } + } + } } if lostPlayer.Userinfo.Uid != "999" { if conf, err := this.module.configure.GetGameConsumeHero(lostPlayer.Cardid); err != nil { @@ -574,7 +582,7 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { } } if conf, err := this.module.configure.GetGameConsumeintegral(list.Consumeexp); err == nil { // 战败扣除积分 - for _, v := range conf.Rewards { + for _, v := range conf.Deductrewards { if v.A == "attr" && v.T == "consumeexp" { lostScore = v.N list.Consumeexp -= v.N @@ -612,27 +620,39 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { } } } - + } else { + if conf, err := this.module.configure.GetGameConsumeintegral(winner.Consumeexp); err == nil { + for _, v := range conf.Deductrewards { + if v.A == "attr" && v.T == "consumeexp" { + lostScore = v.N + break + } + } + } } - - // 更新排行榜数据 - this.module.modelRank.updateXxlRank(pl...) - // 写记录 - recode1 := &pb.DBXxlRecord{ - Id: primitive.NewObjectID().Hex(), - P1: this.player1.Userinfo.Uid, - P2: this.player2.Userinfo.Uid, - Uinfo1: this.player1.Userinfo, - Uinfo2: this.player2.Userinfo, - P1Score: this.player1.Score, - P2Score: this.player2.Score, - Win: winner.Userinfo.Uid, - Winscore: winScore, - Lostscore: lostScore, - Createtime: configure.Now().Unix(), - } - - this.module.modelRecode.updateXxlRecord(recode1) + go func() { + // 更新排行榜数据 + this.module.modelRank.updateXxlRank(pl...) + // 写记录 + recode1 := &pb.DBXxlRecord{ + Id: primitive.NewObjectID().Hex(), + P1: this.player1.Userinfo.Uid, + P2: this.player2.Userinfo.Uid, + Uinfo1: this.player1.Userinfo, + Uinfo2: this.player2.Userinfo, + P1Score: this.player1.Score, + P2Score: this.player2.Score, + Win: winner.Userinfo.Uid, + Winscore: winScore, + Lostscore: lostScore, + P1Card: this.player1.Cardid, + P2Cards: this.player2.Cardid, + P1Totlascore: this.player1.Consumeexp, + P2Totlascore: this.player2.Consumeexp, + Createtime: configure.Now().Unix(), + } + this.module.modelRecode.updateXxlRecord(recode1) + }() // 修改房间状态 this.Status = 2 diff --git a/pb/entertain_db.pb.go b/pb/entertain_db.pb.go index 7cd49e882..58518dbf0 100644 --- a/pb/entertain_db.pb.go +++ b/pb/entertain_db.pb.go @@ -768,17 +768,21 @@ type DBXxlRecord struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - P1 string `protobuf:"bytes,2,opt,name=p1,proto3" json:"p1"` // 服务端索引用 - P2 string `protobuf:"bytes,3,opt,name=p2,proto3" json:"p2"` // 服务端索引用 - Uinfo1 *BaseUserInfo `protobuf:"bytes,4,opt,name=uinfo1,proto3" json:"uinfo1"` //p1基本信息 - Uinfo2 *BaseUserInfo `protobuf:"bytes,5,opt,name=uinfo2,proto3" json:"uinfo2"` //p2基本信息 - P1Score int32 `protobuf:"varint,6,opt,name=p1score,proto3" json:"p1score"` // p1 得分 - P2Score int32 `protobuf:"varint,7,opt,name=p2score,proto3" json:"p2score"` // p2 得分 - Win string `protobuf:"bytes,8,opt,name=win,proto3" json:"win"` // uid 胜利 - Winscore int32 `protobuf:"varint,9,opt,name=winscore,proto3" json:"winscore"` - Lostscore int32 `protobuf:"varint,10,opt,name=lostscore,proto3" json:"lostscore"` - Createtime int64 `protobuf:"varint,11,opt,name=createtime,proto3" json:"createtime" bson:"createtime"` // + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + P1 string `protobuf:"bytes,2,opt,name=p1,proto3" json:"p1"` // 服务端索引用 + P2 string `protobuf:"bytes,3,opt,name=p2,proto3" json:"p2"` // 服务端索引用 + Uinfo1 *BaseUserInfo `protobuf:"bytes,4,opt,name=uinfo1,proto3" json:"uinfo1"` //p1基本信息 + Uinfo2 *BaseUserInfo `protobuf:"bytes,5,opt,name=uinfo2,proto3" json:"uinfo2"` //p2基本信息 + P1Score int32 `protobuf:"varint,6,opt,name=p1score,proto3" json:"p1score"` // p1 得分 + P2Score int32 `protobuf:"varint,7,opt,name=p2score,proto3" json:"p2score"` // p2 得分 + Win string `protobuf:"bytes,8,opt,name=win,proto3" json:"win"` // uid 胜利 + Winscore int32 `protobuf:"varint,9,opt,name=winscore,proto3" json:"winscore"` + Lostscore int32 `protobuf:"varint,10,opt,name=lostscore,proto3" json:"lostscore"` + P1Card string `protobuf:"bytes,11,opt,name=p1card,proto3" json:"p1card"` // p1 卡片 + P2Cards string `protobuf:"bytes,12,opt,name=p2cards,proto3" json:"p2cards"` // p2 卡片 + P1Totlascore int32 `protobuf:"varint,13,opt,name=p1totlascore,proto3" json:"p1totlascore"` // p1 总分 + P2Totlascore int32 `protobuf:"varint,14,opt,name=p2totlascore,proto3" json:"p2totlascore"` // p2 总分 + Createtime int64 `protobuf:"varint,15,opt,name=createtime,proto3" json:"createtime" bson:"createtime"` // } func (x *DBXxlRecord) Reset() { @@ -883,6 +887,34 @@ func (x *DBXxlRecord) GetLostscore() int32 { return 0 } +func (x *DBXxlRecord) GetP1Card() string { + if x != nil { + return x.P1Card + } + return "" +} + +func (x *DBXxlRecord) GetP2Cards() string { + if x != nil { + return x.P2Cards + } + return "" +} + +func (x *DBXxlRecord) GetP1Totlascore() int32 { + if x != nil { + return x.P1Totlascore + } + return 0 +} + +func (x *DBXxlRecord) GetP2Totlascore() int32 { + if x != nil { + return x.P2Totlascore + } + return 0 +} + func (x *DBXxlRecord) GetCreatetime() int64 { if x != nil { return x.Createtime @@ -1027,7 +1059,7 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x61, 0x78, 0x73, 0x6f, 0x63, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x73, 0x6f, 0x63, 0x72, 0x65, 0x22, 0xab, 0x02, 0x0a, + 0x28, 0x05, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x73, 0x6f, 0x63, 0x72, 0x65, 0x22, 0xa5, 0x03, 0x0a, 0x0b, 0x44, 0x42, 0x58, 0x78, 0x6c, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x70, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x70, 0x31, 0x12, 0x0e, 0x0a, 0x02, @@ -1044,10 +1076,18 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x12, 0x1a, 0x0a, 0x08, 0x77, 0x69, 0x6e, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x77, 0x69, 0x6e, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x73, 0x74, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x6c, 0x6f, 0x73, 0x74, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x09, 0x6c, 0x6f, 0x73, 0x74, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x31, + 0x63, 0x61, 0x72, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x31, 0x63, 0x61, + 0x72, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x32, 0x63, 0x61, 0x72, 0x64, 0x73, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x32, 0x63, 0x61, 0x72, 0x64, 0x73, 0x12, 0x22, 0x0a, 0x0c, + 0x70, 0x31, 0x74, 0x6f, 0x74, 0x6c, 0x61, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0d, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0c, 0x70, 0x31, 0x74, 0x6f, 0x74, 0x6c, 0x61, 0x73, 0x63, 0x6f, 0x72, 0x65, + 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x32, 0x74, 0x6f, 0x74, 0x6c, 0x61, 0x73, 0x63, 0x6f, 0x72, 0x65, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x70, 0x32, 0x74, 0x6f, 0x74, 0x6c, 0x61, 0x73, + 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var (