From 1fd03267010ed4f0e102877b5ed2b12d982afb55 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 13 Dec 2022 11:04:49 +0800 Subject: [PATCH 1/5] =?UTF-8?q?bingo=20=E7=9B=B4=E6=8E=A5=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=B5=9B=E5=AD=A3=E5=A1=94=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/module.go | 16 ++++++++++++-- stress/robot/robot.go | 5 ++++- stress/server/dispose.go | 6 +++--- stress/server/golink/websocket_link.go | 29 -------------------------- stress/stress.go | 2 +- 5 files changed, 22 insertions(+), 36 deletions(-) diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index ff73e9dab..3312812ed 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -13,6 +13,7 @@ import ( "go_dreamfactory/sys/db" "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/bson/primitive" ) type Pagoda struct { @@ -234,8 +235,19 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int return } if !expand.CompletePagoda { // 普通塔 - code = pb.ErrorCode_ReqParameterError - return + expand.CompletePagoda = true + update := map[string]interface{}{ + "completePagoda": true, + } + this.ModuleUser.ChangeUserExpand(session.GetUserId(), update) + list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) + if list.Id == "" { + list.Id = primitive.NewObjectID().Hex() + list.Uid = session.GetUserId() + list.PagodaId = level + + this.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), list) + } } else { list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) if list.Id != "" { diff --git a/stress/robot/robot.go b/stress/robot/robot.go index 7aae07d54..c0244c335 100644 --- a/stress/robot/robot.go +++ b/stress/robot/robot.go @@ -266,6 +266,7 @@ func (r *Robot) Login() int64 { rsp := &pb.NotifyErrorNotifyPush{} if !comm.ProtoUnmarshal(msg, rsp) { // 记录错误码 + fmt.Printf("NotifyErrorNotifyPush err:%v", rsp) byteLen = 0 break } @@ -304,7 +305,7 @@ func (r *Robot) Create(i uint64) int64 { subType := "create" msg := &pb.UserMessage{MainType: mainType, SubType: subType} - name := "a100000" + strconv.Itoa(int(i)) + name := "e100000" + strconv.Itoa(int(i)) + r.account rsp := &pb.UserCreateReq{ NickName: name, Figure: 100, @@ -341,9 +342,11 @@ func (r *Robot) Create(i uint64) int64 { rsp := &pb.NotifyErrorNotifyPush{} if !comm.ProtoUnmarshal(msg, rsp) { // 记录错误码 + fmt.Printf("NotifyErrorNotifyPush err:%v", rsp) byteLen = 0 break } + break } } return byteLen diff --git a/stress/server/dispose.go b/stress/server/dispose.go index 348cb5890..93424d9a2 100644 --- a/stress/server/dispose.go +++ b/stress/server/dispose.go @@ -17,7 +17,7 @@ import ( ) const ( - connectionMode = 2 // 1:顺序建立长链接 2:并发建立长链接 + connectionMode = 1 // 1:顺序建立长链接 2:并发建立长链接 ) // init 注册验证器 @@ -51,7 +51,7 @@ func Dispose(ctx context.Context, concurrency, totalNumber uint64, request *mode case 1: // 连接以后再启动协程 r := robot.NewRobot(request.URL) - r.SetAccount("41112" + strconv.Itoa(int(i))) + r.SetAccount("f51112" + strconv.Itoa(int(i))) //head := &pb.UserMessage{MainType: "user", SubType: "login"} // 先登录 @@ -63,7 +63,7 @@ func Dispose(ctx context.Context, concurrency, totalNumber uint64, request *mode // 并发建立长链接 go func(i uint64) { r := robot.NewRobot(request.URL) - r.SetAccount("71112" + strconv.Itoa(int(i))) + r.SetAccount("b71112" + strconv.Itoa(int(i))) //head := &pb.UserMessage{MainType: "user", SubType: "login"} // 先登录 diff --git a/stress/server/golink/websocket_link.go b/stress/server/golink/websocket_link.go index f677743c5..f44a5a376 100644 --- a/stress/server/golink/websocket_link.go +++ b/stress/server/golink/websocket_link.go @@ -89,35 +89,6 @@ func webSocketRequest(chanID uint64, ch chan<- *model.RequestResults, i uint64, isSucceed = false } - //startTime := time.Now() - // r.GetRandUser() // 获取随机在线玩家数据 - //r.GetGourmetList() - //byteLen = r.GourmetOrder() - // if byteLen > 0 { - // isSucceed = true - // } - // for { - // var msg *pb.UserMessage = &pb.UserMessage{} - // data, err := r.GetMessagedata() - // if err != nil { - // fmt.Printf("readMessage err:%v", err) - // isSucceed = false - // break - // } - // if err = proto.Unmarshal(data, msg); err != nil { - // fmt.Printf("unmarshal err:%v", err) - // } - // if msg.MainType == "gourmet" && msg.SubType == "getlist" { - // byteLen += int64(len(data)) - // isSucceed = true - // resp := &pb.GourmetGetListResp{} - // if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败 - // break - // } - // break - // } - // } - requestTime := uint64(helper.DiffNano(startTime)) requestResults := &model.RequestResults{ ID: "", diff --git a/stress/stress.go b/stress/stress.go index 113fa6e0a..66b19d569 100644 --- a/stress/stress.go +++ b/stress/stress.go @@ -73,7 +73,7 @@ func main() { statistics.InitLog() concurrency = 100 - totalNumber = 10 + totalNumber = 1 debugStr = "false" requestURL = "ws://106.54.189.74:7891/gateway" if concurrency == 0 || totalNumber == 0 || (requestURL == "") { From 29ba901ecb91dc0fa707b64773afc7901e03c218 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 13 Dec 2022 11:17:21 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=B5=9B=E5=AD=A3=E5=A1=94=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/module.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index 3312812ed..48c95e88d 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -13,6 +13,7 @@ import ( "go_dreamfactory/sys/db" "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) @@ -245,8 +246,15 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int list.Id = primitive.NewObjectID().Hex() list.Uid = session.GetUserId() list.PagodaId = level + if conn, err := db.Cross(); err == nil { + rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}) + server := &pb.DBServerData{} + rst.Decode(server) + list.Type = server.SeasonType + } this.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), list) + session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) } } else { list, _ := this.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) From dc6a8900cf14e40566ff9c40f1845b1900ac4f04 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 13 Dec 2022 11:45:43 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/module.go | 14 +++++++++++++- modules/user/model_expand.go | 10 ---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index 48c95e88d..1d05d3e66 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -95,9 +95,21 @@ func (this *Pagoda) ModifyPagodaFloor(session comm.IUserSession, level int32) (c list.PagodaId = level mapData := make(map[string]interface{}, 0) mapData["pagodaId"] = level + // 通关校验 + Nomalcfg := this.configure.GetPagodaConfigData(comm.PagodaType, level+1) + if Nomalcfg == nil { + // 修改expand 数据 + update := map[string]interface{}{ + "completePagoda": true, + } + this.ModuleUser.ChangeUserExpand(session.GetUserId(), update) + list.Complete = true + mapData["complete"] = true + } code = this.ModifyPagodaData(session.GetUserId(), mapData) session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) } + return } @@ -263,7 +275,7 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int list.PagodaId = level mapData := make(map[string]interface{}, 0) mapData["pagodaId"] = level - code = this.ModifyPagodaData(session.GetUserId(), mapData) + code = this.ModifySeasonPagodaData(session.GetUserId(), mapData) session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) } } diff --git a/modules/user/model_expand.go b/modules/user/model_expand.go index 6b4c7a99e..2cfcf3439 100644 --- a/modules/user/model_expand.go +++ b/modules/user/model_expand.go @@ -88,13 +88,3 @@ func (this *ModelExpand) updateLoginDay(uid string, timestamp int64) (err error) } return } - -// 通关了普通塔 -func (this *ModelExpand) CompleteNormalPagoda(uid string) (err error) { - update := map[string]interface{}{ - "completePagoda": true, - } - err = this.ChangeUserExpand(uid, update) - - return -} From 37d7998748db7b05319acc15fa00d67ba0d81c87 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 13 Dec 2022 11:59:54 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E9=80=9A=E8=A1=8C=E8=AF=81=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/api.go | 2 +- .../{api_passcheck.go => api_warorder.go} | 8 +-- pb/pagoda_msg.pb.go | 64 +++++++++---------- 3 files changed, 37 insertions(+), 37 deletions(-) rename modules/pagoda/{api_passcheck.go => api_warorder.go} (85%) diff --git a/modules/pagoda/api.go b/modules/pagoda/api.go index cafe8fea4..b0e356161 100644 --- a/modules/pagoda/api.go +++ b/modules/pagoda/api.go @@ -14,7 +14,7 @@ const ( PagodaGetRewardResp = "getreward" PagodaRankListResp = "ranklist" PagodaActivateResp = "activate" - PagodaPassCheckResp = "passcheck" + PagodaWarOrderResp = "warorder" ) type apiComp struct { diff --git a/modules/pagoda/api_passcheck.go b/modules/pagoda/api_warorder.go similarity index 85% rename from modules/pagoda/api_passcheck.go rename to modules/pagoda/api_warorder.go index fb6c85226..9f1cc087a 100644 --- a/modules/pagoda/api_passcheck.go +++ b/modules/pagoda/api_warorder.go @@ -9,13 +9,13 @@ import ( ) //参数校验 -func (this *apiComp) PassCheckCheck(session comm.IUserSession, req *pb.PagodaPassCheckReq) (code pb.ErrorCode) { +func (this *apiComp) WarOrderCheck(session comm.IUserSession, req *pb.PagodaWarOrderReq) (code pb.ErrorCode) { return } // 战令领取 -func (this *apiComp) PassCheck(session comm.IUserSession, req *pb.PagodaPassCheckReq) (code pb.ErrorCode, data proto.Message) { +func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderReq) (code pb.ErrorCode, data proto.Message) { var ( list *pb.DBPagoda resCfg []*cfg.Gameatn @@ -26,7 +26,7 @@ func (this *apiComp) PassCheck(session comm.IUserSession, req *pb.PagodaPassChec mapData map[string]interface{} ) mapData = make(map[string]interface{}, 0) - this.PassCheckCheck(session, req) + //this.WarOrderCheck(session, req) list, _ = this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) if list.Id == "" { @@ -90,7 +90,7 @@ func (this *apiComp) PassCheck(session comm.IUserSession, req *pb.PagodaPassChec }) } code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData) - session.SendMsg(string(this.module.GetType()), PagodaPassCheckResp, &pb.PagodaPassCheckResp{ + session.SendMsg(string(this.module.GetType()), PagodaWarOrderResp, &pb.PagodaWarOrderResp{ Data: list, Itmes: res, }) diff --git a/pb/pagoda_msg.pb.go b/pb/pagoda_msg.pb.go index 3ae29f5ac..ae4b3e089 100644 --- a/pb/pagoda_msg.pb.go +++ b/pb/pagoda_msg.pb.go @@ -715,14 +715,14 @@ func (x *PagodaActivateResp) GetData() *DBPagoda { } // 领取战令奖励 -type PagodaPassCheckReq struct { +type PagodaWarOrderReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *PagodaPassCheckReq) Reset() { - *x = PagodaPassCheckReq{} +func (x *PagodaWarOrderReq) Reset() { + *x = PagodaWarOrderReq{} if protoimpl.UnsafeEnabled { mi := &file_pagoda_pagoda_msg_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -730,13 +730,13 @@ func (x *PagodaPassCheckReq) Reset() { } } -func (x *PagodaPassCheckReq) String() string { +func (x *PagodaWarOrderReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PagodaPassCheckReq) ProtoMessage() {} +func (*PagodaWarOrderReq) ProtoMessage() {} -func (x *PagodaPassCheckReq) ProtoReflect() protoreflect.Message { +func (x *PagodaWarOrderReq) ProtoReflect() protoreflect.Message { mi := &file_pagoda_pagoda_msg_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -748,12 +748,12 @@ func (x *PagodaPassCheckReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PagodaPassCheckReq.ProtoReflect.Descriptor instead. -func (*PagodaPassCheckReq) Descriptor() ([]byte, []int) { +// Deprecated: Use PagodaWarOrderReq.ProtoReflect.Descriptor instead. +func (*PagodaWarOrderReq) Descriptor() ([]byte, []int) { return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{14} } -type PagodaPassCheckResp struct { +type PagodaWarOrderResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -762,8 +762,8 @@ type PagodaPassCheckResp struct { Itmes []*UserAssets `protobuf:"bytes,2,rep,name=itmes,proto3" json:"itmes"` // 获得的奖励 } -func (x *PagodaPassCheckResp) Reset() { - *x = PagodaPassCheckResp{} +func (x *PagodaWarOrderResp) Reset() { + *x = PagodaWarOrderResp{} if protoimpl.UnsafeEnabled { mi := &file_pagoda_pagoda_msg_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -771,13 +771,13 @@ func (x *PagodaPassCheckResp) Reset() { } } -func (x *PagodaPassCheckResp) String() string { +func (x *PagodaWarOrderResp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PagodaPassCheckResp) ProtoMessage() {} +func (*PagodaWarOrderResp) ProtoMessage() {} -func (x *PagodaPassCheckResp) ProtoReflect() protoreflect.Message { +func (x *PagodaWarOrderResp) ProtoReflect() protoreflect.Message { mi := &file_pagoda_pagoda_msg_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -789,19 +789,19 @@ func (x *PagodaPassCheckResp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PagodaPassCheckResp.ProtoReflect.Descriptor instead. -func (*PagodaPassCheckResp) Descriptor() ([]byte, []int) { +// Deprecated: Use PagodaWarOrderResp.ProtoReflect.Descriptor instead. +func (*PagodaWarOrderResp) Descriptor() ([]byte, []int) { return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{15} } -func (x *PagodaPassCheckResp) GetData() *DBPagoda { +func (x *PagodaWarOrderResp) GetData() *DBPagoda { if x != nil { return x.Data } return nil } -func (x *PagodaPassCheckResp) GetItmes() []*UserAssets { +func (x *PagodaWarOrderResp) GetItmes() []*UserAssets { if x != nil { return x.Itmes } @@ -871,14 +871,14 @@ var file_pagoda_pagoda_msg_proto_rawDesc = []byte{ 0x67, 0x6f, 0x64, 0x61, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0x14, 0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x50, 0x61, 0x73, 0x73, 0x43, 0x68, 0x65, - 0x63, 0x6b, 0x52, 0x65, 0x71, 0x22, 0x57, 0x0a, 0x13, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x50, - 0x61, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x50, - 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x05, 0x69, - 0x74, 0x6d, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, - 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x69, 0x74, 0x6d, 0x65, 0x73, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x13, 0x0a, 0x11, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x57, 0x61, 0x72, 0x4f, 0x72, 0x64, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x22, 0x56, 0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x57, 0x61, + 0x72, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, + 0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x05, 0x69, 0x74, 0x6d, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, + 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x69, 0x74, 0x6d, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -909,8 +909,8 @@ var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{ (*PagodaQueryRecordResp)(nil), // 11: PagodaQueryRecordResp (*PagodaActivateReq)(nil), // 12: PagodaActivateReq (*PagodaActivateResp)(nil), // 13: PagodaActivateResp - (*PagodaPassCheckReq)(nil), // 14: PagodaPassCheckReq - (*PagodaPassCheckResp)(nil), // 15: PagodaPassCheckResp + (*PagodaWarOrderReq)(nil), // 14: PagodaWarOrderReq + (*PagodaWarOrderResp)(nil), // 15: PagodaWarOrderResp (*DBPagoda)(nil), // 16: DBPagoda (*BattleFormation)(nil), // 17: BattleFormation (*BattleInfo)(nil), // 18: BattleInfo @@ -928,8 +928,8 @@ var file_pagoda_pagoda_msg_proto_depIdxs = []int32{ 20, // 6: PagodaRankListResp.ranks:type_name -> DBPagodaRecord 20, // 7: PagodaQueryRecordResp.data:type_name -> DBPagodaRecord 16, // 8: PagodaActivateResp.data:type_name -> DBPagoda - 16, // 9: PagodaPassCheckResp.data:type_name -> DBPagoda - 21, // 10: PagodaPassCheckResp.itmes:type_name -> UserAssets + 16, // 9: PagodaWarOrderResp.data:type_name -> DBPagoda + 21, // 10: PagodaWarOrderResp.itmes:type_name -> UserAssets 11, // [11:11] is the sub-list for method output_type 11, // [11:11] is the sub-list for method input_type 11, // [11:11] is the sub-list for extension type_name @@ -1115,7 +1115,7 @@ func file_pagoda_pagoda_msg_proto_init() { } } file_pagoda_pagoda_msg_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PagodaPassCheckReq); i { + switch v := v.(*PagodaWarOrderReq); i { case 0: return &v.state case 1: @@ -1127,7 +1127,7 @@ func file_pagoda_pagoda_msg_proto_init() { } } file_pagoda_pagoda_msg_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PagodaPassCheckResp); i { + switch v := v.(*PagodaWarOrderResp); i { case 0: return &v.state case 1: From 18b4b318ed6e7505ea4845443f0cac33a9713849 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 13 Dec 2022 14:32:23 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=9B=B8=E5=90=8C=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=95=B4=E5=90=88=E4=B8=80=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/api_warorder.go | 58 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/modules/pagoda/api_warorder.go b/modules/pagoda/api_warorder.go index 9f1cc087a..ade434c61 100644 --- a/modules/pagoda/api_warorder.go +++ b/modules/pagoda/api_warorder.go @@ -24,6 +24,7 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR resID []int32 // 当前可领取的id vipID []int32 // 有vip的情况 可领取的id mapData map[string]interface{} + bReward bool ) mapData = make(map[string]interface{}, 0) //this.WarOrderCheck(session, req) @@ -33,10 +34,6 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 return } - if list.PagodaId <= list.PassCheckID { // 层数校验 - code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 - return - } payPoint := this.module.configure.GetPassCheckPointByTtype(1) if payPoint != "" { @@ -45,25 +42,39 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR vip = true } } + + if list.PagodaId < list.PassCheckID { // 层数校验 + //code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 + //return + bReward = true + } + if vip && bReward { + if list.PagodaId < list.VipPassCheckID { // 层数校验 + code = pb.ErrorCode_PagodaConditionErr // 领取条件没达到 + return + } + } conf := this.module.configure.GetPassCheckByTtype(1) - for pos, v := range conf { - if int32(pos) <= list.PassCheckID { + for _, v := range conf { + if v.Parameter <= list.PassCheckID { continue } - if v.Parameter >= list.PagodaId { + if v.Parameter <= list.PagodaId { resID = append(resID, v.Id) mapData["passCheckID"] = v.Parameter + list.PassCheckID = v.Parameter } } if vip { - for pos, v := range conf { - if int32(pos) <= list.VipPassCheckID { + for _, v := range conf { + if v.Parameter <= list.VipPassCheckID { continue } - if v.Parameter >= list.PagodaId { + if v.Parameter <= list.PagodaId { vipID = append(vipID, v.Id) mapData["vipPassCheckID"] = v.Parameter + list.VipPassCheckID = v.Parameter } } } @@ -78,17 +89,36 @@ func (this *apiComp) WarOrder(session comm.IUserSession, req *pb.PagodaWarOrderR resCfg = append(resCfg, confCheck.PayReward) } } - if code = this.module.DispenseRes(session, resCfg, true); code != pb.ErrorCode_Success { // 发放奖励 - return - } - // 转成协议格式 + // 资源整合 + var totalRes []*cfg.Gameatn for _, v := range resCfg { + b := false + for _, v1 := range totalRes { + if v.A == v1.A && v.T == v1.T { + b = true + v1.N += v.N + break + } + } + if !b { + totalRes = append(totalRes, v) + } + } + if len(totalRes) > 0 { + if code = this.module.DispenseRes(session, totalRes, true); code != pb.ErrorCode_Success { // 发放奖励 + return + } + } + + // 转成协议格式 + for _, v := range totalRes { res = append(res, &pb.UserAssets{ A: v.A, T: v.T, N: v.N, }) } + code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData) session.SendMsg(string(this.module.GetType()), PagodaWarOrderResp, &pb.PagodaWarOrderResp{ Data: list,