Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
fc3ac03b99
@ -28,24 +28,20 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
// GetMsgDistribute 获取消息分发规则读取配置表
|
||||
func (this *configureComp) GetMsgDistribute(msgmid, msguid string) (rule string, ok bool) {
|
||||
var (
|
||||
err error
|
||||
v interface{}
|
||||
item *cfg.GameMsgdistribData
|
||||
)
|
||||
if v, err = this.GetConfigure(game_msgdistrib); err != nil {
|
||||
ok = false
|
||||
return
|
||||
} else {
|
||||
if v, err := this.GetConfigure(game_msgdistrib); err == nil {
|
||||
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgmid]; ok && item.Open {
|
||||
rule = item.Routrules
|
||||
return
|
||||
} else {
|
||||
msgid := strings.ToLower(fmt.Sprintf("%s.%s", msgmid, msguid))
|
||||
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgid]; ok && item.Open {
|
||||
rule = item.Routrules
|
||||
return
|
||||
}
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
ok = false
|
||||
return
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ const (
|
||||
TrollRankListResp = "ranklist"
|
||||
TrollRecordListResp = "recordlist"
|
||||
TrollAfkSetResp = "afkset"
|
||||
TrollSurpriseIdResp = "surpriseid"
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
|
@ -68,7 +68,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
|
||||
return
|
||||
}
|
||||
if int32(configure.Now().Unix()-trolltrain.RefreshTime) < szTrain[trolltrain.TarinPos-1] {
|
||||
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})
|
||||
//session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})
|
||||
return
|
||||
}
|
||||
trainNum := this.configure.GetTrollMaxTraintNum()
|
||||
|
67
modules/troll/api_surpriseid.go
Normal file
67
modules/troll/api_surpriseid.go
Normal file
@ -0,0 +1,67 @@
|
||||
package troll
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"math/big"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) SurpriseIdCheck(session comm.IUserSession, req *pb.TrollSurpriseIdReq) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) SurpriseId(session comm.IUserSession, req *pb.TrollSurpriseIdReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
circletime int32 // 循环一个周期的时间
|
||||
circleCount int32 // 循环的次数
|
||||
update map[string]interface{}
|
||||
)
|
||||
update = make(map[string]interface{})
|
||||
|
||||
trolltrain, err := this.module.modelTroll.getTrollList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
/// 计算经过了多少个周期
|
||||
szTrain := this.configure.GetTrollAllTrain()
|
||||
for _, v := range szTrain {
|
||||
circletime += v
|
||||
}
|
||||
if int32(len(szTrain)) < trolltrain.TarinPos {
|
||||
this.module.Errorf("TarinPos error: TarinPos:%d,maxLen:%d", trolltrain.TarinPos, len(szTrain))
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if int32(configure.Now().Unix()-trolltrain.RefreshTime) >= szTrain[trolltrain.TarinPos-1] {
|
||||
trainNum := this.configure.GetTrollMaxTraintNum()
|
||||
|
||||
t := int32(configure.Now().Unix() - trolltrain.Ctime)
|
||||
circleCount = t / circletime // 经过的周期数
|
||||
if trolltrain.Circle != circleCount {
|
||||
trolltrain.SurpriseID = make(map[int32]int32, 0)
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(trainNum)))
|
||||
// 只算当前商人所属的货物
|
||||
g := this.configure.GetTrollGoodsFor(int32(n.Int64()) + 1)
|
||||
n2, _ := rand.Int(rand.Reader, big.NewInt(int64(len(g))))
|
||||
trolltrain.SurpriseID[int32(n.Int64())+1] = g[int32(n2.Int64())]
|
||||
update["surpriseID"] = trolltrain.SurpriseID
|
||||
trolltrain.Circle = circleCount
|
||||
update["circle"] = trolltrain.Circle
|
||||
this.module.ModifyTrollData(session.GetUserId(), update)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), TrollSurpriseIdResp, &pb.TrollSurpriseIdResp{
|
||||
SurpriseID: trolltrain.SurpriseID,
|
||||
})
|
||||
return
|
||||
}
|
@ -667,6 +667,93 @@ func (x *TrollRecordListResp) GetData() []*DBTrollRecord {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取惊喜商品
|
||||
type TrollSurpriseIdReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *TrollSurpriseIdReq) Reset() {
|
||||
*x = TrollSurpriseIdReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_troll_troll_msg_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TrollSurpriseIdReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TrollSurpriseIdReq) ProtoMessage() {}
|
||||
|
||||
func (x *TrollSurpriseIdReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_troll_troll_msg_proto_msgTypes[13]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TrollSurpriseIdReq.ProtoReflect.Descriptor instead.
|
||||
func (*TrollSurpriseIdReq) Descriptor() ([]byte, []int) {
|
||||
return file_troll_troll_msg_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
// 返回进度信息
|
||||
type TrollSurpriseIdResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
SurpriseID map[int32]int32 `protobuf:"bytes,1,rep,name=surpriseID,proto3" json:"surpriseID" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"surpriseID"` //key商人id value惊喜货物ID
|
||||
}
|
||||
|
||||
func (x *TrollSurpriseIdResp) Reset() {
|
||||
*x = TrollSurpriseIdResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_troll_troll_msg_proto_msgTypes[14]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TrollSurpriseIdResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TrollSurpriseIdResp) ProtoMessage() {}
|
||||
|
||||
func (x *TrollSurpriseIdResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_troll_troll_msg_proto_msgTypes[14]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TrollSurpriseIdResp.ProtoReflect.Descriptor instead.
|
||||
func (*TrollSurpriseIdResp) Descriptor() ([]byte, []int) {
|
||||
return file_troll_troll_msg_proto_rawDescGZIP(), []int{14}
|
||||
}
|
||||
|
||||
func (x *TrollSurpriseIdResp) GetSurpriseID() map[int32]int32 {
|
||||
if x != nil {
|
||||
return x.SurpriseID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_troll_troll_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_troll_troll_msg_proto_rawDesc = []byte{
|
||||
@ -722,8 +809,19 @@ var file_troll_troll_msg_proto_rawDesc = []byte{
|
||||
0x0a, 0x13, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73,
|
||||
0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x52, 0x65, 0x63,
|
||||
0x6f, 0x72, 0x64, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6f, 0x72, 0x64, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x14, 0x0a, 0x12, 0x54, 0x72, 0x6f,
|
||||
0x6c, 0x6c, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x64, 0x52, 0x65, 0x71, 0x22,
|
||||
0x9a, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73,
|
||||
0x65, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x44, 0x0a, 0x0a, 0x73, 0x75, 0x72, 0x70, 0x72,
|
||||
0x69, 0x73, 0x65, 0x49, 0x44, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x54, 0x72,
|
||||
0x6f, 0x6c, 0x6c, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x64, 0x52, 0x65, 0x73,
|
||||
0x70, 0x2e, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x44, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x52, 0x0a, 0x73, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x44, 0x1a, 0x3d, 0x0a,
|
||||
0x0f, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x44, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04,
|
||||
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -738,7 +836,7 @@ func file_troll_troll_msg_proto_rawDescGZIP() []byte {
|
||||
return file_troll_troll_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_troll_troll_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
||||
var file_troll_troll_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
|
||||
var file_troll_troll_msg_proto_goTypes = []interface{}{
|
||||
(*TrollGetListReq)(nil), // 0: TrollGetListReq
|
||||
(*TrollGetListResp)(nil), // 1: TrollGetListResp
|
||||
@ -753,23 +851,27 @@ var file_troll_troll_msg_proto_goTypes = []interface{}{
|
||||
(*TrollRankListResp)(nil), // 10: TrollRankListResp
|
||||
(*TrollRecordListReq)(nil), // 11: TrollRecordListReq
|
||||
(*TrollRecordListResp)(nil), // 12: TrollRecordListResp
|
||||
nil, // 13: TrollBuyOrSellReq.ItemsEntry
|
||||
(*DBTrollTrain)(nil), // 14: DBTrollTrain
|
||||
(*DBTrollRecord)(nil), // 15: DBTrollRecord
|
||||
(*TrollSurpriseIdReq)(nil), // 13: TrollSurpriseIdReq
|
||||
(*TrollSurpriseIdResp)(nil), // 14: TrollSurpriseIdResp
|
||||
nil, // 15: TrollBuyOrSellReq.ItemsEntry
|
||||
nil, // 16: TrollSurpriseIdResp.SurpriseIDEntry
|
||||
(*DBTrollTrain)(nil), // 17: DBTrollTrain
|
||||
(*DBTrollRecord)(nil), // 18: DBTrollRecord
|
||||
}
|
||||
var file_troll_troll_msg_proto_depIdxs = []int32{
|
||||
14, // 0: TrollGetListResp.data:type_name -> DBTrollTrain
|
||||
13, // 1: TrollBuyOrSellReq.items:type_name -> TrollBuyOrSellReq.ItemsEntry
|
||||
14, // 2: TrollBuyOrSellResp.data:type_name -> DBTrollTrain
|
||||
14, // 3: TrollAfkSetResp.data:type_name -> DBTrollTrain
|
||||
14, // 4: TrollNpcRewardResp.data:type_name -> DBTrollTrain
|
||||
17, // 0: TrollGetListResp.data:type_name -> DBTrollTrain
|
||||
15, // 1: TrollBuyOrSellReq.items:type_name -> TrollBuyOrSellReq.ItemsEntry
|
||||
17, // 2: TrollBuyOrSellResp.data:type_name -> DBTrollTrain
|
||||
17, // 3: TrollAfkSetResp.data:type_name -> DBTrollTrain
|
||||
17, // 4: TrollNpcRewardResp.data:type_name -> DBTrollTrain
|
||||
9, // 5: TrollRankListResp.data:type_name -> RankData
|
||||
15, // 6: TrollRecordListResp.data:type_name -> DBTrollRecord
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
18, // 6: TrollRecordListResp.data:type_name -> DBTrollRecord
|
||||
16, // 7: TrollSurpriseIdResp.surpriseID:type_name -> TrollSurpriseIdResp.SurpriseIDEntry
|
||||
8, // [8:8] is the sub-list for method output_type
|
||||
8, // [8:8] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
8, // [8:8] is the sub-list for extension extendee
|
||||
0, // [0:8] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_troll_troll_msg_proto_init() }
|
||||
@ -935,6 +1037,30 @@ func file_troll_troll_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_troll_troll_msg_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*TrollSurpriseIdReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_troll_troll_msg_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*TrollSurpriseIdResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -942,7 +1068,7 @@ func file_troll_troll_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_troll_troll_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 14,
|
||||
NumMessages: 17,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user