Exemple #1
0
        public bool ParseInputReroll(string line)
        {
            if (line == null)
            {
                throw new NullReferenceException();
            }
            if (line.Trim().Equals("0"))
            {
                DiceToReroll.Clear();
                EndOfThrowing = true;
                return(true);
            }

            List <int> InputNumbers;

            try
            {
                InputNumbers = line.Split().Select(int.Parse).ToList();
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input: Could not recognise numbers. Try again.");
                return(false);
            }

            if ((InputNumbers.Count() > NUM_OF_DICE || InputNumbers.Count() < 1) || InputNumbers.Any(x => x > NUM_OF_DICE || x < 1))
            {
                Console.WriteLine("Invalid input: Too many entered numbers or they are out of range. Try again.");
                return(false);
            }

            DiceToReroll = PlayerDice.Where(x => InputNumbers.Contains(x.IndexOfDice)).ToList();
            return(true);
        }
Exemple #2
0
 public void Reroll()
 {
     DiceToReroll.ForEach(x => x.Roll());
 }