diff --git a/bin/json/game_opencond.json b/bin/json/game_opencond.json index cce4953ff..54e480d28 100644 --- a/bin/json/game_opencond.json +++ b/bin/json/game_opencond.json @@ -7,12 +7,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -33,12 +33,12 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -59,12 +59,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -85,12 +85,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -111,12 +111,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -137,12 +137,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -163,12 +163,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -189,12 +189,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -215,12 +215,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -241,12 +241,12 @@ }, "main": [ { - "key": "platlv", - "param": 2 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -267,12 +267,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -293,12 +293,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -319,12 +319,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -345,12 +345,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -371,12 +371,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -397,12 +397,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -423,12 +423,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -449,12 +449,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -475,12 +475,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -501,12 +501,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -527,12 +527,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -553,12 +553,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -579,12 +579,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -605,12 +605,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -631,12 +631,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -657,12 +657,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -683,12 +683,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -709,12 +709,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -735,7 +735,7 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 } ], @@ -757,12 +757,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -783,12 +783,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -809,12 +809,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -835,12 +835,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -861,12 +861,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -887,12 +887,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -913,12 +913,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -939,12 +939,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -965,12 +965,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -991,12 +991,12 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1017,12 +1017,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1043,12 +1043,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1069,12 +1069,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1095,12 +1095,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1121,12 +1121,12 @@ }, "main": [ { - "key": "platlv", - "param": 20 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1147,12 +1147,12 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1173,12 +1173,12 @@ }, "main": [ { - "key": "platlv", - "param": 13 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1199,12 +1199,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1225,7 +1225,7 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 } ], @@ -1247,7 +1247,7 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 } ], @@ -1269,7 +1269,7 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 } ], @@ -1291,12 +1291,12 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1317,12 +1317,12 @@ }, "main": [ { - "key": "platlv", - "param": 4 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1343,12 +1343,12 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1369,12 +1369,12 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1395,12 +1395,12 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1421,12 +1421,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1447,12 +1447,12 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1473,12 +1473,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1499,12 +1499,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1525,12 +1525,12 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1551,12 +1551,12 @@ }, "main": [ { - "key": "platlv", - "param": 30 + "key": 1, + "param": 1 }, { - "key": "maxmapid", - "param": 1 + "key": 2, + "param": 1100101 } ], "optional": "", @@ -1577,8 +1577,8 @@ }, "main": [ { - "key": "worldtaskid", - "param": 20050 + "key": 3, + "param": 20010 } ], "optional": "", @@ -1599,8 +1599,8 @@ }, "main": [ { - "key": "worldtaskid", - "param": 20050 + "key": 3, + "param": 20010 } ], "optional": "", @@ -1621,8 +1621,8 @@ }, "main": [ { - "key": "worldtaskid", - "param": 20050 + "key": 3, + "param": 20010 } ], "optional": "", diff --git a/comm/const.go b/comm/const.go index 5ba030703..b1bcbfd38 100644 --- a/comm/const.go +++ b/comm/const.go @@ -78,6 +78,7 @@ const ( ModuleEnchant core.M_Modules = "enchant" //附魔 ModuleAutoBattle core.M_Modules = "autobattle" //自动战斗 ModuleMline core.M_Modules = "mline" //主线模块 + ModuleRTimePVP core.M_Modules = "rtimepvp" //实时pvp ) //数据表名定义处 diff --git a/comm/imodule.go b/comm/imodule.go index 4471cea98..2b745176b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -2,6 +2,7 @@ package comm import ( "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) type ( @@ -17,6 +18,7 @@ type ( type ( ISys interface { IsAccess(funcName string, uid string) (code pb.ErrorCode) + ValidCond(uid string, conf *cfg.GameOpencondData) string } //邮件业务模块对外接口定义 提供给其他模块使用的 diff --git a/modules/friend/model_friend.go b/modules/friend/model_friend.go index e4c2d59b0..f60c12ac2 100644 --- a/modules/friend/model_friend.go +++ b/modules/friend/model_friend.go @@ -10,6 +10,7 @@ import ( "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelFriend struct { @@ -21,6 +22,10 @@ func (this *ModelFriend) Init(service core.IService, module core.IModule, comp c this.TableName = comm.TableFriend err = this.MCompModel.Init(service, module, comp, options) this.moduleFriend = module.(*Friend) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return } diff --git a/modules/items/modelitems.go b/modules/items/modelitems.go index 98214e3e7..742874cfa 100644 --- a/modules/items/modelitems.go +++ b/modules/items/modelitems.go @@ -195,6 +195,7 @@ func (this *ModelItemsComp) QueryUserPackItemsAmount(uId string, itemid ...strin itmes []*pb.DB_UserItemData err error ) + if itmes, err = this.QueryUserPack(uId); err != nil { this.module.Errorf("err:%v", err) return diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index 45c6c9df5..e3cfb150c 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -81,9 +81,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle // if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { // cd = pb.ErrorCode_CacheReadError // } - if cd = this.module.CheckRes(session, boss.PsConsume); cd != pb.ErrorCode_Success { - return - } + // if umfantasy.Ticket < this.module.configure.GetGlobalConf().DreamlandCos { // cd = pb.ErrorCode_MoonfantasyNotEnoughbattles // } @@ -92,6 +90,12 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle cd = pb.ErrorCode_ConfigNoFound return } + if cd = this.module.ModuleItems.RecoverTicket(session); cd != pb.ErrorCode_Success { + return + } + if cd = this.module.CheckRes(session, boss.PsConsume); cd != pb.ErrorCode_Success { + return + } if len(mdata.Join) >= int(mdata.Numup) { cd = pb.ErrorCode_MoonfantasyJoinUp diff --git a/modules/moonfantasy/api_getlist.go b/modules/moonfantasy/api_getlist.go index 9c09e2f76..a13d3626f 100644 --- a/modules/moonfantasy/api_getlist.go +++ b/modules/moonfantasy/api_getlist.go @@ -25,11 +25,12 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetLi code = pb.ErrorCode_CacheReadError return } - this.module.modelUserMF.recoverTicket(session, info) - if err = this.module.modelUserMF.updateUserInfo(info); err != nil { - code = pb.ErrorCode_DBError - return - } + // this.module.modelUserMF.recoverTicket(session, info) + // if err = this.module.modelUserMF.updateUserInfo(info); err != nil { + // code = pb.ErrorCode_DBError + // return + // } + this.module.ModuleItems.RecoverTicket(session) mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId()) session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{ // BattleNum: info.Ticket, diff --git a/modules/moonfantasy/modelUserMF.go b/modules/moonfantasy/modelUserMF.go index bd4167e6c..b7373f29c 100644 --- a/modules/moonfantasy/modelUserMF.go +++ b/modules/moonfantasy/modelUserMF.go @@ -63,8 +63,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (info *pb.DBUserMFantasy, ///保存用户竞技场信息 func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) { this.Change(info.Uid, map[string]interface{}{ - "triggerNum": info.TriggerNum, - // "ticket": info.Ticket, + "triggerNum": info.TriggerNum, "buyNum": info.BuyNum, "lastTrigger": info.LastTrigger, "lastrtickettime": info.Lastrtickettime, diff --git a/modules/rtask/model_record.go b/modules/rtask/model_record.go index a758a0056..e016d35b0 100644 --- a/modules/rtask/model_record.go +++ b/modules/rtask/model_record.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelRtaskRecord struct { @@ -22,6 +23,10 @@ func (this *ModelRtaskRecord) Init(service core.IService, module core.IModule, c err = this.MCompModel.Init(service, module, comp, options) this.moduleRtask = module.(*ModuleRtask) this.service = service + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return } diff --git a/modules/rtimepvp/api.go b/modules/rtimepvp/api.go new file mode 100644 index 000000000..2ea30dc96 --- /dev/null +++ b/modules/rtimepvp/api.go @@ -0,0 +1,29 @@ +package rtimepvp + +import ( + "go_dreamfactory/modules" + + "go_dreamfactory/lego/core" +) + +/* +装备模块 API +*/ +type apiComp struct { + modules.MCompGate + service core.IService + module *RTimePVP +} + +//组件初始化接口 +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) + this.module = module.(*RTimePVP) + this.service = service + return +} + +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() + return +} diff --git a/modules/rtimepvp/module.go b/modules/rtimepvp/module.go new file mode 100644 index 000000000..d8decae43 --- /dev/null +++ b/modules/rtimepvp/module.go @@ -0,0 +1,28 @@ +package rtimepvp + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/base" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +/* +模块名:实时PVP +描述:同步战斗模块 +开发:李伟 +*/ +func NewModule() core.IModule { + m := new(RTimePVP) + return m +} + +type RTimePVP struct { + modules.ModuleBase + service base.IRPCXService +} + +//模块名 +func (this *RTimePVP) GetType() core.M_Modules { + return comm.ModuleRTimePVP +} diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index 92a2806c7..4c39a9244 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -49,6 +49,9 @@ func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "_id", Value: bsonx.Int32(1)}}, }) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "name", Value: bsonx.Int32(1)}}, + }) this.module = module.(*Sociaty) this.service = service this.EventApp = event_v2.NewApp() diff --git a/modules/sys/api_func.go b/modules/sys/api_func.go index 2522634f1..3aa6be614 100644 --- a/modules/sys/api_func.go +++ b/modules/sys/api_func.go @@ -25,13 +25,9 @@ func (this *apiComp) Funclist(session comm.IUserSession, req *pb.SysFuncListReq) if len(req.Keys) == 0 { confList := this.moduleSys.configure.getOpencondList() for _, v := range confList { - // 返回未开启的功能列表 - for _, conf := range v.Main { - // 校验玩家等级 - if conf.Key == "platlv" && user.Lv >= conf.Param { - funcList = append(funcList, v.Id) - continue - } + id := this.moduleSys.modelSys.validCond(session.GetUserId(), v) + if id != "" { + funcList = append(funcList, id) } } } else { @@ -41,12 +37,9 @@ func (this *apiComp) Funclist(session comm.IUserSession, req *pb.SysFuncListReq) continue } if conf, ok := opencfg.GetDataMap()[key]; ok { - for _, main := range conf.Main { - // 校验玩家等级 - if main.Key == "platlv" && user.Lv >= main.Param { - funcList = append(funcList, key) - continue - } + id := this.moduleSys.modelSys.validCond(session.GetUserId(), conf) + if id != "" { + funcList = append(funcList, id) } } } diff --git a/modules/sys/model_sys.go b/modules/sys/model_sys.go index 3cef80442..c5d467292 100644 --- a/modules/sys/model_sys.go +++ b/modules/sys/model_sys.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) type ModelSys struct { @@ -27,14 +28,73 @@ func (this *ModelSys) IsAccess(funName string, uid string) (code pb.ErrorCode) { if user != nil { conf := this.moduleSys.configure.getFuncCfg(funName) if conf != nil { - for _, v := range conf.Main { - if v.Key == "platlv" && user.Lv < v.Param { - code = pb.ErrorCode_NoOpened - return - } - } + this.validCond(uid, conf) } } return } + +func (this *ModelSys) validCond(uid string, condData *cfg.GameOpencondData) string { + var flag bool + for _, conf := range condData.Main { + switch conf.Key { + case 1: //等级 + iuser := this.moduleSys.ModuleUser + user := iuser.GetUser(uid) + if user == nil { + flag = false + return "" + } + if user.Lv >= conf.Param { + flag = true + }else{ + flag = false + } + case 2: //关卡ID + iuser := this.moduleSys.ModuleUser + ex, err := iuser.GetUserExpand(uid) + if err != nil { + flag = false + return "" + } + if ex.Uid == "" { + flag = false + return "" + } + + if v, ok := ex.Mline[1]; ok { + if v >= conf.Param { + flag = true + }else{ + flag = false + } + }else{ + flag = false + } + + case 3: //世界任务ID + module, err := this.service.GetModule(comm.ModuleWorldtask) + if err != nil { + this.moduleSys.Debugln(err) + flag = false + return "" + } + if i, ok := module.(comm.IWorldtask); ok { + d := i.GetMyWorldtask(uid) + if _, ok := d.LastTaskIds[conf.Param]; ok { + flag = true + }else{ + flag = false + } + }else{ + flag = false + } + } + } + + if flag { + return condData.Id + } + return "" +} diff --git a/modules/sys/module.go b/modules/sys/module.go index a8174cf58..23c5be9e2 100644 --- a/modules/sys/module.go +++ b/modules/sys/module.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) var _ comm.ISys = (*ModuleSys)(nil) @@ -40,3 +41,7 @@ func (this *ModuleSys) GetType() core.M_Modules { func (this *ModuleSys) IsAccess(funcName string, userId string) (code pb.ErrorCode) { return this.modelSys.IsAccess(funcName, userId) } + +func (this *ModuleSys) ValidCond(uid string, conf *cfg.GameOpencondData) string { + return this.modelSys.validCond(uid, conf) +} diff --git a/modules/user/comp_configure.go b/modules/user/comp_configure.go index a3acca4ac..e0a48c412 100644 --- a/modules/user/comp_configure.go +++ b/modules/user/comp_configure.go @@ -68,6 +68,20 @@ func (this *configureComp) LoadSignData() { return } +func (this *configureComp) GetOpenCondList() []*cfg.GameOpencondData { + if v, err := this.GetConfigure(gameOpencond); err != nil { + return nil + } else { + data, ok := v.(*cfg.GameOpencond) + if !ok { + err = fmt.Errorf("%T no is *cfg.GameOpencond", v) + return nil + } + return data.GetDataList() + } + return nil +} + func (this *configureComp) FindFunc(lv int32) (funcIds []string) { if v, err := this.GetConfigure(gameOpencond); err != nil { return nil @@ -79,7 +93,7 @@ func (this *configureComp) FindFunc(lv int32) (funcIds []string) { } for _, d := range data.GetDataList() { for _, v := range d.Main { - if v.Key == "platlv" && v.Param == lv { + if v.Key == 1 && v.Param == lv { funcIds = append(funcIds, d.Id) continue } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index f4dee732f..b52d56b5d 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -273,7 +273,20 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{ ) return } - et.TriggerEvent(comm.EventOpenCond, ul.session.GetUserId(), this.module.configure.FindFunc(curLv)) + module, err2 := this.module.service.GetModule(comm.ModuleSys) + if err2 == nil { + if isys, ok := module.(comm.ISys); ok { + var funcList []string + for _, conf := range this.module.configure.GetOpenCondList() { + id := isys.ValidCond(ul.session.GetUserId(), conf) + if id != "" { + funcList = append(funcList, id) + } + } + + et.TriggerEvent(comm.EventOpenCond, ul.session.GetUserId(), funcList) + } + } if err := ul.session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush, &pb.UserLvChangedPush{Uid: ul.session.GetUserId(), Exp: curExp, Lv: curLv}); err != nil { this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败", diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index f80306a86..1f87e10f4 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -8,7 +8,6 @@ import ( "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" "reflect" - "runtime" "sync" "time" @@ -119,15 +118,15 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, //Rpc_GatewayRoute服务接口的接收函数 func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) { method := fmt.Sprintf("%s.%s", args.MainType, args.SubType) - defer func() { //程序异常 收集异常信息传递给前端显示 - if r := recover(); r != nil { - buf := make([]byte, 4096) - l := runtime.Stack(buf, false) - reply.Code = pb.ErrorCode_Exception - reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) - log.Errorf("[Handle Api] m:%s reply:%s", method, reply) - } - }() + // defer func() { //程序异常 收集异常信息传递给前端显示 + // if r := recover(); r != nil { + // buf := make([]byte, 4096) + // l := runtime.Stack(buf, false) + // reply.Code = pb.ErrorCode_Exception + // reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) + // log.Errorf("[Handle Api] m:%s reply:%s", method, reply) + // } + // }() //获取用户消息处理函数 this.mrlock.RLock() msghandle, ok := this.msghandles[method] diff --git a/sys/configure/structs/Game.OpencondType.go b/sys/configure/structs/Game.OpencondType.go new file mode 100644 index 000000000..01706bec6 --- /dev/null +++ b/sys/configure/structs/Game.OpencondType.go @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +const ( + GameOpencondType_None = 0 + GameOpencondType_Platlv = 1 + GameOpencondType_Maxmapid = 2 + GameOpencondType_Worldtaskid = 3 +) diff --git a/sys/configure/structs/Game.OpenedCond.go b/sys/configure/structs/Game.OpenedCond.go index ed98c2e01..63eaaf150 100644 --- a/sys/configure/structs/Game.OpenedCond.go +++ b/sys/configure/structs/Game.OpenedCond.go @@ -11,7 +11,7 @@ package cfg import "errors" type GameOpenedCond struct { - Key string + Key int32 Param int32 } @@ -22,7 +22,7 @@ func (*GameOpenedCond) GetTypeId() int32 { } func (_v *GameOpenedCond)Deserialize(_buf map[string]interface{}) (err error) { - { var _ok_ bool; if _v.Key, _ok_ = _buf["key"].(string); !_ok_ { err = errors.New("key error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["param"].(float64); !_ok_ { err = errors.New("param error"); return }; _v.Param = int32(_tempNum_) } return } diff --git a/sys/db/dbmodel.go b/sys/db/dbmodel.go index d741b29df..9b6ebf045 100644 --- a/sys/db/dbmodel.go +++ b/sys/db/dbmodel.go @@ -441,7 +441,7 @@ func (this *DBModel) GetList(uid string, data interface{}) (err error) { buf := make([]byte, 4096) l := runtime.Stack(buf, false) err = fmt.Errorf("%v: %s", r, buf[:l]) - log.Errorf("[DB GetList] TableName:%s uid:%s", this.TableName, uid) + log.Errorf("[DB GetList] TableName:%s uid:%s err:%v", this.TableName, uid, err) } }() var (