Beispiel #1
0
        private void addRoundScore()
        {
            RoundScore rs = new RoundScore()
            {
                GameID = _gameID,
                TeamID = _selectedTeam.TeamID,
                Points = 0,
                Round  = 1
            };

            _allRoundScores.Add(rs);
            _roundScores.Add(rs);
            _dataManager.Entry(rs).State = EntityState.Added;

            SelectedRoundScore = rs;
        }
        private void turnCompleted()
        {
            if (_counter % _teams.Count == 0)
            {
                _roundNumber++;
            }

            if (_pointValuesForCurrentTurn.All(e => e == false))
            {
                RoundScore rs = new RoundScore()
                {
                    GameID = _game.GameID, TeamID = _currentTeamScore.TeamID, Round = _roundNumber, Points = 0
                };
                _dataManager.RoundScores.Add(rs);
                _dataManager.SaveChanges();
            }
            else
            {
                for (int i = 0; i < _pointValuesForCurrentTurn.Count; i++)
                {
                    if (_pointValuesForCurrentTurn[i])
                    {
                        RoundScore rs = new RoundScore()
                        {
                            GameID = _game.GameID, TeamID = _currentTeamScore.TeamID, Round = _roundNumber
                        };
                        rs.Points = _pointValues[i].Points;

                        _dataManager.RoundScores.Add(rs);
                        _dataManager.SaveChanges();
                    }
                }
            }

            _counter++;

            UpdateTeamScore(_currentTeamScore.TeamID, _roundNumber);

            int index = _teamScores.IndexOf(_currentTeamScore);

            index = (index == (_teamScores.Count - 1)) ? 0 : index + 1;

            CurrentTeamScore  = _teamScores.ElementAt(index);
            SelectedTeamScore = _teamScores.ElementAt(index);

            ResetPointValuesForCurrentTurn();
        }
 private void OnZombieScore(RoundScore zombieScore)
 {
     if (cur != zombieScore._cur)
     {
         cur           = zombieScore._cur;
         curFont.Scale = 2f;
     }
     if (total != zombieScore._total)
     {
         total           = zombieScore._total;
         totalFont.Scale = 2f;
     }
     if (cur > total)
     {
         cur = total;
     }
 }
        private void UpdateTeamScore(int teamID, int round)
        {
            TeamScore         teamScore   = _teamScores.SingleOrDefault(e => e.TeamID == teamID);
            List <RoundScore> roundScores = _game.RoundScores.Where(e => e.TeamID == teamID).ToList();

            foreach (PointValueHit pv in teamScore.PointValuesHit)
            {
                pv.HitLastRound = false;
            }

            teamScore.CurrentScore = roundScores.Sum(e => e.Points);

            foreach (RoundScore rs in roundScores.Where(e => e.Round == round))
            {
                PointValueHit pvh = teamScore.PointValuesHit.SingleOrDefault(e => e.Points == rs.Points);
                if (pvh != null)
                {
                    pvh.Completed    = true;
                    pvh.HitLastRound = true;
                }
            }

            if (teamScore.CurrentScore == _scoreToWin)
            {
                System.Windows.Forms.MessageBox.Show(string.Format("{0} Win!", teamScore.TeamName));
            }
            else if (teamScore.CurrentScore > _scoreToWin)
            {
                RoundScore negRoundScore = new RoundScore()
                {
                    GameID = _game.GameID, TeamID = teamID, Round = round
                };
                negRoundScore.Points = _fallbackScoreOnBust - teamScore.CurrentScore;

                _game.RoundScores.Add(negRoundScore);
                _dataManager.SaveChanges();

                teamScore.CurrentScore = roundScores.Sum(e => e.Points) + negRoundScore.Points;
            }
        }
Beispiel #5
0
        public static IList <RoundScore> StatisticalScore(IList <RoundScorePostViewModel> scores)
        {
            var scoresOrder = scores.OrderBy(s => s.GroupNum).ThenByDescending(s => s.Result);
            var i           = 0;
            var beforeScore = scoresOrder.First();
            var result      = new List <RoundScore>();
            var maxScore    = GetMaxScore(scores) + 1;

            foreach (var score in scoresOrder)
            {
                var s = new RoundScore
                {
                    Id         = score.Id,
                    Result     = score.Result,
                    Score      = score.Result == 0f ? maxScore : score.GroupNum != beforeScore.GroupNum ? (i = 1) : ++i,
                    Contestant = new Contestant {
                        GroupNum = score.GroupNum
                    }
                };
                result.Add(s);
                beforeScore = score;
            }
            return(result);
        }
        public ActionResult ScorecardDetail(FormCollection collection, ScorecardModel model)
        {
            ScorecardModel m = new ScorecardModel();
            ScorekeeperDBEntities s = new ScorekeeperDBEntities();
            m.SelectedCourseValue = model.SelectedCourseValue;
            m.SelectedCourse = s.Courses.Where(x => x.CourseId == model.SelectedCourseValue).FirstOrDefault();
            int? highestRoundNum = 0;
            if (s.Rounds.Where(x => x.UserId == m.User.UserId).Count() > 0)
                highestRoundNum = s.Rounds.Where(x => x.UserId == m.User.UserId).OrderByDescending(x => x.RoundNumber).FirstOrDefault().RoundNumber;

            Round round = new Round();
            round.RoundId = Guid.NewGuid();
            round.CourseId = m.SelectedCourse.CourseId;
            round.UserId = m.User.UserId;
            round.RoundNumber = highestRoundNum + 1;
            round.PlayedDate = DateTime.Now;
            s.AddToRounds(round);

            for (int i = 0; i < m.SelectedCourse.Hole.Count(); i++)
            {
                RoundScore rs = new RoundScore();
                rs.RoundScoreId = Guid.NewGuid();
                rs.RoundId = round.RoundId;
                var g = (from h in s.Hole
                            where h.HoleNumber == i+1 && h.CourseId == m.SelectedCourse.CourseId
                            select h.HoleId);
                rs.HoleId = g.FirstOrDefault();
                string holeNum = "Hole" + (i+1).ToString();
                rs.Strokes = Int32.Parse(collection[holeNum]);
                s.AddToRoundScore(rs);
            }
            s.SaveChanges();
            m.message = "Round Saved Successfully";
            m.SelectedCourse = null;
            return View("Scorecard", m);
        }
Beispiel #7
0
 internal void SetRoundScore()
 {
     Out.Invoke($"Выиграно очков в раунде: {CurrentRound.Score}.");
     RoundScore?.Invoke();
 }
Beispiel #8
0
 public Round(int firstRoll, int secondRoll, RoundScore score)
 {
     FirstRoll  = firstRoll;
     SecondRoll = secondRoll;
     Score      = score;
 }