From ead9a69a4462d2c4601b2a936bb3fb4c5b2ed1fc Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 6 Jul 2023 10:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BE=E9=81=A3=E6=B7=BB=E5=8A=A0=E9=98=B5?= =?UTF-8?q?=E8=90=A5=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dispatch/configure.go | 19 ++++++++ modules/dispatch/model_dispatch.go | 48 +++++++++++++++++-- modules/hero/configure_comp.go | 1 + .../structs/Game.DispatchCondType.go | 1 + 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/modules/dispatch/configure.go b/modules/dispatch/configure.go index 4c02b8199..ebb4b0cdf 100644 --- a/modules/dispatch/configure.go +++ b/modules/dispatch/configure.go @@ -2,6 +2,7 @@ package dispatch import ( "fmt" + "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" @@ -10,6 +11,7 @@ import ( const ( gameDispatchLv = "game_dispatch_lv.json" gameDispatchTask = "game_dispatch_task.json" + new_hero = "game_hero.json" //英雄 ) type configureComp struct { @@ -21,6 +23,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp err = this.LoadMultiConfigure(map[string]interface{}{ gameDispatchLv: cfg.NewGameDispatch_Lv, gameDispatchTask: cfg.NewGameDispatch_Task, + new_hero: cfg.NewGameHero, }) return } @@ -88,3 +91,19 @@ func (this *configureComp) getDispatchTaskConfByType(typeId int32) (list []*cfg. } return } + +// 获取英雄配置 +func (this *configureComp) GetHeroConfig(heroCfgId string) (conf *cfg.GameHeroData, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(new_hero); err == nil { + if configure, ok := v.(*cfg.GameHero); ok { + if conf, ok = configure.GetDataMap()[heroCfgId]; ok { + return + } + } + } + err = comm.NewNotFoundConfErr("dispatch", new_hero, heroCfgId) + return +} diff --git a/modules/dispatch/model_dispatch.go b/modules/dispatch/model_dispatch.go index bd3185ef7..c6008d332 100644 --- a/modules/dispatch/model_dispatch.go +++ b/modules/dispatch/model_dispatch.go @@ -239,19 +239,59 @@ func (this *modelDispatch) validHeroCond(uid string, taskId int32, heroId string if code == nil && hero != nil { for _, v := range gd.Taskreq { - switch v.Key { - case 1: //校验英雄的基础条件 + if v.Key == 1 { if hero.Lv >= v.Param { ok1 = true + } else { + ok1 = false + break + } + } else if v.Key == 2 { + if hero.Star >= v.Param { + ok1 = true + } else { + ok1 = false + break + } + } else if v.Key == 3 { + hcfg, err2 := this.module.configure.GetHeroConfig(hero.HeroID) + if err2 != nil { + return false, false, err2 + } + if hcfg.Race == v.Param { + ok1 = true + } else { + ok1 = false + break } } } for _, v := range gd.Taskreqex { - switch v.Key { - case 2: //校验英雄的额外要求 + if v.Key == 1 { + if hero.Lv >= v.Param { + ok2 = true + } else { + ok2 = false + break + } + } else if v.Key == 2 { if hero.Star >= v.Param { ok2 = true + } else { + ok2 = false + break + } + } else if v.Key == 3 { + hcfg, err2 := this.module.configure.GetHeroConfig(hero.HeroID) + if err2 != nil { + return false, false, err2 + } + if hcfg.Race == v.Param { + ok2 = true + } else { + ok2 = false + break } } } diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index a9cbb86df..3eeeb97c1 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -1,3 +1,4 @@ + package hero import ( diff --git a/sys/configure/structs/Game.DispatchCondType.go b/sys/configure/structs/Game.DispatchCondType.go index 347eb7b26..5959a2a8b 100644 --- a/sys/configure/structs/Game.DispatchCondType.go +++ b/sys/configure/structs/Game.DispatchCondType.go @@ -11,4 +11,5 @@ package cfg const ( GameDispatchCondType_Lv = 1 GameDispatchCondType_Star = 2 + GameDispatchCondType_Race = 3 )