From 4c203aa3b22563c37cd185477256330d68d63cc1 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 25 Aug 2022 09:48:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=AD=A6=E9=A6=86=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E6=A6=82=E7=8E=87=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/martialhall/api_upgrade.go | 34 +++++++++++++++++--------- pb/martialhall_msg.pb.go | 38 +++++++++++++++++++----------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/modules/martialhall/api_upgrade.go b/modules/martialhall/api_upgrade.go index 632ee3f4e..661112775 100644 --- a/modules/martialhall/api_upgrade.go +++ b/modules/martialhall/api_upgrade.go @@ -1,9 +1,11 @@ package martialhall import ( + "crypto/rand" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" + "math/big" "google.golang.org/protobuf/proto" ) @@ -17,9 +19,10 @@ func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.Martialhall ///练功请求 func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.MartialhallUpgradeReq) (code pb.ErrorCode, data proto.Message) { var ( - err error - mart *pb.DBMartialhall - mdata *cfg.GameKungfuMasterworkerData + err error + mart *pb.DBMartialhall + mdata *cfg.GameKungfuMasterworkerData + issucc bool ) if mart, err = this.module.modelMartialhall.queryUserMartialhall(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError @@ -32,13 +35,22 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.MartialhallUpgra if code = this.module.ConsumeRes(session, mdata.LevelDeplete, true); code != pb.ErrorCode_Success { return } - mart.Lv++ - settlement(mart.Pillar1, mdata) - settlement(mart.Pillar2, mdata) - settlement(mart.Pillar3, mdata) - settlement(mart.Pillar4, mdata) - settlement(mart.Pillar5, mdata) - this.module.modelMartialhall.Add(session.GetUserId(), mart) - session.SendMsg(string(this.module.GetType()), "upgrade", &pb.MartialhallUpgradeResp{Info: mart}) + n, _ := rand.Int(rand.Reader, big.NewInt(1000)) + if int32(n.Int64()) < mdata.Probability { + issucc = true + } else { + issucc = false + } + if issucc { + mart.Lv++ + settlement(mart.Pillar1, mdata) + settlement(mart.Pillar2, mdata) + settlement(mart.Pillar3, mdata) + settlement(mart.Pillar4, mdata) + settlement(mart.Pillar5, mdata) + this.module.modelMartialhall.Add(session.GetUserId(), mart) + } + + session.SendMsg(string(this.module.GetType()), "upgrade", &pb.MartialhallUpgradeResp{Issucc: issucc, Info: mart}) return } diff --git a/pb/martialhall_msg.pb.go b/pb/martialhall_msg.pb.go index 96163b60d..7047e141c 100644 --- a/pb/martialhall_msg.pb.go +++ b/pb/martialhall_msg.pb.go @@ -359,7 +359,8 @@ type MartialhallUpgradeResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Info *DBMartialhall `protobuf:"bytes,1,opt,name=info,proto3" json:"info"` + Issucc bool `protobuf:"varint,1,opt,name=issucc,proto3" json:"issucc"` + Info *DBMartialhall `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` } func (x *MartialhallUpgradeResp) Reset() { @@ -394,6 +395,13 @@ func (*MartialhallUpgradeResp) Descriptor() ([]byte, []int) { return file_martialhall_martialhall_msg_proto_rawDescGZIP(), []int{7} } +func (x *MartialhallUpgradeResp) GetIssucc() bool { + if x != nil { + return x.Issucc + } + return false +} + func (x *MartialhallUpgradeResp) GetInfo() *DBMartialhall { if x != nil { return x.Info @@ -534,20 +542,22 @@ var file_martialhall_martialhall_msg_proto_rawDesc = []byte{ 0x52, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61, 0x72, 0x22, 0x18, 0x0a, 0x16, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, - 0x6c, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x22, 0x3c, 0x0a, 0x16, 0x4d, + 0x6c, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x22, 0x54, 0x0a, 0x16, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, - 0x61, 0x6c, 0x6c, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x2e, 0x0a, 0x14, 0x4d, 0x61, 0x72, - 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, - 0x71, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61, 0x72, 0x22, 0x53, 0x0a, 0x15, 0x4d, 0x61, 0x72, - 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x22, 0x0a, 0x04, 0x69, 0x6e, - 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x72, - 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x22, 0x0a, + 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, + 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x52, 0x04, 0x69, 0x6e, 0x66, + 0x6f, 0x22, 0x2e, 0x0a, 0x14, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, + 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6c, + 0x6c, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61, + 0x72, 0x22, 0x53, 0x0a, 0x15, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, + 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, + 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, + 0x63, 0x63, 0x12, 0x22, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, + 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (