From 7d990f06c5fbeb273ea4651a4ebbeacf8165fd37 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 31 Jan 2023 15:04:58 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=94=AF=E6=8C=81=E5=A4=9A=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_opencond.json | 338 ++++++++++----------- comm/imodule.go | 2 + modules/sys/api_func.go | 19 +- modules/sys/model_sys.go | 44 ++- modules/sys/module.go | 5 + modules/user/comp_configure.go | 16 +- modules/user/model_user.go | 15 +- sys/configure/structs/Game.OpencondType.go | 16 + sys/configure/structs/Game.OpenedCond.go | 4 +- 9 files changed, 267 insertions(+), 192 deletions(-) create mode 100644 sys/configure/structs/Game.OpencondType.go diff --git a/bin/json/game_opencond.json b/bin/json/game_opencond.json index cce4953ff..19d7d8a83 100644 --- a/bin/json/game_opencond.json +++ b/bin/json/game_opencond.json @@ -7,11 +7,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -33,11 +33,11 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -59,11 +59,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -85,11 +85,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -111,11 +111,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -137,11 +137,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -163,11 +163,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -189,11 +189,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -215,11 +215,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -241,11 +241,11 @@ }, "main": [ { - "key": "platlv", - "param": 2 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -267,11 +267,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -293,11 +293,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -319,11 +319,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -345,11 +345,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -371,11 +371,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -397,11 +397,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -423,11 +423,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -449,11 +449,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -475,11 +475,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -501,11 +501,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -527,11 +527,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -553,11 +553,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -579,11 +579,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -605,11 +605,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -631,11 +631,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -657,11 +657,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -683,11 +683,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -709,11 +709,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -735,7 +735,7 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 } ], @@ -757,11 +757,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -783,11 +783,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -809,11 +809,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -835,11 +835,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -861,11 +861,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -887,11 +887,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -913,11 +913,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -939,11 +939,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -965,11 +965,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -991,11 +991,11 @@ }, "main": [ { - "key": "platlv", - "param": 999 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1017,11 +1017,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1043,11 +1043,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1069,11 +1069,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1095,11 +1095,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1121,11 +1121,11 @@ }, "main": [ { - "key": "platlv", - "param": 20 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1147,11 +1147,11 @@ }, "main": [ { - "key": "platlv", - "param": 3 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1173,11 +1173,11 @@ }, "main": [ { - "key": "platlv", - "param": 13 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1199,11 +1199,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -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,11 +1291,11 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1317,11 +1317,11 @@ }, "main": [ { - "key": "platlv", - "param": 4 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1343,11 +1343,11 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1369,11 +1369,11 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1395,11 +1395,11 @@ }, "main": [ { - "key": "platlv", - "param": 5 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1421,11 +1421,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1447,11 +1447,11 @@ }, "main": [ { - "key": "platlv", + "key": 1, "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1473,11 +1473,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1499,11 +1499,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1525,11 +1525,11 @@ }, "main": [ { - "key": "platlv", - "param": 10 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -1551,11 +1551,11 @@ }, "main": [ { - "key": "platlv", - "param": 30 + "key": 1, + "param": 1 }, { - "key": "maxmapid", + "key": 2, "param": 1 } ], @@ -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/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/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..39be355be 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,45 @@ 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 { + return "" + } + if user.Lv >= conf.Param { + flag = true + } + case 2: //关卡ID + flag = true + + case 3: //世界任务ID + module, err := this.service.GetModule(comm.ModuleWorldtask) + if err != nil { + this.moduleSys.Debugln(err) + return "" + } + if i, ok := module.(comm.IWorldtask); ok { + d := i.GetMyWorldtask(uid) + if _, ok := d.LastTaskIds[conf.Param]; ok { + flag = true + } + } + } + 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/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 } From 1a55e9119bc0b79a97031a7b5a50b99def07a307 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 31 Jan 2023 15:27:09 +0800 Subject: [PATCH 2/5] update --- modules/sys/model_sys.go | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/sys/model_sys.go b/modules/sys/model_sys.go index 39be355be..c5d467292 100644 --- a/modules/sys/model_sys.go +++ b/modules/sys/model_sys.go @@ -43,30 +43,58 @@ func (this *ModelSys) validCond(uid string, condData *cfg.GameOpencondData) stri 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 - flag = true + 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 - } + } + + if flag { + return condData.Id } return "" } From 3c8acf03929699c271a4a52798e28f664be90d44 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 31 Jan 2023 17:06:45 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=9C=88=E5=AD=90?= =?UTF-8?q?=E7=A7=98=E5=A2=83=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 1 + modules/items/modelitems.go | 1 + modules/moonfantasy/api_battle.go | 10 +++++++--- modules/moonfantasy/api_getlist.go | 11 ++++++----- modules/moonfantasy/modelUserMF.go | 3 +-- modules/rtimepvp/api.go | 29 +++++++++++++++++++++++++++++ modules/rtimepvp/module.go | 28 ++++++++++++++++++++++++++++ services/comp_gateroute.go | 19 +++++++++---------- sys/db/dbmodel.go | 2 +- 9 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 modules/rtimepvp/api.go create mode 100644 modules/rtimepvp/module.go 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/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/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/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/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 ( From 67e02f6b8278c7b8682eda571956452d45877929 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 31 Jan 2023 17:20:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_opencond.json | 114 ++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/bin/json/game_opencond.json b/bin/json/game_opencond.json index 19d7d8a83..54e480d28 100644 --- a/bin/json/game_opencond.json +++ b/bin/json/game_opencond.json @@ -12,7 +12,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -38,7 +38,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -64,7 +64,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -90,7 +90,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -116,7 +116,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -142,7 +142,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -168,7 +168,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -194,7 +194,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -220,7 +220,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -246,7 +246,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -272,7 +272,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -298,7 +298,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -324,7 +324,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -350,7 +350,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -376,7 +376,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -402,7 +402,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -428,7 +428,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -454,7 +454,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -480,7 +480,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -506,7 +506,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -532,7 +532,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -558,7 +558,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -584,7 +584,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -610,7 +610,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -636,7 +636,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -662,7 +662,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -688,7 +688,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -714,7 +714,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -762,7 +762,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -788,7 +788,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -814,7 +814,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -840,7 +840,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -866,7 +866,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -892,7 +892,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -918,7 +918,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -944,7 +944,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -970,7 +970,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -996,7 +996,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1022,7 +1022,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1048,7 +1048,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1074,7 +1074,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1100,7 +1100,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1126,7 +1126,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1152,7 +1152,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1178,7 +1178,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1204,7 +1204,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1296,7 +1296,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1322,7 +1322,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1348,7 +1348,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1374,7 +1374,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1400,7 +1400,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1426,7 +1426,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1452,7 +1452,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1478,7 +1478,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1504,7 +1504,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1530,7 +1530,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", @@ -1556,7 +1556,7 @@ }, { "key": 2, - "param": 1 + "param": 1100101 } ], "optional": "", From f13707e51b260b7b25d08975b935c12286a6e6b6 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 31 Jan 2023 18:19:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=8A=A0=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/friend/model_friend.go | 5 +++++ modules/rtask/model_record.go | 5 +++++ modules/sociaty/model_sociaty.go | 3 +++ 3 files changed, 13 insertions(+) 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/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/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()