修复任务记录

This commit is contained in:
wh_zcy 2022-12-20 12:52:55 +08:00
parent d1fb30e587
commit 2589c198a9
2 changed files with 29 additions and 2 deletions

View File

@ -89,7 +89,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
//查找任务数据 //查找任务数据
if v, ok := record.Vals[cfg.Id]; ok { if v, ok := record.Vals[cfg.Id]; ok {
newArr := make([]int32, len(vals)) newArr := make([]int32, len(vals))
newArr = vals copy(newArr, vals)
srcCount := v.Data[0] srcCount := v.Data[0]
newArr[0] = srcCount + vals[0] newArr[0] = srcCount + vals[0]
v.Data = toMap(newArr...) v.Data = toMap(newArr...)

View File

@ -119,7 +119,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB
} }
if err := this.moduleTask.modelTask.Change(uid, update); err != nil { if err := this.moduleTask.modelTask.Change(uid, update); err != nil {
this.moduleTask.Error("change err", log.Field{Key: "uid", Value: uid})
} }
} }
@ -147,6 +147,7 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB
// 成就列表 // 成就列表
var achieveList []*pb.TaskData var achieveList []*pb.TaskData
var bflag bool
if taskTag == comm.TASK_ACHIEVE { if taskTag == comm.TASK_ACHIEVE {
for _, v := range task.AchieveList { for _, v := range task.AchieveList {
if curTask := this.moduleTask.configure.getTaskById(v.TaskId); curTask != nil { if curTask := this.moduleTask.configure.getTaskById(v.TaskId); curTask != nil {
@ -170,6 +171,32 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB
} }
} }
} }
for _, v := range achieveList {
oldVal := v.Progress
var newVal int32
if p, ok := dr.Vals[v.TypeId]; ok {
if len(p.Data) == 0 {
continue
}
newVal = p.Data[0]
if code := this.moduleTask.ModuleRtask.CheckCondi(uid, v.TypeId); code == pb.ErrorCode_Success {
v.Progress = p.Data[0]
v.Status = 1
} else {
v.Progress = p.Data[0]
}
}
if oldVal != newVal {
bflag = true
}
}
if bflag {
update["achieveList"] = achieveList
if err := this.moduleTask.modelTask.Change(uid, update); err != nil {
log.Error("err", log.Field{Key: "uid", Value: uid})
}
}
task.AchieveList = achieveList task.AchieveList = achieveList
} }