private static void UpdateRanking(Group group, Func <int> nextRank, FoosMatch match)
        {
            var winner = match.Winner;
            var looser = match.Looser;

            if (!winner.Ranking.HasValue)
            {
                winner.Ranking = nextRank();
            }

            UpdateRanking(group, winner, looser);

            if (!looser.Ranking.HasValue)
            {
                looser.Ranking = nextRank();
            }
        }
Exemple #2
0
        public static bool TryParse(string message, out FoosMatch match)
        {
            match = null;
            Player player1;
            Player player2;
            int    score1;
            int    score2;

            if (!PlayerParser.TryParse(message, out player1, out player2) ||
                !ResultParser.TryParse(message, out score1, out score2))
            {
                return(false);
            }
            match = new FoosMatch(
                score1 > score2 ? player1 : player2,
                score1 > score2 ? player2 : player1,
                score1 > score2 ? score1 : score2, score1 < score2 ? score1 : score2);
            return(true);
        }
        public static IEnumerable <FoosMatch> GetMatches(IEnumerable <Message> messages)
        {
            FoosMatch match = null;

            return(messages.Where(m => MatchParser.TryParse(m.Text, out match)).Select(m => match));
        }