diff --git a/modules/practice/api_receive.go b/modules/practice/api_receive.go index cf7d8d047..017741d89 100644 --- a/modules/practice/api_receive.go +++ b/modules/practice/api_receive.go @@ -158,7 +158,11 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.PracticeReceiveR if len(tconfigure.Ants) > 0 { //额外道具加成 ants1 = make([]*cfg.Gameatn, 0) r := rand.New(rand.NewSource(time.Now().Unix())) - num := r.Int31n(tconfigure.Num[1]-tconfigure.Num[0]) + tconfigure.Num[0] + interval := tconfigure.Num[1] - tconfigure.Num[0] + num := tconfigure.Num[0] + if interval > 0 { + num = r.Int31n(interval) + tconfigure.Num[0] + } if r.Int31n(100) < tconfigure.Probability { //随机一个道具 total := 0 for _, v := range tconfigure.Wget { diff --git a/modules/practice/configure.go b/modules/practice/configure.go index b6b3407e6..af6ea49a3 100644 --- a/modules/practice/configure.go +++ b/modules/practice/configure.go @@ -4,6 +4,7 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" @@ -20,7 +21,7 @@ const ( game_dispatch_battle = "game_dispatch_battle.json" ) -///背包配置管理组件 +// /背包配置管理组件 type configureComp struct { modules.MCompConfigure module *Practice @@ -28,13 +29,12 @@ type configureComp struct { buffs map[int32][]*cfg.GamePandamasBuffData } -//组件初始化接口 +// 组件初始化接口 func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.MCompConfigure.Init(service, module, comp, options) this.module = module.(*Practice) this.LoadConfigure(game_pandamasmz, cfg.NewGamePandamasMz) this.LoadConfigure(game_pandamasjs, cfg.NewGamePandamasJs) - this.LoadConfigure(game_pandamasjx, cfg.NewGamePandamasJx) this.LoadConfigure(game_pandamasyxjx, cfg.NewGamePandamasYxjx) this.LoadConfigure(game_pandamasmryl, cfg.NewGamePandamasMryl) this.LoadConfigure(game_dispatch_battle, cfg.NewGameDispatch_Battle) @@ -55,6 +55,20 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp } this.lock.Unlock() }) + + configure.RegisterConfigure(game_pandamasjx, cfg.NewGamePandamasJx, func() { + if v, err := this.GetConfigure(game_pandamasjx); err != nil { + this.module.Errorf("err:%v", err) + this.lock.Unlock() + return + } else { + for _, v := range v.(*cfg.GamePandamasJx).GetDataList() { + if len(v.Ants) > 0 && (len(v.Num) != 2 || v.Num[1] < v.Num[0]) { + this.module.Error("配置错误!", log.Field{Key: "Num", Value: v.Num}) + } + } + } + }) return } @@ -156,7 +170,7 @@ func (this *configureComp) getPandamasMryl(id int32) (configure *cfg.GamePandama return } -//随机获取buff权重 +// 随机获取buff权重 func (this *configureComp) getGamePandamasBuff(groupid int32) (configure *cfg.GamePandamasBuffData, err error) { var ( group []*cfg.GamePandamasBuffData @@ -181,7 +195,7 @@ func (this *configureComp) getGamePandamasBuff(groupid int32) (configure *cfg.Ga return } -//获取踢馆npc配置 +// 获取踢馆npc配置 func (this *configureComp) getDispatchBattle() (configure []*cfg.GameDispatch_BattleData, err error) { var ( v interface{} @@ -195,7 +209,7 @@ func (this *configureComp) getDispatchBattle() (configure []*cfg.GameDispatch_Ba return } -//获取踢馆npc配置 +// 获取踢馆npc配置 func (this *configureComp) getDispatchBattleData(id int32) (configure *cfg.GameDispatch_BattleData, err error) { var ( v interface{}