派遣添加阵营条件

This commit is contained in:
wh_zcy 2023-07-06 10:53:47 +08:00
parent 460725a94f
commit ead9a69a44
4 changed files with 65 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package dispatch
import ( import (
"fmt" "fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
@ -10,6 +11,7 @@ import (
const ( const (
gameDispatchLv = "game_dispatch_lv.json" gameDispatchLv = "game_dispatch_lv.json"
gameDispatchTask = "game_dispatch_task.json" gameDispatchTask = "game_dispatch_task.json"
new_hero = "game_hero.json" //英雄
) )
type configureComp struct { type configureComp struct {
@ -21,6 +23,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = this.LoadMultiConfigure(map[string]interface{}{ err = this.LoadMultiConfigure(map[string]interface{}{
gameDispatchLv: cfg.NewGameDispatch_Lv, gameDispatchLv: cfg.NewGameDispatch_Lv,
gameDispatchTask: cfg.NewGameDispatch_Task, gameDispatchTask: cfg.NewGameDispatch_Task,
new_hero: cfg.NewGameHero,
}) })
return return
} }
@ -88,3 +91,19 @@ func (this *configureComp) getDispatchTaskConfByType(typeId int32) (list []*cfg.
} }
return 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 { if code == nil && hero != nil {
for _, v := range gd.Taskreq { for _, v := range gd.Taskreq {
switch v.Key { if v.Key == 1 {
case 1: //校验英雄的基础条件
if hero.Lv >= v.Param { if hero.Lv >= v.Param {
ok1 = true 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 { for _, v := range gd.Taskreqex {
switch v.Key { if v.Key == 1 {
case 2: //校验英雄的额外要求 if hero.Lv >= v.Param {
ok2 = true
} else {
ok2 = false
break
}
} else if v.Key == 2 {
if hero.Star >= v.Param { if hero.Star >= v.Param {
ok2 = true 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 package hero
import ( import (

View File

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