条件状态判断

This commit is contained in:
wh_zcy 2023-06-14 18:06:37 +08:00
parent 4f2660fabb
commit 1ba179f675
2 changed files with 23 additions and 8 deletions

View File

@ -20,7 +20,7 @@ const (
type configureComp struct { type configureComp struct {
modules.MCompConfigure modules.MCompConfigure
lock sync.RWMutex lock sync.RWMutex
worldtaskConf map[int32]*cfg.GameWorldTaskData worldtaskConf map[int32]*cfg.GameWorldTaskData //key 条件ID
} }
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
@ -31,6 +31,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
gameWorldAll: cfg.NewGameWorldAll, gameWorldAll: cfg.NewGameWorldAll,
gameburiedCond: cfg.NewGameBuriedCondi, gameburiedCond: cfg.NewGameBuriedCondi,
}) })
this.worldtaskConf = make(map[int32]*cfg.GameWorldTaskData)
configure.RegisterConfigure(gameWorldTask, cfg.NewGameBuriedCondi, this.updateconfigure) configure.RegisterConfigure(gameWorldTask, cfg.NewGameBuriedCondi, this.updateconfigure)
return return
} }

View File

@ -40,7 +40,6 @@ func (this *Worldtask) OnInstallComp() {
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask) this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
// conf,err = this.configure.getWorldtaskBattleCfg()
} }
@ -53,6 +52,11 @@ func (this *Worldtask) Start() (err error) {
if err = this.checkWorldtaskConf(); err != nil { if err = this.checkWorldtaskConf(); err != nil {
return err return err
} }
conf, err := this.configure.getWorldtaskCfg()
if err != nil {
return err
}
this.configure.worldtaskConf = conf.GetDataMap()
return return
} }
@ -121,8 +125,6 @@ func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
return return
} }
// 检索condId是否是世界任务的完成条件
taskConds := make(map[int32][]*pb.CurrentTask) taskConds := make(map[int32][]*pb.CurrentTask)
finishedCondIds := []*pb.ConIProgress{} finishedCondIds := []*pb.ConIProgress{}
@ -186,12 +188,24 @@ func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
if err != nil || curTaskConf == nil { if err != nil || curTaskConf == nil {
return return
} }
var flag bool
if curTaskConf.DeliverNpc == 0 { if curTaskConf.DeliverNpc == 0 {
//判断当前任务下的条件是否全部是完成状态
for _, s := range t.Conds {
if s.State == pb.BuriedItemFinishState_buried_finish {
flag = true
} else {
flag = false
}
}
if flag {
defer func() { defer func() {
this.modelWorldtask.taskFinish(session, t.TaskId, userTask, curTaskConf) this.modelWorldtask.taskFinish(session, t.TaskId, userTask, curTaskConf)
this.modelWorldtask.taskFinishPush(session, userTask, curTaskConf) this.modelWorldtask.taskFinishPush(session, userTask, curTaskConf)
}() }()
} }
}
currentTasks = append(currentTasks, t) currentTasks = append(currentTasks, t)
} }
} }