Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
b1075b08f4
@ -4,7 +4,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 0,
|
||||
"id_after": 20020,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -41,7 +41,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20010,
|
||||
"id_after": 20030,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -78,7 +78,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20020,
|
||||
"id_after": 20040,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -113,7 +113,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20030,
|
||||
"id_after": 20050,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -148,7 +148,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20040,
|
||||
"id_after": 20060,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -183,7 +183,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20050,
|
||||
"id_after": 20070,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -218,7 +218,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20060,
|
||||
"id_after": 20080,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -253,7 +253,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20070,
|
||||
"id_after": 20090,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -288,7 +288,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20080,
|
||||
"id_after": 20100,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -323,7 +323,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20090,
|
||||
"id_after": 0,
|
||||
"group": 2,
|
||||
"group": 20010,
|
||||
"des": 2,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -358,7 +358,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20010,
|
||||
"id_after": 0,
|
||||
"group": 3,
|
||||
"group": 30010,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -393,7 +393,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20020,
|
||||
"id_after": 40020,
|
||||
"group": 4,
|
||||
"group": 30020,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -428,7 +428,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 40010,
|
||||
"id_after": 0,
|
||||
"group": 4,
|
||||
"group": 30020,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -463,7 +463,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20030,
|
||||
"id_after": 50011,
|
||||
"group": 5,
|
||||
"group": 30030,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -498,7 +498,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 50010,
|
||||
"id_after": 0,
|
||||
"group": 5,
|
||||
"group": 30030,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -533,7 +533,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20040,
|
||||
"id_after": 0,
|
||||
"group": 6,
|
||||
"group": 30040,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -568,7 +568,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20050,
|
||||
"id_after": 0,
|
||||
"group": 7,
|
||||
"group": 30050,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -603,7 +603,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20060,
|
||||
"id_after": 0,
|
||||
"group": 8,
|
||||
"group": 30060,
|
||||
"des": 3,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -638,7 +638,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20050,
|
||||
"id_after": 0,
|
||||
"group": 100,
|
||||
"group": 10010,
|
||||
"des": 1,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
@ -673,7 +673,7 @@
|
||||
"lock": 1,
|
||||
"ontxe": 20050,
|
||||
"id_after": 0,
|
||||
"group": 200,
|
||||
"group": 40010,
|
||||
"des": 4,
|
||||
"icon": "",
|
||||
"task_Tname": {
|
||||
|
@ -79,16 +79,8 @@ func (this *modelDispatch) getDBDispatch(uid string) (dis *pb.DBDispatch) {
|
||||
}
|
||||
|
||||
// 获取随机任务ID
|
||||
func (this *modelDispatch) getTasksWeight(d *pb.DBDispatch) int32 {
|
||||
if d == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
if d.Nb == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
conf, err := this.module.configure.getDispatchLvConf(d.Nb.Lv)
|
||||
func (this *modelDispatch) getTasksWeight(lv int32) int32 {
|
||||
conf, err := this.module.configure.getDispatchLvConf(lv)
|
||||
if err != nil || conf == nil {
|
||||
this.module.Error("配置不存在", log.Field{Key: "error", Value: err})
|
||||
return 0
|
||||
@ -124,18 +116,19 @@ func (this *modelDispatch) taskRandom(uid string, dispatch *pb.DBDispatch) (task
|
||||
//随机任务
|
||||
tasks = this.randomTask(dispatch, noticeNum)
|
||||
} else {
|
||||
var randCount int
|
||||
// var randCount int
|
||||
for i := 0; i < len(dispatch.Nb.Tasks); i++ {
|
||||
//只随机未接取的任务
|
||||
if dispatch.Nb.Tasks[i].Status == 0 {
|
||||
//删除
|
||||
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks[:i], dispatch.Nb.Tasks[i+1:]...)
|
||||
i--
|
||||
randCount++
|
||||
// dispatch.Nb.Tasks = append(dispatch.Nb.Tasks[:i], dispatch.Nb.Tasks[i+1:]...)
|
||||
dispatch.Nb.Tasks[i] = this.addOneRandomTask(dispatch)
|
||||
// i--
|
||||
// randCount++
|
||||
}
|
||||
}
|
||||
//追加随机
|
||||
tasks = append(tasks, this.addRandomTask(dispatch, randCount)...)
|
||||
// tasks = append(tasks, this.addRandomTask(dispatch, randCount)...)
|
||||
}
|
||||
|
||||
return
|
||||
@ -144,16 +137,16 @@ func (this *modelDispatch) taskRandom(uid string, dispatch *pb.DBDispatch) (task
|
||||
func (this *modelDispatch) randomTask(dispatch *pb.DBDispatch, n int) (tasks []*pb.DispatchTask) {
|
||||
total := 0
|
||||
for total < n {
|
||||
rid := this.getTasksWeight(dispatch)
|
||||
rid := this.getTasksWeight(dispatch.Nb.Lv)
|
||||
if rid == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(dispatch.Nb.Tasks) == 0 {
|
||||
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks, &pb.DispatchTask{
|
||||
TaskId: rid,
|
||||
})
|
||||
total++
|
||||
} else {
|
||||
// if len(tasks) == 0 {
|
||||
// tasks = append(tasks, &pb.DispatchTask{
|
||||
// TaskId: rid,
|
||||
// })
|
||||
// total++
|
||||
// } else {
|
||||
//去重
|
||||
exist := false
|
||||
for _, v := range dispatch.Nb.Tasks {
|
||||
@ -161,18 +154,19 @@ func (this *modelDispatch) randomTask(dispatch *pb.DBDispatch, n int) (tasks []*
|
||||
exist = true
|
||||
}
|
||||
}
|
||||
//不存在
|
||||
if !exist {
|
||||
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks, &pb.DispatchTask{
|
||||
tasks = append(tasks, &pb.DispatchTask{
|
||||
TaskId: rid,
|
||||
})
|
||||
total++
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//更新任务持续截至时间
|
||||
for _, task := range dispatch.Nb.Tasks {
|
||||
for _, task := range tasks {
|
||||
taskConf, err := this.module.configure.getDispatchTaskConf(task.TaskId)
|
||||
if err != nil {
|
||||
return nil
|
||||
@ -182,12 +176,19 @@ func (this *modelDispatch) randomTask(dispatch *pb.DBDispatch, n int) (tasks []*
|
||||
duration := configure.Now().Unix() + int64(taskConf.Taskcd)
|
||||
task.Duration = duration
|
||||
}
|
||||
tasks = append(tasks, task)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelDispatch) addOneRandomTask(dispatch *pb.DBDispatch) (task *pb.DispatchTask) {
|
||||
tasks := this.randomTask(dispatch, 1)
|
||||
if len(tasks) == 1 {
|
||||
task = tasks[0]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelDispatch) addRandomTask(dispatch *pb.DBDispatch, n int) (tasks []*pb.DispatchTask) {
|
||||
if n <= 0 {
|
||||
tasks = dispatch.Nb.Tasks
|
||||
@ -199,7 +200,7 @@ func (this *modelDispatch) addRandomTask(dispatch *pb.DBDispatch, n int) (tasks
|
||||
|
||||
// 替换指定的已完成任务
|
||||
func (this *modelDispatch) replaceTask(uid string, taskId int32, dispatch *pb.DBDispatch) (tasks []*pb.DispatchTask, oldTask *pb.DispatchTask) {
|
||||
var randCount int
|
||||
// var randCount int
|
||||
for i := 0; i < len(dispatch.Nb.Tasks); i++ {
|
||||
//替换状态是完成的任务
|
||||
if dispatch.Nb.Tasks[i].Status == 2 {
|
||||
@ -207,15 +208,15 @@ func (this *modelDispatch) replaceTask(uid string, taskId int32, dispatch *pb.DB
|
||||
continue
|
||||
}
|
||||
oldTask = dispatch.Nb.Tasks[i]
|
||||
//删除
|
||||
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks[:i], dispatch.Nb.Tasks[i+1:]...)
|
||||
i--
|
||||
randCount++
|
||||
//替换
|
||||
dispatch.Nb.Tasks[i] = this.addOneRandomTask(dispatch)
|
||||
// i--
|
||||
// randCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
tasks = append(tasks, this.addRandomTask(dispatch, randCount)...)
|
||||
// tasks = append(tasks, this.addRandomTask(dispatch, randCount)...)
|
||||
return
|
||||
}
|
||||
|
||||
@ -389,8 +390,9 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
|
||||
//判断到期时间
|
||||
if dispatch.Nb.Tasks[i].Duration != 0 &&
|
||||
dispatch.Nb.Tasks[i].Duration <= configure.Now().Unix() {
|
||||
//替换到期任务
|
||||
//删除到期任务
|
||||
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks[:i], dispatch.Nb.Tasks[i+1:]...)
|
||||
//
|
||||
i--
|
||||
randCount++
|
||||
}
|
||||
|
@ -74,11 +74,6 @@ func (this *apiComp) CompleteCondi(session comm.IUserSession, req *pb.WorldtaskC
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "completecondi", rsp)
|
||||
|
||||
//判断是否要结束任务
|
||||
if curTaskConf.DeliverNpc == 0 {
|
||||
//结束任务
|
||||
this.module.modelWorldtask.taskFinish(session, req.GroupId, req.TaskId, myWorldtask, curTaskConf)
|
||||
this.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -111,6 +111,17 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in
|
||||
log.Field{Key: "condiIds", Value: wt.CondiIds},
|
||||
log.Field{Key: "taskId", Value: taskId})
|
||||
|
||||
//判断是否要结束任务
|
||||
// 当前任务配置
|
||||
curTaskConf, err := this.configure.getWorldtaskById(taskId)
|
||||
if err != nil || curTaskConf == nil {
|
||||
return comm.NewCustomError(pb.ErrorCode_ConfigNoFound)
|
||||
}
|
||||
if curTaskConf.DeliverNpc == 0 {
|
||||
//结束任务
|
||||
this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf)
|
||||
this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user