From 06315e72e712973fae4a481c3bebc932f7650cb9 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 4 Jul 2023 18:05:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A8=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_caravancity.json | 20 ++------ modules/caravan/api_gotocity.go | 10 +++- modules/caravan/comp_configure.go | 48 ++++++++++++++----- modules/caravan/module.go | 1 + modules/gm/module.go | 12 +++-- sys/configure/structs/Game.CaravanCityData.go | 17 +------ 6 files changed, 60 insertions(+), 48 deletions(-) diff --git a/bin/json/game_caravancity.json b/bin/json/game_caravancity.json index 0fed24f55..ab097ec27 100644 --- a/bin/json/game_caravancity.json +++ b/bin/json/game_caravancity.json @@ -50,9 +50,7 @@ "sptalk": 11003, "buytalk": 11004, "cityeventpro": 50000, - "cityevent": [ - 1 - ] + "cityevent": 1 }, { "id": 102, @@ -105,9 +103,7 @@ "sptalk": 11003, "buytalk": 11004, "cityeventpro": 100000, - "cityevent": [ - 1 - ] + "cityevent": 1 }, { "id": 103, @@ -161,9 +157,7 @@ "sptalk": 11003, "buytalk": 11004, "cityeventpro": 50000, - "cityevent": [ - 1 - ] + "cityevent": 1 }, { "id": 104, @@ -217,9 +211,7 @@ "sptalk": 11003, "buytalk": 11004, "cityeventpro": 100000, - "cityevent": [ - 1 - ] + "cityevent": 1 }, { "id": 105, @@ -272,8 +264,6 @@ "sptalk": 11003, "buytalk": 11004, "cityeventpro": 50000, - "cityevent": [ - 1 - ] + "cityevent": 1 } ] \ No newline at end of file diff --git a/modules/caravan/api_gotocity.go b/modules/caravan/api_gotocity.go index 1227e55be..0e2da9489 100644 --- a/modules/caravan/api_gotocity.go +++ b/modules/caravan/api_gotocity.go @@ -58,8 +58,14 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity } if bNewTask { // 到该城市随机一个新的任务 if newCity, e := this.module.configure.GetCaravanCity(req.City); e == nil { - ipos := comm.GetRandW(newCity.Cityevent) - list.Eventid = newCity.Cityevent[ipos] // 新的任务 + if elist, err := this.configure.GetCaravanEventByGroup(newCity.Cityevent); err != nil { + var randW []int32 + for _, v := range elist { + randW = append(randW, v.Eventweight) + } + list.Eventid = elist[comm.GetRandW(randW)].Id + } + // 新的任务 // list.Tasktime = configure.Now().Unix() // if event := this.module.configure.GetCaravanEventById(list.Eventid); event != nil { // list.Task = event.Worldtask // 对应世界任务组 diff --git a/modules/caravan/comp_configure.go b/modules/caravan/comp_configure.go index dc6c8c221..098e82bc0 100644 --- a/modules/caravan/comp_configure.go +++ b/modules/caravan/comp_configure.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "sync" ) var moduleName = "caravan" @@ -24,6 +25,8 @@ const ( type configureComp struct { modules.MCompConfigure module *Caravan + lock sync.RWMutex + event map[int32][]*cfg.GameCaravanEventData } //组件初始化接口 @@ -36,6 +39,19 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.LoadConfigure(game_caravan_thing, cfg.NewGameCaravanThing) this.LoadConfigure(game_caravan_event, cfg.NewGameCaravanEvent) this.LoadConfigure(game_caravan_rank, cfg.NewGameCaravanRank) + configure.RegisterConfigure(game_caravan_event, cfg.NewGameEquip, func() { + this.lock.Lock() + if v, err := this.GetConfigure(game_caravan_event); err != nil { + this.module.Errorf("err:%v", err) + return + } else { + this.event = make(map[int32][]*cfg.GameCaravanEventData, 0) + for _, v := range v.(*cfg.GameCaravanEvent).GetDataList() { + this.event[v.Eventgroup] = append(this.event[v.Eventgroup], v) + } + } + this.lock.Unlock() + }) return } @@ -139,20 +155,14 @@ func (this *configureComp) GetAllCaravanItem() (data []*cfg.GameCaravanThingData } // 获取随机事件 -func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanEventData, err error) { +func (this *configureComp) GetCaravanEventByGroup(eventgroup int32) (data []*cfg.GameCaravanEventData, err error) { var ( - v interface{} + ok bool ) - if v, err = this.GetConfigure(game_caravan_event); err == nil { - if configure, ok := v.(*cfg.GameCaravanEvent); ok { - if data = configure.Get(id); data == nil { - err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id) - this.module.Errorln(err) - } - return - } + if data, ok = this.event[eventgroup]; !ok { + err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, eventgroup) } - err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id) + return } @@ -214,3 +224,19 @@ func (this *configureComp) GetCaravanRank(index int32) (reward *cfg.GameCaravanR err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index) return } +func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanEventData, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(game_caravan_event); err == nil { + if configure, ok := v.(*cfg.GameCaravanEvent); ok { + if data = configure.Get(id); data == nil { + err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id) + this.module.Errorln(err) + } + return + } + } + err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id) + return +} diff --git a/modules/caravan/module.go b/modules/caravan/module.go index 7b50e296b..f06b0ac35 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -224,6 +224,7 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) { // 校验随机事件是否超时 func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCaravan) (bTimeOut bool) { + if data.Eventid != 0 { if list, err := this.configure.GetCaravanEventById(data.Eventid); err == nil { // 校验任务是否超时 diff --git a/modules/gm/module.go b/modules/gm/module.go index 06b5ed495..4f74d30da 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -149,11 +149,13 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er // 发所有道具 item := this.configure.GetAllItemConfigure() for _, v := range item { - res = append(res, &cfg.Gameatn{ - A: "item", - T: v.Id, - N: 100, - }) + if v.Bagtype != 0 { + res = append(res, &cfg.Gameatn{ + A: "item", + T: v.Id, + N: 100, + }) + } } errdata = this.DispenseRes(session, res, true) if errdata != nil { diff --git a/sys/configure/structs/Game.CaravanCityData.go b/sys/configure/structs/Game.CaravanCityData.go index b36c0d318..3f328da7f 100644 --- a/sys/configure/structs/Game.CaravanCityData.go +++ b/sys/configure/structs/Game.CaravanCityData.go @@ -34,7 +34,7 @@ type GameCaravanCityData struct { Sptalk int32 Buytalk int32 Cityeventpro int32 - Cityevent []int32 + Cityevent int32 } const TypeId_GameCaravanCityData = 145138895 @@ -132,20 +132,7 @@ func (_v *GameCaravanCityData)Deserialize(_buf map[string]interface{}) (err erro { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["sptalk"].(float64); !_ok_ { err = errors.New("sptalk error"); return }; _v.Sptalk = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["buytalk"].(float64); !_ok_ { err = errors.New("buytalk error"); return }; _v.Buytalk = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["cityeventpro"].(float64); !_ok_ { err = errors.New("cityeventpro error"); return }; _v.Cityeventpro = int32(_tempNum_) } - { - var _arr_ []interface{} - var _ok_ bool - if _arr_, _ok_ = _buf["cityevent"].([]interface{}); !_ok_ { err = errors.New("cityevent error"); return } - - _v.Cityevent = make([]int32, 0, len(_arr_)) - - for _, _e_ := range _arr_ { - var _list_v_ int32 - { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } - _v.Cityevent = append(_v.Cityevent, _list_v_) - } - } - + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["cityevent"].(float64); !_ok_ { err = errors.New("cityevent error"); return }; _v.Cityevent = int32(_tempNum_) } return } From 86405a4199d2f80eacd10eb98322c0200f82d898 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 4 Jul 2023 18:21:00 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/comp_configure.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/caravan/comp_configure.go b/modules/caravan/comp_configure.go index 098e82bc0..bcf911bf1 100644 --- a/modules/caravan/comp_configure.go +++ b/modules/caravan/comp_configure.go @@ -39,7 +39,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.LoadConfigure(game_caravan_thing, cfg.NewGameCaravanThing) this.LoadConfigure(game_caravan_event, cfg.NewGameCaravanEvent) this.LoadConfigure(game_caravan_rank, cfg.NewGameCaravanRank) - configure.RegisterConfigure(game_caravan_event, cfg.NewGameEquip, func() { + configure.RegisterConfigure(game_caravan_event, cfg.NewGameCaravanRank, func() { this.lock.Lock() if v, err := this.GetConfigure(game_caravan_event); err != nil { this.module.Errorf("err:%v", err) From c02bbc94c6f1a6e5b7ceadfcfa5c375be3df9350 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 4 Jul 2023 18:27:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/api_gotocity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/caravan/api_gotocity.go b/modules/caravan/api_gotocity.go index 0e2da9489..11787ad25 100644 --- a/modules/caravan/api_gotocity.go +++ b/modules/caravan/api_gotocity.go @@ -58,7 +58,7 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity } if bNewTask { // 到该城市随机一个新的任务 if newCity, e := this.module.configure.GetCaravanCity(req.City); e == nil { - if elist, err := this.configure.GetCaravanEventByGroup(newCity.Cityevent); err != nil { + if elist, err := this.module.configure.GetCaravanEventByGroup(newCity.Cityevent); err == nil { var randW []int32 for _, v := range elist { randW = append(randW, v.Eventweight) From a0c07187a29ebd8ce8cb2626a37dc5b7f8cf4bb9 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 4 Jul 2023 18:30:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/practice/api_practice.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/practice/api_practice.go b/modules/practice/api_practice.go index 113d436fd..6075f4c08 100644 --- a/modules/practice/api_practice.go +++ b/modules/practice/api_practice.go @@ -137,19 +137,22 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic return } room.Knapsack[req.Teacher].Usenum++ - if tconfigure.Race != heroconf.Race { + room.Knapsack[req.Teacher].Lastusetime = configure.Now().Unix() + if tconfigure.Race != 0 && tconfigure.Race != heroconf.Race { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: fmt.Sprintf("the teacher race:%d and the herorace:%d is race no can use", tconfigure.Race, heroconf.Race), } + return } - if tconfigure.Job != heroconf.Job { + if tconfigure.Job != 0 && tconfigure.Job != heroconf.Job { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: fmt.Sprintf("the teacher job:%d and the hero job:%d is race no can use", tconfigure.Job, heroconf.Job), } + return } if tconfigure.BanHero == hero.HeroID { //禁止使用 errdata = &pb.ErrorData{ @@ -181,7 +184,7 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic } if !utils.IsToday(room.Knapsack[req.Prop].Lastusetime) { - room.Knapsack[req.Teacher].Usenum = 0 + room.Knapsack[req.Prop].Usenum = 0 } if room.Knapsack[req.Prop].Usenum >= tconfigure.Limitation { @@ -193,20 +196,22 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic return } room.Knapsack[req.Prop].Usenum++ - - if pconfigure.Race != heroconf.Race { + room.Knapsack[req.Prop].Lastusetime = configure.Now().Unix() + if pconfigure.Race != 0 && pconfigure.Race != heroconf.Race { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: fmt.Sprintf("the teacher race:%d and the herorace:%d is race no can use", tconfigure.Race, heroconf.Race), } + return } - if pconfigure.Job != heroconf.Job { + if pconfigure.Job != 0 && pconfigure.Job != heroconf.Job { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: fmt.Sprintf("the teacher job:%d and the hero job:%d is race no can use", tconfigure.Job, heroconf.Job), } + return } extra += int32(float64(pillarconfigure.PlacementDuration) * float64(pconfigure.Duration) / float64(1000)) pillar.Prop = req.Prop