Compare commits

..

2 Commits

4 changed files with 65 additions and 4 deletions

View File

@ -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
}

View File

@ -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
}
}
}

View File

@ -1,3 +1,4 @@
package hero
import (

View File

@ -11,4 +11,5 @@ package cfg
const (
GameDispatchCondType_Lv = 1
GameDispatchCondType_Star = 2
GameDispatchCondType_Race = 3
)