世界任务通知事件
This commit is contained in:
parent
82220d8ed1
commit
392c7d3ecf
@ -34,6 +34,7 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options
|
||||
|
||||
func (this *Worldtask) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
event.RegisterGO(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
@ -54,15 +55,18 @@ func (this *Worldtask) Start() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds []int32) error {
|
||||
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condIds", Value: condIds})
|
||||
uid := session.GetUserId()
|
||||
func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) {
|
||||
session, ok:= this.GetUserSession(uid)
|
||||
if !ok{
|
||||
return
|
||||
}
|
||||
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condIds", Value: conids})
|
||||
|
||||
// 玩家世界任务
|
||||
userTask, err := this.modelWorldtask.getWorldtask(uid)
|
||||
if err != nil {
|
||||
this.Error("获取玩家世界任务", log.Field{Key: "uid", Value: uid})
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
var groupId, taskId int32
|
||||
@ -70,7 +74,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds [
|
||||
finishedTaskIds := make(map[int32]int32) //达成的任务条件
|
||||
for _, c := range this.worldtaskConf.GetDataList() {
|
||||
for _, v := range c.Completetask {
|
||||
for _, condId := range condIds {
|
||||
for _, condId := range conids {
|
||||
if v == condId {
|
||||
//校验任务是否是当前任务
|
||||
if task, ok := userTask.CurrentTask[c.Group]; ok {
|
||||
@ -90,7 +94,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds [
|
||||
// this.Debug("未找到通知的世界任务",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "finishedTaskIds", Value: finishedTaskIds})
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
if userTask.CurrentTask == nil {
|
||||
@ -102,7 +106,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds [
|
||||
wt = &pb.Worldtask{}
|
||||
}
|
||||
|
||||
for _, condId := range condIds {
|
||||
for _, condId := range conids {
|
||||
if _, ok := utils.Findx(wt.CondiIds, condId); !ok {
|
||||
wt.CondiIds = append(wt.CondiIds, condId)
|
||||
}
|
||||
@ -127,7 +131,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds [
|
||||
// 当前任务配置
|
||||
curTaskConf, err := this.configure.getWorldtaskById(taskId)
|
||||
if err != nil || curTaskConf == nil {
|
||||
return comm.NewCustomError(pb.ErrorCode_ConfigNoFound)
|
||||
return
|
||||
}
|
||||
|
||||
//结束任务
|
||||
@ -135,6 +139,11 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds [
|
||||
this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf)
|
||||
this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds []int32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user