Compare commits

...

2 Commits

5 changed files with 135 additions and 25 deletions

View File

@ -37,6 +37,11 @@ func (this *modelTask) getTaskRecord(uid string) (*pb.DBTujianTask, error) {
}
func (this *modelTask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
session, ok := this.module.GetUserSession(uid)
if !ok {
this.module.Errorln("TCondFinishNotify 获取session失败")
return
}
this.module.Debug("铁匠铺任务通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "conds", Value: conds})
confList, err := this.module.configure.GetSmithyTasks()
if err != nil {
@ -62,6 +67,15 @@ func (this *modelTask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
}
if v.State == pb.BuriedItemFinishState_buried_finish {
tt.Received = 1
i, err := this.module.service.GetModule(comm.ModuleReddot)
if err != nil {
this.module.Error(err.Error())
return
}
if b, y := i.(comm.IReddot); y {
b.PushReddot(session, comm.Reddot17107)
}
}
dt.Tasks = append(dt.Tasks, tt)
if err := this.Add(uid, dt); err != nil {

View File

@ -7,6 +7,7 @@ package smithy
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
@ -18,6 +19,7 @@ import (
type Smithy struct {
modules.ModuleBase
service base.IRPCXService
modelTrade *modelTrade
api *apiComp
configure *configureComp
@ -36,7 +38,7 @@ func (this *Smithy) GetType() core.M_Modules {
func (this *Smithy) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service.(base.IRPCXService)
return
}

View File

@ -91,28 +91,47 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
return
} else {
task.NpcStatus = 1
for _, cid := range curTaskConf.Completetask {
task.Conds = append(task.Conds, &pb.ConIProgress{
Conid: cid,
})
}
}
break
} else {
if tasks.TaskMap == nil {
tasks.TaskMap = make(map[int32]*pb.Worldtask)
}
tasks.TaskMap[task.TaskId] = &pb.Worldtask{
task := &pb.Worldtask{
TaskId: req.TaskId,
TaskType: curTaskConf.Des,
NpcStatus: 1, //接取
}
for _, cid := range curTaskConf.Completetask {
task.Conds = append(task.Conds, &pb.ConIProgress{
Conid: cid,
})
}
tasks.TaskMap[task.TaskId] = task
}
}
} else {
tasks = &pb.Worldtasks{
TaskMap: make(map[int32]*pb.Worldtask),
}
tasks.TaskMap[req.TaskId] = &pb.Worldtask{
task := &pb.Worldtask{
TaskId: req.TaskId,
TaskType: curTaskConf.Des,
NpcStatus: 1, //接取
}
for _, cid := range curTaskConf.Completetask {
task.Conds = append(task.Conds, &pb.ConIProgress{
Conid: cid,
})
}
tasks.TaskMap[req.TaskId] = task
myWorldtask.CurrentTasks[curTaskConf.Group] = tasks
}

View File

@ -122,7 +122,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RtaskCondiNoReach,
Title: pb.ErrorCode_RtaskCondiNoReach.ToString(),
Message: fmt.Sprintf("世界任务[%v] 条件[%v]未达成", req.TaskId, curTaskConf.Completetask),
Message: fmt.Sprintf("世界任务[%v] 条件[%v]未达成", req.TaskId, cond.Conid),
}
return
}

View File

@ -184,28 +184,28 @@ func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
var currentTasks []*pb.CurrentTask
for _, tasks := range taskConds {
for _, t := range tasks {
curTaskConf, err := this.configure.getWorldtaskById(t.TaskId)
if err != nil || curTaskConf == nil {
return
}
var flag bool
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() {
this.modelWorldtask.taskFinish(session, t.TaskId, userTask, curTaskConf)
this.modelWorldtask.taskFinishPush(session, userTask, curTaskConf)
}()
}
// curTaskConf, err := this.configure.getWorldtaskById(t.TaskId)
// if err != nil || curTaskConf == nil {
// return
// }
// var flag bool
// if curTaskConf.DeliverNpc == 0 {
// //判断当前任务下的条件是否全部是完成状态
// for _, cond := range t.Conds {
// if cond.State == pb.BuriedItemFinishState_buried_finish {
// flag = true
// } else {
// flag = false
// }
// }
// if flag {
}
// defer func() {
// this.modelWorldtask.taskFinish(session, t.TaskId, userTask, curTaskConf)
// this.modelWorldtask.taskFinishPush(session, userTask, curTaskConf)
// }()
// }
// }
currentTasks = append(currentTasks, t)
}
}
@ -214,6 +214,81 @@ func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
session.SendMsg(string(this.GetType()), "changecondis", &pb.WorldtaskChangecondisPush{
Tasks: currentTasks,
})
for _, task := range currentTasks {
curTaskConf, err := this.configure.getWorldtaskById(task.TaskId)
if err != nil || curTaskConf == nil {
return
}
var newconds []*pb.ConIProgress
if tasks, ok := userTask.CurrentTasks[task.GroupId]; ok {
if t, ok := tasks.TaskMap[task.TaskId]; ok {
//更新cond
for _, t1 := range task.Conds {
for _, t2 := range t.Conds {
if t1.Conid == t2.Conid {
// t2 = t1
newconds = append(newconds, t1)
} else {
newconds = append(newconds, t2)
}
}
}
t.Conds = newconds
//判断所有的条件是都是
var flag bool
for _, cond := range t.Conds {
if cond.State == pb.BuriedItemFinishState_buried_finish {
flag = true
} else {
flag = false
break
}
}
if curTaskConf.DeliverNpc == 0 {
if flag {
this.modelWorldtask.taskFinish(session, t.TaskId, userTask, curTaskConf)
this.modelWorldtask.taskFinishPush(session, userTask, curTaskConf)
}
}
}
}
}
update := map[string]interface{}{
"currentTasks": userTask.CurrentTasks,
}
this.modelWorldtask.Change(uid, update)
// for _, task := range currentTasks {
// curTaskConf, err := this.configure.getWorldtaskById(task.TaskId)
// if err != nil || curTaskConf == nil {
// return
// }
// var flag bool
// if curTaskConf.DeliverNpc == 0 {
// if tasks, ok := userTask.CurrentTasks[task.GroupId]; ok {
// if t, ok := tasks.TaskMap[task.TaskId]; ok {
// for _, cond := range t.Conds {
// if cond.State == pb.BuriedItemFinishState_buried_finish {
// flag = true
// } else {
// flag = false
// }
// }
// if flag {
// this.modelWorldtask.taskFinish(session, t.TaskId, userTask, curTaskConf)
// this.modelWorldtask.taskFinishPush(session, userTask, curTaskConf)
// }
// }
// }
// }
// }
}
return