272 lines
8.5 KiB
Go
272 lines
8.5 KiB
Go
![]() |
package logic
|
|||
|
|
|||
|
//type PlayerTask struct {
|
|||
|
// Id uint32 `bson:"id" key:"1"`
|
|||
|
// Process []int `bson:"process"` //进度
|
|||
|
// Okay []bool `bson:"nice"` //点赞
|
|||
|
// Status uint32 `bson:"status"` //任务状态:0.未完成,1.已完成,2.已提交(已领取)
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *PlayerTask) BuildMsgTask() *proto.Task {
|
|||
|
// return &proto.Task{Id: this.Id, Process: this.Process, Status: this.Status}
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) checkTaskCompetedAhead(task *PlayerTask, taskTable *data.Task) {
|
|||
|
// if proto.TaskType(taskTable.TaskType) != proto.TaskTypeMainline {
|
|||
|
// return
|
|||
|
// }
|
|||
|
//
|
|||
|
// var changed = false
|
|||
|
// var completed = true
|
|||
|
// for i := range taskTable.Section1 {
|
|||
|
// switch proto.TaskSection1(taskTable.Section1[i]) {
|
|||
|
// case proto.TaskSection1PassSpecificScene:
|
|||
|
// if len(taskTable.Section2) > 0 && taskTable.Section2[i] > 0 {
|
|||
|
// changed = this.processTask(task, taskTable, i, int(this.GetCopyPassedNum(uint32(taskTable.Section2[i])))) || changed
|
|||
|
// }
|
|||
|
// case proto.TaskSection1HeadComponentMaxLevel:
|
|||
|
// changed = this.processTask(task, taskTable, i, int(this.GetRigCompnentLevels(proto.EquipTypeHead))) || changed
|
|||
|
// case proto.TaskSection1BodyComponentMaxLevel:
|
|||
|
// changed = this.processTask(task, taskTable, i, int(this.GetRigCompnentLevels(proto.EquipTypeBody))) || changed
|
|||
|
// case proto.TaskSection1TailComponentMaxLevel:
|
|||
|
// changed = this.processTask(task, taskTable, i, int(this.GetRigCompnentLevels(proto.EquipTypeTail))) || changed
|
|||
|
// case proto.TaskSection1ComponentsAllLevels:
|
|||
|
// changed = this.processTask(task, taskTable, i, int(this.GetAllRigCompnentLevels())) || changed
|
|||
|
// default:
|
|||
|
// return
|
|||
|
// }
|
|||
|
// completed = completed && task.Okay[i]
|
|||
|
// }
|
|||
|
// if completed {
|
|||
|
// task.Status = uint32(proto.TaskStatusCompleted)
|
|||
|
// }
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) addTask(taskTable *data.Task) *PlayerTask {
|
|||
|
//
|
|||
|
// if taskTable.Id == 200002 {
|
|||
|
// this.manager.logger.Error("200002")
|
|||
|
// }
|
|||
|
//
|
|||
|
// var task = &PlayerTask{Id: uint32(taskTable.Id), Process: make([]int, len(taskTable.Section1)), Okay: make([]bool, len(taskTable.Section1))}
|
|||
|
// this.Task[task.Id] = task
|
|||
|
// this.checkTaskCompetedAhead(task, taskTable)
|
|||
|
// this.SaveModel(task)
|
|||
|
//
|
|||
|
// this.manager.eventManager.PlayerTaskLog(this, LogTypeTaskAdd, uint32(taskTable.Id), taskTable.Section1, taskTable.Section2, taskTable.Section3)
|
|||
|
// return task
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) AddTask(taskIds ...int) {
|
|||
|
// if len(taskIds) == 0 {
|
|||
|
// return
|
|||
|
// }
|
|||
|
//
|
|||
|
// var changeList []*proto.TaskChange
|
|||
|
// for _, taskId := range taskIds {
|
|||
|
// var task = this.Task[uint32(taskId)]
|
|||
|
// if task != nil {
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// var taskTable = this.manager.tables.Task.Get(taskId)
|
|||
|
// if taskTable == nil {
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// task = this.addTask(taskTable)
|
|||
|
// changeList = append(changeList, &proto.TaskChange{Task: task.BuildMsgTask(), ChangeType: uint32(proto.ChangeTypeAdd)})
|
|||
|
// }
|
|||
|
// if len(changeList) > 0 {
|
|||
|
// _ = this.Send(proto.ModIdTask, proto.MsgIdTaskChange, &proto.MsgTaskChangeListAck{List: changeList})
|
|||
|
// }
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) checkTaskDeprecated() (changed bool) {
|
|||
|
// for id, task := range this.Task {
|
|||
|
// if taskTable := this.manager.tables.Task.Get(int(id)); taskTable == nil {
|
|||
|
// delete(this.Task, id)
|
|||
|
// this.WipeModel(task)
|
|||
|
// changed = true
|
|||
|
// }
|
|||
|
// }
|
|||
|
// return
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) checkTaskReset(taskType proto.TaskType) (changed bool) {
|
|||
|
// if taskType == proto.TaskTypeLevelJudge {
|
|||
|
// return false
|
|||
|
// }
|
|||
|
//
|
|||
|
// var list []*proto.TaskChange
|
|||
|
// var taskTables = this.manager.tables.TaskExtend.Get(int(taskType))
|
|||
|
// for _, taskTable := range taskTables {
|
|||
|
// var task = this.Task[uint32(taskTable.Id)]
|
|||
|
// if task != nil {
|
|||
|
// task.Process = make([]int, len(taskTable.Section1))
|
|||
|
// task.Okay = make([]bool, len(taskTable.Section1))
|
|||
|
// task.Status = uint32(proto.TaskStatusIncomplete)
|
|||
|
// list = append(list, &proto.TaskChange{Task: task.BuildMsgTask(), ChangeType: uint32(proto.ChangeTypeChange)})
|
|||
|
// } else {
|
|||
|
// task = this.addTask(taskTable)
|
|||
|
// list = append(list, &proto.TaskChange{Task: task.BuildMsgTask(), ChangeType: uint32(proto.ChangeTypeAdd)})
|
|||
|
// }
|
|||
|
//
|
|||
|
// this.SaveModel(task)
|
|||
|
// this.ResetCounterDaily(proto.CounterTypeTaskCompleted, task.Id)
|
|||
|
// changed = true
|
|||
|
// }
|
|||
|
//
|
|||
|
// _ = this.Send(proto.ModIdTask, proto.MsgIdTaskChange, &proto.MsgTaskChangeListAck{List: list})
|
|||
|
// return
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) CheckTask(section1 proto.TaskSection1, section2, value int) bool {
|
|||
|
// var changeList []*proto.TaskChange
|
|||
|
// for _, task := range this.Task {
|
|||
|
// var taskTable = this.manager.tables.Task.Get(int(task.Id))
|
|||
|
// if taskTable == nil {
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// if proto.TaskType(taskTable.TaskType) == proto.TaskTypeLevelJudge {
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// if proto.TaskStatus(task.Status) >= proto.TaskStatusCompleted {
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// var changed = false
|
|||
|
// if len(task.Process) != len(taskTable.Section1) {
|
|||
|
// var process = task.Process
|
|||
|
// var okay = task.Okay
|
|||
|
//
|
|||
|
// task.Process = make([]int, len(taskTable.Section1))
|
|||
|
// task.Okay = make([]bool, len(taskTable.Section1))
|
|||
|
//
|
|||
|
// copy(task.Process, process)
|
|||
|
// copy(task.Okay, okay)
|
|||
|
//
|
|||
|
// changed = true
|
|||
|
// }
|
|||
|
//
|
|||
|
// var completed = true
|
|||
|
// for i := range taskTable.Section1 {
|
|||
|
// if task.Okay[i] {
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// if proto.TaskSection1(taskTable.Section1[i]) != section1 {
|
|||
|
// completed = false
|
|||
|
// continue
|
|||
|
// }
|
|||
|
//
|
|||
|
// if len(taskTable.Section2) > 0 && taskTable.Section2[i] > 0 {
|
|||
|
// if section2 != taskTable.Section2[i] {
|
|||
|
// completed = false
|
|||
|
// continue
|
|||
|
// }
|
|||
|
// }
|
|||
|
//
|
|||
|
// changed = this.processTask(task, taskTable, i, value) || changed
|
|||
|
// completed = completed && task.Okay[i]
|
|||
|
// }
|
|||
|
//
|
|||
|
// if changed {
|
|||
|
// if completed {
|
|||
|
// task.Status = uint32(proto.TaskStatusCompleted)
|
|||
|
// }
|
|||
|
// this.SaveModel(task)
|
|||
|
// changeList = append(changeList, &proto.TaskChange{Task: task.BuildMsgTask(), ChangeType: uint32(proto.ChangeTypeChange)})
|
|||
|
// }
|
|||
|
// }
|
|||
|
//
|
|||
|
// if len(changeList) == 0 {
|
|||
|
// return false
|
|||
|
// }
|
|||
|
//
|
|||
|
// _ = this.Send(proto.ModIdTask, proto.MsgIdTaskChange, &proto.MsgTaskChangeListAck{List: changeList})
|
|||
|
// return true
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) processTask(task *PlayerTask, taskTable *data.Task, i, value int) bool {
|
|||
|
// switch proto.TaskSection1(taskTable.Section1[i]) {
|
|||
|
// case proto.TaskSection1PassSpecificScene,
|
|||
|
// proto.TaskSection1PassAnyScene,
|
|||
|
// proto.TaskSection1CollectSpecificItem,
|
|||
|
// proto.TaskSection1PassedClassifyCopies,
|
|||
|
// proto.TaskSection1KillSpecificMonster,
|
|||
|
// proto.TaskSection1LoginDays,
|
|||
|
// proto.TaskSection1BoughtInSpecificStore,
|
|||
|
// proto.TaskSection1SmelterSmeltTimes,
|
|||
|
// proto.TaskSection1InfrastructureProduce,
|
|||
|
// proto.TaskSection1GetIdleBattleRewards,
|
|||
|
// proto.TaskSection1KillClassifyMonsters,
|
|||
|
// proto.TaskSection1UpgradeHeadComponents,
|
|||
|
// proto.TaskSection1UpgradeBodyComponents,
|
|||
|
// proto.TaskSection1UpgradeTailComponents,
|
|||
|
// proto.TaskSection1LevelBattleScore,
|
|||
|
// proto.TaskSection1UpgradeComponents,
|
|||
|
// proto.TaskSection1UpgradeComponentStars,
|
|||
|
// proto.TaskSection1UpgradeCharacters,
|
|||
|
// proto.TaskSection1UpgradeCharacterStars,
|
|||
|
// proto.TaskSection1UpgradeRemains,
|
|||
|
// proto.TaskSection1ArenaChallengeTimes,
|
|||
|
// proto.TaskSection1PlanetMineTimes,
|
|||
|
// proto.TaskSection1BuildCivilizations:
|
|||
|
// if task.Process[i] >= taskTable.Section3[i] {
|
|||
|
// return false
|
|||
|
// }
|
|||
|
//
|
|||
|
// task.Process[i] += value
|
|||
|
// if task.Process[i] >= taskTable.Section3[i] {
|
|||
|
// task.Process[i] = taskTable.Section3[i]
|
|||
|
// task.Okay[i] = true
|
|||
|
// }
|
|||
|
// case proto.TaskSection1ArriveSpecificDepth,
|
|||
|
// proto.TaskSection1HeadComponentMaxLevel,
|
|||
|
// proto.TaskSection1BodyComponentMaxLevel,
|
|||
|
// proto.TaskSection1TailComponentMaxLevel,
|
|||
|
// proto.TaskSection1ComponentsAllLevels:
|
|||
|
// if task.Process[i] >= taskTable.Section3[i] {
|
|||
|
// return false
|
|||
|
// }
|
|||
|
//
|
|||
|
// task.Process[i] = value
|
|||
|
// if task.Process[i] >= taskTable.Section3[i] {
|
|||
|
// task.Process[i] = taskTable.Section3[i]
|
|||
|
// task.Okay[i] = true
|
|||
|
// }
|
|||
|
// case proto.TaskSection1ArrivedDesignatedArea:
|
|||
|
// task.Process[i] = value
|
|||
|
// if len(taskTable.Section2) == 0 {
|
|||
|
// return false
|
|||
|
// }
|
|||
|
//
|
|||
|
// switch taskTable.Section2[i] {
|
|||
|
// case 1, 2:
|
|||
|
// if task.Process[i] >= taskTable.Section3[i] {
|
|||
|
// task.Process[i] = taskTable.Section3[i]
|
|||
|
// task.Okay[i] = true
|
|||
|
// }
|
|||
|
// case 3, 4:
|
|||
|
// if task.Process[i] <= taskTable.Section3[i] {
|
|||
|
// task.Process[i] = taskTable.Section3[i]
|
|||
|
// task.Okay[i] = true
|
|||
|
// }
|
|||
|
// }
|
|||
|
// default:
|
|||
|
// return false
|
|||
|
// }
|
|||
|
// return true
|
|||
|
//}
|
|||
|
//
|
|||
|
//func (this *Player) BuildMsgTaskListAck() *proto.MsgTaskListAck {
|
|||
|
// var list []*proto.Task
|
|||
|
// for _, task := range this.Task {
|
|||
|
// list = append(list, task.BuildMsgTask())
|
|||
|
// }
|
|||
|
// return &proto.MsgTaskListAck{List: list}
|
|||
|
//}
|