/// <summary> /// Проверка на перебор времени по заданию. /// </summary> /// <param name="teamGameState"></param> /// <param name="recalcDateTime"></param> private void CheckOvertime(TeamGameState teamGameState, DateTime recalcDateTime) { if (teamGameState == null || teamGameState.ActiveTaskState == null) { return; } // время выполнения задания TimeSpan taskTime = recalcDateTime - teamGameState.ActiveTaskState.TaskStartTime; int timePerTask = teamGameState.Game.TimePerTask; // Если задание с "ускорением" и "ускорение" произошло if (teamGameState.ActiveTaskState.Task.TaskType == TaskTypes.NeedForSpeed && teamGameState.ActiveTaskState.AccelerationTaskStartTime != null) { taskTime = recalcDateTime - (DateTime)teamGameState.ActiveTaskState.AccelerationTaskStartTime; timePerTask = teamGameState.Game.TimePerTask - teamGameState.ActiveTaskState.Task.Tips.Last(tip => tip.SuspendTime > 0).SuspendTime; } if (taskTime.TotalMinutes >= timePerTask) { // Если все основные коды приняты, то задание считаем выполненым успешно TeamTaskStateFlag closeFlag = teamGameState.ActiveTaskState.AcceptedCodes.Count(x => !x.Code.IsBonus) == teamGameState.ActiveTaskState.Task.Codes.Count(x => !x.IsBonus) ? TeamTaskStateFlag.Success : TeamTaskStateFlag.Overtime; Task oldTask = teamGameState.ActiveTaskState.Task; gameService.CloseTaskForTeam(teamGameState.ActiveTaskState, closeFlag, recalcDateTime); gameService.AssignNewTask(teamGameState, oldTask, recalcDateTime); } }
public void CloseTaskForTeam(TeamTaskState teamTaskState, TeamTaskStateFlag flag, DateTime recalcTime) { teamTaskState.TaskFinishTime = recalcTime; teamTaskState.State = (int)flag; teamTaskState.TeamGameState.ActiveTaskState = null; teamTaskState.TeamGameState.AcceptedTasks.Add(teamTaskState); }
/// <summary> /// Помечает задание как успешно выполненное. /// </summary> /// <param name="teamTaskState"></param> /// <param name="flag"></param> /// <param name="recalcTime"></param> public void CloseTaskForTeam(TeamTaskState teamTaskState, TeamTaskStateFlag flag, DateTime recalcTime) { taskService.CloseTaskForTeam(teamTaskState, flag, recalcTime); }
/// <summary> /// Помечает задание как успешно выполненное. /// </summary> /// <param name="teamTaskState"></param> /// <param name="flag"></param> /// <param name="recalcTime"></param> public void CloseTaskForTeam(TeamTaskState teamTaskState, TeamTaskStateFlag flag, DateTime recalcTime) { taskService.CloseTaskForTeam(teamTaskState, flag, recalcTime); }
/// <summary> /// Помечает задание как успешно выполненное. /// </summary> /// <param name="teamTaskState"></param> public void CloseTaskForTeam(TeamTaskState teamTaskState, TeamTaskStateFlag flag) { taskService.CloseTaskForTeam(teamTaskState, flag); }
public void CloseTaskForTeam(TeamTaskState teamTaskState, TeamTaskStateFlag flag, DateTime recalcTime) { teamTaskState.TaskFinishTime = recalcTime; teamTaskState.State = (int) flag; teamTaskState.TeamGameState.ActiveTaskState = null; teamTaskState.TeamGameState.AcceptedTasks.Add(teamTaskState); }
public void CloseTaskForTeam(TeamTaskState teamTaskState, TeamTaskStateFlag flag) { teamTaskState.TaskFinishTime = DateTime.Now; teamTaskState.State = (int) flag; teamTaskStateRepository.SaveOrUpdate(teamTaskState); teamTaskState.TeamGameState.ActiveTaskState = null; teamTaskState.TeamGameState.AcceptedTasks.Add(teamTaskState); teamGameStateRepository.SaveOrUpdate(teamTaskState.TeamGameState); teamGameStateRepository.DbContext.CommitChanges(); }