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