上传武馆升级概率机制
This commit is contained in:
parent
9ef0b28252
commit
4c203aa3b2
@ -1,9 +1,11 @@
|
|||||||
package martialhall
|
package martialhall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"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) {
|
func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.MartialhallUpgradeReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
mart *pb.DBMartialhall
|
mart *pb.DBMartialhall
|
||||||
mdata *cfg.GameKungfuMasterworkerData
|
mdata *cfg.GameKungfuMasterworkerData
|
||||||
|
issucc bool
|
||||||
)
|
)
|
||||||
if mart, err = this.module.modelMartialhall.queryUserMartialhall(session.GetUserId()); err != nil {
|
if mart, err = this.module.modelMartialhall.queryUserMartialhall(session.GetUserId()); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
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 {
|
if code = this.module.ConsumeRes(session, mdata.LevelDeplete, true); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mart.Lv++
|
n, _ := rand.Int(rand.Reader, big.NewInt(1000))
|
||||||
settlement(mart.Pillar1, mdata)
|
if int32(n.Int64()) < mdata.Probability {
|
||||||
settlement(mart.Pillar2, mdata)
|
issucc = true
|
||||||
settlement(mart.Pillar3, mdata)
|
} else {
|
||||||
settlement(mart.Pillar4, mdata)
|
issucc = false
|
||||||
settlement(mart.Pillar5, mdata)
|
}
|
||||||
this.module.modelMartialhall.Add(session.GetUserId(), mart)
|
if issucc {
|
||||||
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.MartialhallUpgradeResp{Info: mart})
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,8 @@ type MartialhallUpgradeResp struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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() {
|
func (x *MartialhallUpgradeResp) Reset() {
|
||||||
@ -394,6 +395,13 @@ func (*MartialhallUpgradeResp) Descriptor() ([]byte, []int) {
|
|||||||
return file_martialhall_martialhall_msg_proto_rawDescGZIP(), []int{7}
|
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 {
|
func (x *MartialhallUpgradeResp) GetInfo() *DBMartialhall {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Info
|
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,
|
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,
|
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,
|
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,
|
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,
|
0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18,
|
||||||
0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68,
|
0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x22, 0x0a,
|
||||||
0x61, 0x6c, 0x6c, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x2e, 0x0a, 0x14, 0x4d, 0x61, 0x72,
|
0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42,
|
||||||
0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65,
|
0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x52, 0x04, 0x69, 0x6e, 0x66,
|
||||||
0x71, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x6f, 0x22, 0x2e, 0x0a, 0x14, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c,
|
||||||
0x05, 0x52, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61, 0x72, 0x22, 0x53, 0x0a, 0x15, 0x4d, 0x61, 0x72,
|
0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6c,
|
||||||
0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65,
|
0x6c, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x69, 0x6c, 0x6c, 0x61,
|
||||||
0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01,
|
0x72, 0x22, 0x53, 0x0a, 0x15, 0x4d, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c,
|
||||||
0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x22, 0x0a, 0x04, 0x69, 0x6e,
|
0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73,
|
||||||
0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x72,
|
0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75,
|
||||||
0x74, 0x69, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x06,
|
0x63, 0x63, 0x12, 0x22, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user