示例#1
0
        public static int ValidScore(Roll roll)
        {
            if (roll.Count == 6 && roll.Distinct <int>().Count() == 6)
            {
                return(1500);
            }

            var score = 0;

            if (roll.GroupBy(x => x).Where(x => x.Count() == 6).Any())
            {
                return(roll[0] * (roll[0] == 1 ? 2000 : 200));
            }

            foreach (var triple in roll.GroupBy(x => x).Where(x => x.Count() >= 3))
            {
                triple.Take(3).ToList().ForEach(x => roll.Remove(x));
                score += triple.Key * (triple.Key == 1 ? 1000 : 100);
            }

            roll.Where(x => x == 1).ToList().ForEach(x => { roll.Remove(x); score += 100; });
            roll.Where(x => x == 5).ToList().ForEach(x => { roll.Remove(x); score += 50; });

            return(roll.Any() ? 0 : score);
        }
示例#2
0
        public Roll Narrow(List <int> remove)
        {
            Roll newRoll = new Roll(this);

            remove.ForEach(x => newRoll.Remove(x));
            return(newRoll);
        }
示例#3
0
        public Roll Narrow(int remove)
        {
            Roll newRoll = new Roll(this);

            newRoll.Remove(remove);
            return(newRoll);
        }