Exemple #1
0
        public AjaxStoreResult GetTeamsState(int id)
        {
            var list = new List <TeamsState>();

            var game = gameRepository.Get(id);

            foreach (Team team in game.Teams)
            {
                if (team.TeamGameState == null)
                {
                    continue;
                }

                var teamState = new TeamsState();
                teamState.Id   = team.Id;
                teamState.Name = team.Name;
                if (team.TeamGameState.ActiveTaskState != null)
                {
                    teamState.Task = team.TeamGameState.ActiveTaskState.Task.Name;
                    teamState.Time = DateTime.Now - team.TeamGameState.ActiveTaskState.TaskStartTime;

                    var acceptedTasks = team.TeamGameState.AcceptedTasks;
                    teamState.Accpt    = acceptedTasks.Count;
                    teamState.Success  = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Success);
                    teamState.Overtime = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Overtime);
                    teamState.Canceled = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Canceled);
                    teamState.Cheat    = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Cheat);

                    teamState.Tips            = team.TeamGameState.ActiveTaskState.AcceptedTips.Count - 1;
                    teamState.CodesMainCount  = team.TeamGameState.ActiveTaskState.Task.Codes.Count(c => c.IsBonus == false);
                    teamState.CodesBonusCount = team.TeamGameState.ActiveTaskState.Task.Codes.Count(c => c.IsBonus == true);
                    teamState.CodesAccpt      = team.TeamGameState.ActiveTaskState.AcceptedCodes.Count(c => c.Code.IsBonus == false);
                    teamState.CodesBonusAccpt = team.TeamGameState.ActiveTaskState.AcceptedCodes.Count(c => c.Code.IsBonus == true);
                }
                list.Add(teamState);
            }

            return(new AjaxStoreResult(list, list.Count));
        }
        public AjaxStoreResult GetTeamsState(int id)
        {
            var list = new List<TeamsState>();

            var game = gameRepository.Get(id);
            foreach (Team team in game.Teams)
            {
                if (team.TeamGameState == null)
                    continue;

                var teamState = new TeamsState();
                teamState.Id = team.Id;
                teamState.Name = team.Name;
                if (team.TeamGameState.ActiveTaskState != null)
                {
                    teamState.Task = team.TeamGameState.ActiveTaskState.Task.Name;
                    teamState.Time = DateTime.Now - team.TeamGameState.ActiveTaskState.TaskStartTime;

                    var acceptedTasks = team.TeamGameState.AcceptedTasks;
                    teamState.Accpt = acceptedTasks.Count;
                    teamState.Success = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Success);
                    teamState.Overtime = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Overtime);
                    teamState.Canceled = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Canceled);
                    teamState.Cheat = acceptedTasks.Count(x => x.State == (int)TeamTaskStateFlag.Cheat);

                    teamState.Tips = team.TeamGameState.ActiveTaskState.AcceptedTips.Count - 1;
                    teamState.CodesMainCount = team.TeamGameState.ActiveTaskState.Task.Codes.Count(c => c.IsBonus == false);
                    teamState.CodesBonusCount = team.TeamGameState.ActiveTaskState.Task.Codes.Count(c => c.IsBonus == true);
                    teamState.CodesAccpt = team.TeamGameState.ActiveTaskState.AcceptedCodes.Count(c => c.Code.IsBonus == false);
                    teamState.CodesBonusAccpt = team.TeamGameState.ActiveTaskState.AcceptedCodes.Count(c => c.Code.IsBonus == true);
                }
                list.Add(teamState);
            }

            return new AjaxStoreResult(list, list.Count);
        }