上传月之秘境代码优化

This commit is contained in:
liwei1dao 2022-08-31 14:29:17 +08:00
parent 3222c9fc4e
commit 8e71ed1091
6 changed files with 74 additions and 20 deletions

View File

@ -43,8 +43,19 @@ func (this *apiComp) Dare(session comm.IUserSession, req *pb.MoonfantasyDareReq)
code = pb.ErrorCode_MoonfantasyHasExpired code = pb.ErrorCode_MoonfantasyHasExpired
return return
} }
if v, ok := mdata.Record[session.GetUserId()]; ok {
if v >= mdata.Unitmup {
code = pb.ErrorCode_MoonfantasyDareUp
return
}
mdata.Record[session.GetUserId()]++
} else {
mdata.Record[session.GetUserId()] = 1
}
this.module.modelDream.ChangeList(req.Uid, req.Mid, map[string]interface{}{ this.module.modelDream.ChangeList(req.Uid, req.Mid, map[string]interface{}{
"joinnum": mdata.Joinnum + 1, "joinnum": mdata.Joinnum + 1,
"record": mdata.Record,
}) })
session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyDareResp{}) session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyDareResp{})
return return

View File

@ -42,17 +42,24 @@ func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTrigg
this.module.Errorln(err) this.module.Errorln(err)
return return
} }
if time.Unix(uexpand.MoonfantasyLastTrigger, 0).Day() != time.Now().Day() {
uexpand.MoonfantasyTriggerNum = 0
}
if uexpand.MoonfantasyTriggerNum >= globalconf.DreamlandTriggernum { if uexpand.MoonfantasyTriggerNum >= globalconf.DreamlandTriggernum {
return return
} }
if boss, err = this.module.configure.GetMonster(); err != nil { if boss, err = this.module.configure.GetMonster(); err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
if mdata, err = this.module.modelDream.addDreamData(session.GetUserId(), boss); err != nil { if mdata, err = this.module.modelDream.addDreamData(session.GetUserId(), boss); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{ this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1, "moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1,
"moonfantasyLastTrigger": time.Now().Unix(), "moonfantasyLastTrigger": time.Now().Unix(),

View File

@ -26,7 +26,7 @@ func (this *modelDreamComp) Init(service core.IService, module core.IModule, com
this.TableName = comm.TableMoonfantasy this.TableName = comm.TableMoonfantasy
//创建uid索引 //创建uid索引
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "heroid", Value: bsonx.Int32(1)}}, Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
}) })
return return
} }
@ -48,6 +48,9 @@ func (this *modelDreamComp) addDreamData(uid string, boss *cfg.GameDreamlandBoos
Monster: boss.Bossid, Monster: boss.Bossid,
Ctime: time.Now().Unix(), Ctime: time.Now().Unix(),
Joinnum: 0, Joinnum: 0,
Numup: boss.Challengenum,
Unitmup: boss.Fightnum,
Record: make(map[string]int32),
} }
if err = this.AddList(uid, result.Id, result); err != nil { if err = this.AddList(uid, result.Id, result); err != nil {
this.module.Errorln(err) this.module.Errorln(err)

View File

@ -167,6 +167,7 @@ const (
// moonfantasy 月之秘境 // moonfantasy 月之秘境
ErrorCode_MoonfantasyHasExpired ErrorCode = 2401 // boos 连接已失效 ErrorCode_MoonfantasyHasExpired ErrorCode = 2401 // boos 连接已失效
ErrorCode_MoonfantasyJoinUp ErrorCode = 2402 // boos 参与人数已达上限 ErrorCode_MoonfantasyJoinUp ErrorCode = 2402 // boos 参与人数已达上限
ErrorCode_MoonfantasyDareUp ErrorCode = 2403 // boos 挑战次数已达上限
) )
// Enum value maps for ErrorCode. // Enum value maps for ErrorCode.
@ -301,6 +302,7 @@ var (
2303: "VikingBuyMaxCount", 2303: "VikingBuyMaxCount",
2401: "MoonfantasyHasExpired", 2401: "MoonfantasyHasExpired",
2402: "MoonfantasyJoinUp", 2402: "MoonfantasyJoinUp",
2403: "MoonfantasyDareUp",
} }
ErrorCode_value = map[string]int32{ ErrorCode_value = map[string]int32{
"Success": 0, "Success": 0,
@ -432,6 +434,7 @@ var (
"VikingBuyMaxCount": 2303, "VikingBuyMaxCount": 2303,
"MoonfantasyHasExpired": 2401, "MoonfantasyHasExpired": 2401,
"MoonfantasyJoinUp": 2402, "MoonfantasyJoinUp": 2402,
"MoonfantasyDareUp": 2403,
} }
) )
@ -466,7 +469,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{ var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xe7, 0x15, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x6f, 0x2a, 0xff, 0x15, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -640,8 +643,10 @@ var file_errorcode_proto_rawDesc = []byte{
0x6f, 0x75, 0x6e, 0x74, 0x10, 0xff, 0x11, 0x12, 0x1a, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xff, 0x11, 0x12, 0x1a, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66,
0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x48, 0x61, 0x73, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x48, 0x61, 0x73, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64,
0x10, 0xe1, 0x12, 0x12, 0x16, 0x0a, 0x11, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x10, 0xe1, 0x12, 0x12, 0x16, 0x0a, 0x11, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61,
0x73, 0x79, 0x4a, 0x6f, 0x69, 0x6e, 0x55, 0x70, 0x10, 0xe2, 0x12, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x73, 0x79, 0x4a, 0x6f, 0x69, 0x6e, 0x55, 0x70, 0x10, 0xe2, 0x12, 0x12, 0x16, 0x0a, 0x11, 0x4d,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x44, 0x61, 0x72, 0x65, 0x55, 0x70,
0x10, 0xe3, 0x12, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (

View File

@ -25,12 +25,14 @@ type DBMoonfantasy struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id
Monster int32 `protobuf:"varint,3,opt,name=monster,proto3" json:"monster"` //怪物id Monster int32 `protobuf:"varint,3,opt,name=monster,proto3" json:"monster"` //怪物id
Ctime int64 `protobuf:"varint,4,opt,name=ctime,proto3" json:"ctime"` //创建时间 Ctime int64 `protobuf:"varint,4,opt,name=ctime,proto3" json:"ctime"` //创建时间
Joinnum int32 `protobuf:"varint,5,opt,name=joinnum,proto3" json:"joinnum"` //参与人数 Joinnum int32 `protobuf:"varint,5,opt,name=joinnum,proto3" json:"joinnum"` //参与人数
Numup int32 `protobuf:"varint,6,opt,name=numup,proto3" json:"numup"` //人数上限 Numup int32 `protobuf:"varint,6,opt,name=numup,proto3" json:"numup"` //人数上限
Unitmup int32 `protobuf:"varint,7,opt,name=unitmup,proto3" json:"unitmup"` //单人可挑战次数
Record map[string]int32 `protobuf:"bytes,8,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录
} }
func (x *DBMoonfantasy) Reset() { func (x *DBMoonfantasy) Reset() {
@ -107,12 +109,26 @@ func (x *DBMoonfantasy) GetNumup() int32 {
return 0 return 0
} }
func (x *DBMoonfantasy) GetUnitmup() int32 {
if x != nil {
return x.Unitmup
}
return 0
}
func (x *DBMoonfantasy) GetRecord() map[string]int32 {
if x != nil {
return x.Record
}
return nil
}
var File_moonfantasy_moonfantasy_db_proto protoreflect.FileDescriptor var File_moonfantasy_moonfantasy_db_proto protoreflect.FileDescriptor
var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{
0x0a, 0x20, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2f, 0x6d, 0x6f, 0x0a, 0x20, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2f, 0x6d, 0x6f,
0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x22, 0x91, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x6f, 0x22, 0x9a, 0x02, 0x0a, 0x0d, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e,
0x74, 0x61, 0x73, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x74, 0x61, 0x73, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65,
@ -121,8 +137,16 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{
0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6a, 0x6f, 0x69, 0x6e, 0x6e, 0x75, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6a, 0x6f, 0x69, 0x6e, 0x6e, 0x75,
0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6a, 0x6f, 0x69, 0x6e, 0x6e, 0x75, 0x6d, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6a, 0x6f, 0x69, 0x6e, 0x6e, 0x75, 0x6d,
0x12, 0x14, 0x0a, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70,
0x12, 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79,
0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
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 ( var (
@ -137,16 +161,18 @@ func file_moonfantasy_moonfantasy_db_proto_rawDescGZIP() []byte {
return file_moonfantasy_moonfantasy_db_proto_rawDescData return file_moonfantasy_moonfantasy_db_proto_rawDescData
} }
var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_moonfantasy_moonfantasy_db_proto_goTypes = []interface{}{ var file_moonfantasy_moonfantasy_db_proto_goTypes = []interface{}{
(*DBMoonfantasy)(nil), // 0: DBMoonfantasy (*DBMoonfantasy)(nil), // 0: DBMoonfantasy
nil, // 1: DBMoonfantasy.RecordEntry
} }
var file_moonfantasy_moonfantasy_db_proto_depIdxs = []int32{ var file_moonfantasy_moonfantasy_db_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type 1, // 0: DBMoonfantasy.record:type_name -> DBMoonfantasy.RecordEntry
0, // [0:0] is the sub-list for method input_type 1, // [1:1] is the sub-list for method output_type
0, // [0:0] is the sub-list for extension type_name 1, // [1:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension extendee 1, // [1:1] is the sub-list for extension type_name
0, // [0:0] is the sub-list for field type_name 1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
} }
func init() { file_moonfantasy_moonfantasy_db_proto_init() } func init() { file_moonfantasy_moonfantasy_db_proto_init() }
@ -174,7 +200,7 @@ func file_moonfantasy_moonfantasy_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_moonfantasy_moonfantasy_db_proto_rawDesc, RawDescriptor: file_moonfantasy_moonfantasy_db_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 1, NumMessages: 2,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -14,6 +14,7 @@ import (
"go_dreamfactory/modules/mail" "go_dreamfactory/modules/mail"
"go_dreamfactory/modules/mainline" "go_dreamfactory/modules/mainline"
"go_dreamfactory/modules/martialhall" "go_dreamfactory/modules/martialhall"
"go_dreamfactory/modules/moonfantasy"
"go_dreamfactory/modules/notify" "go_dreamfactory/modules/notify"
"go_dreamfactory/modules/pagoda" "go_dreamfactory/modules/pagoda"
"go_dreamfactory/modules/rtask" "go_dreamfactory/modules/rtask"
@ -69,6 +70,7 @@ func main() {
rtask.NewModule(), rtask.NewModule(),
viking.NewModule(), viking.NewModule(),
smithy.NewModule(), smithy.NewModule(),
moonfantasy.NewModule(),
) )
} }