76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
package wtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const modulename = "世界任务"
|
|
|
|
type WTask struct {
|
|
modules.ModuleBase
|
|
api *apiComp
|
|
configure *configureComp
|
|
modelwtask *ModelWTask
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &WTask{}
|
|
}
|
|
|
|
func (this *WTask) GetType() core.M_Modules {
|
|
return comm.ModuleWorldtask
|
|
}
|
|
|
|
func (this *WTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
return
|
|
}
|
|
|
|
func (this *WTask) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelwtask = this.RegisterComp(new(ModelWTask)).(*ModelWTask)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
|
|
}
|
|
|
|
// 查询可接取任务列表
|
|
func (this *WTask) inquireActivations(lv int32, complete []int32, opencmd []string) (err error, activations []int32) {
|
|
var (
|
|
conf *cfg.GameWorldTask
|
|
completeMap map[int32]struct{} = make(map[int32]struct{})
|
|
opencmdMap map[string]struct{} = make(map[string]struct{})
|
|
ok bool
|
|
)
|
|
activations = make([]int32, 0)
|
|
if conf, err = this.configure.getWorldtaskCfg(); err != nil {
|
|
return
|
|
}
|
|
|
|
for _, v := range complete {
|
|
completeMap[v] = struct{}{}
|
|
}
|
|
for _, v := range opencmd {
|
|
opencmdMap[v] = struct{}{}
|
|
}
|
|
for _, v := range conf.GetDataList() {
|
|
if _, ok = completeMap[v.Key]; ok { //已完成
|
|
continue
|
|
}
|
|
if lv < v.Lock || lv > v.Lockend { //等级不符合
|
|
continue
|
|
}
|
|
if _, ok = completeMap[v.Ontxe]; v.Ontxe != 0 && !ok { //前置任务判断
|
|
continue
|
|
}
|
|
if v.Des == 5 { //商队任务不主动触发
|
|
continue
|
|
}
|
|
activations = append(activations, v.Key)
|
|
}
|
|
return
|
|
}
|