package handler //func (this *PlayerHandler) TaskCommit(player *logic.Player, msg *net.Message) { // var req = new(proto.MsgTaskCommitReq) // var err = msg.Read(req) // if err != nil { // this.logger.Error("Read message failed, ", err) // _ = player.TipNotice(proto.ErrMessageError) // return // } // // if req.Id == 0 { // this.logger.Error("Parameter error, req.Id == 0") // _ = player.TipNotice(proto.ErrParameterError) // return // } // // var task = player.Task[req.Id] // if task == nil { // this.logger.Error("Parameter error, Player 'Task' not found, id: ", req.Id) // _ = player.TipNotice(proto.ErrTaskNotFound) // return // } // // var taskTable = this.tables.Task.Get(int(req.Id)) // if taskTable == nil { // this.logger.Error("Parameter or data error, Table 'Task' not found, id: ", req.Id) // _ = player.TipNotice(proto.ErrDataTablesError) // return // } // // if proto.TaskStatus(task.Status) < proto.TaskStatusCompleted { // this.logger.Errorf("Task not completed, id: %d, status: %d", task.Id, task.Status) // _ = player.TipNotice(proto.ErrTaskNotCompleted) // return // } // // if proto.TaskStatus(task.Status) > proto.TaskStatusCompleted { // this.logger.Errorf("Task has completed, id: %d, status: %d", task.Id, task.Status) // _ = player.TipNotice(proto.ErrTaskHasCommitted) // return // } // // var rewardList []*proto.ItemPair // for i := range taskTable.ItemIdList { // _ = player.AddItem(uint32(taskTable.ItemIdList[i]), uint32(taskTable.ItemNumList[i]), logic.LogTypeItemObtainByTask) // rewardList = append(rewardList, &proto.ItemPair{ItemId: uint32(taskTable.ItemIdList[i]), ItemNum: uint32(taskTable.ItemNumList[i])}) // } // // if proto.TaskType(taskTable.TaskType) == proto.TaskTypeUnlock { // player.TaskComponentUnlock(task.Id) // player.TaskCharacterUnlock(task.Id) // } // // task.Status = uint32(proto.TaskStatusCommitted) // // player.AddCounter(proto.CounterTypeTaskCompleted, task.Id, 1) // // delete(player.Task, task.Id) // player.WipeModel(task) // // _ = player.Send(proto.ModIdTask, proto.MsgIdTaskCommit, &proto.MsgTaskCommitAck{MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList}, Id: req.Id}) // _ = player.Send(proto.ModIdTask, proto.MsgIdTaskChange, &proto.MsgTaskChangeListAck{List: []*proto.TaskChange{{Task: task.BuildMsgTask(), ChangeType: uint32(proto.ChangeTypeDelete)}}}) // // player.AddTask(taskTable.RearTaskId...) // // this.eventManager.PlayerTaskLog(player, logic.LogTypeTaskRemove, uint32(taskTable.Id), taskTable.Section1, taskTable.Section2, task.Process) //} // //func (this *PlayerHandler) ActiveGetReward(player *logic.Player, msg *net.Message) { // var req = new(proto.MsgActiveGetRewardReq) // var err = msg.Read(req) // if err != nil { // this.logger.Error("Read message failed, ", err) // _ = player.TipNotice(proto.ErrMessageError) // return // } // // if req.Id == 0 { // this.logger.Error("Parameter error, req.Id == 0") // _ = player.TipNotice(proto.ErrParameterError) // return // } // // var activeTable = this.tables.Active.Get(int(req.Id)) // if activeTable == nil { // this.logger.Error("Parameter or data error, Active not found, id: ", req.Id) // _ = player.TipNotice(proto.ErrDataTablesError) // return // } // // err = player.CheckMoney(proto.MoneyTypeActivation, uint32(activeTable.ActiveValue)) // if err != nil { // this.logger.Errorf("%s, moneyType: %d, moneyNum: %d", err.Error(), proto.MoneyTypeActivation, activeTable.ActiveValue) // _ = player.TipNotice(err) // return // } // // var active = player.TaskActive[req.Id] // if active == nil { // active = &logic.PlayerTaskActive{Id: uint32(activeTable.Id), Status: uint32(proto.RewardStatusUnable)} // player.TaskActive[active.Id] = active // } else { // if proto.RewardStatus(active.Status) == proto.RewardStatusHasGot { // this.logger.Errorf("Active reward has got, id: %d, status: %d", active.Id, active.Status) // _ = player.TipNotice(proto.ErrRewardHasGot) // return // } // } // // var rewardList []*proto.ItemPair // for i := range activeTable.ItemList { // rewardList = append(rewardList, &proto.ItemPair{ItemId: uint32(activeTable.ItemList[i]), ItemNum: uint32(activeTable.NumList[i])}) // } // // _ = player.Send(proto.ModIdTask, proto.MsgIdActiveGetReward, &proto.MsgActiveGetRewardAck{ // ActiveReward: active.BuildActiveReward(), // MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList}, // }) // // active.Status = uint32(proto.RewardStatusHasGot) // player.SaveModel(active) // // if activeTable.AddExp > 0 { // player.AddMoney(proto.MoneyTypeExp, uint32(activeTable.AddExp), logic.LogTypeItemObtainByTaskActive) // } //}