Example #1
0
        public int?RecordYahtzee(IDiceCup diceCup)
        {
            bool isValidYahtzeeCombination = _diceOfAKindValidator.IsValid(5, diceCup.Dice);

            if (Yahtzee != null && Yahtzee > 0 && isValidYahtzeeCombination)
            {
                if (YahtzeeBonus.Count() == 3)
                {
                    return(null);
                }
                RecordYahtzeeBonus();
                return(100);
            }
            else if (Yahtzee != null)
            {
                return(null);
            }

            if (isValidYahtzeeCombination)
            {
                Yahtzee = 50;
            }
            else
            {
                Yahtzee = 0;
            }

            return(Yahtzee);
        }
Example #2
0
 private void RecordAllUpperSection(IDiceCup diceCup)
 {
     _scoreSheet.RecordUpperSection(UpperSectionItem.Ones, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Twos, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Threes, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Fours, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Fives, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Sixes, diceCup);
 }
Example #3
0
        public int?RecordChance(IDiceCup diceCup)
        {
            if (Chance != null)
            {
                return(null);
            }

            Chance = diceCup.Dice.Select(x => x.Value).Sum();
            return(Chance);
        }
Example #4
0
 private void RecordAllLowerSection(IDiceCup diceCup)
 {
     _scoreSheet.RecordThreeOfAKind(diceCup);
     _scoreSheet.RecordFourOfAKind(diceCup);
     _scoreSheet.RecordFullHouse(diceCup);
     _scoreSheet.RecordSmallStraight(diceCup);
     _scoreSheet.RecordLargeStraight(diceCup);
     _scoreSheet.RecordYahtzee(diceCup);
     _scoreSheet.RecordYahtzee(diceCup);
     _scoreSheet.RecordChance(diceCup);
 }
 public void Show(IDiceCup diceCup)
 {
     StringBuilder sb = new StringBuilder(_prompt);
     foreach (var die in diceCup.Dice)
     {
         sb.Append("| ");
         sb.Append(die.Value);
         sb.Append(" | ");
     }
     Console.Write(sb.ToString().Trim());
 }
Example #6
0
        public void Show(IDiceCup diceCup)
        {
            StringBuilder sb = new StringBuilder(_prompt);

            foreach (var die in diceCup.Dice)
            {
                sb.Append("| ");
                sb.Append(die.Value);
                sb.Append(" | ");
            }
            Console.Write(sb.ToString().Trim());
        }
Example #7
0
        public int?RecordSmallStraight(IDiceCup diceCup)
        {
            if (SmallStraight != null)
            {
                return(null);
            }

            if (_straightValidator.IsValid(4, diceCup.Dice))
            {
                SmallStraight = 30;
            }
            else
            {
                SmallStraight = 0;
            }

            return(SmallStraight);
        }
Example #8
0
        public int?RecordFourOfAKind(IDiceCup diceCup)
        {
            if (FourOfAKind != null)
            {
                return(null);
            }

            if (_diceOfAKindValidator.IsValid(4, diceCup.Dice))
            {
                FourOfAKind = diceCup.Dice.Select(x => x.Value).Sum();
            }
            else
            {
                FourOfAKind = 0;
            }

            return(FourOfAKind);
        }
Example #9
0
        public int?RecordLargeStraight(IDiceCup diceCup)
        {
            if (LargeStraight != null)
            {
                return(null);
            }

            if (_straightValidator.IsValid(5, diceCup.Dice))
            {
                LargeStraight = 40;
            }
            else
            {
                LargeStraight = 0;
            }

            return(LargeStraight);
        }
Example #10
0
        public int?RecordFullHouse(IDiceCup diceCup)
        {
            if (FullHouse != null)
            {
                return(null);
            }

            if (_fullHouseValidator.IsValid(diceCup.Dice))
            {
                FullHouse = 25;
            }
            else
            {
                FullHouse = 0;
            }

            return(FullHouse);
        }
Example #11
0
 private int SumDiceOfValue(IDiceCup diceCup, int value)
 {
     return diceCup.Dice.Where(x => x.Value == value).Sum(x => x.Value);
 }
Example #12
0
        public int? RecordYahtzee(IDiceCup diceCup)
        {
            bool isValidYahtzeeCombination = _diceOfAKindValidator.IsValid(5, diceCup.Dice);

            if (Yahtzee != null && Yahtzee > 0 && isValidYahtzeeCombination)
            {
                if (YahtzeeBonus.Count() == 3) return null;
                RecordYahtzeeBonus();
                return 100;
            }
            else if (Yahtzee != null)
            {
                return null;
            }

            if (isValidYahtzeeCombination)
            {
                Yahtzee = 50;
            }
            else
            {
                Yahtzee = 0;
            }

            return Yahtzee;
        }
Example #13
0
        public int? RecordUpperSection(UpperSectionItem upperSection, IDiceCup diceCup)
        {
            int? sum = null;

            switch (upperSection)
            {
                case UpperSectionItem.Ones:
                    if (Ones != null) return null;
                    sum = SumDiceOfValue(diceCup, 1);
                    Ones = sum;
                    break;
                case UpperSectionItem.Twos:
                    if (Twos != null) return null;
                    sum = SumDiceOfValue(diceCup, 2);
                    Twos = sum;
                    break;
                case UpperSectionItem.Threes:
                    if (Threes != null) return null;
                    sum = SumDiceOfValue(diceCup, 3);
                    Threes = sum;
                    break;
                case UpperSectionItem.Fours:
                    if (Fours != null) return null;
                    sum = SumDiceOfValue(diceCup, 4);
                    Fours = sum;
                    break;
                case UpperSectionItem.Fives:
                    if (Fives != null) return null;
                    sum = SumDiceOfValue(diceCup, 5);
                    Fives = sum;
                    break;
                case UpperSectionItem.Sixes:
                    if (Sixes != null) return null;
                    sum = SumDiceOfValue(diceCup, 6);
                    Sixes = sum;
                    break;
            }

            return sum;
        }
Example #14
0
        public int? RecordThreeOfAKind(IDiceCup diceCup)
        {
            if (ThreeOfAKind != null) return null;

            if (_diceOfAKindValidator.IsValid(3, diceCup.Dice))
            {
                ThreeOfAKind = diceCup.Dice.Select(x => x.Value).Sum();
            }
            else
            {
                ThreeOfAKind = 0;
            }

            return ThreeOfAKind;
        }
Example #15
0
        public int? RecordSmallStraight(IDiceCup diceCup)
        {
            if (SmallStraight != null) return null;

            if (_straightValidator.IsValid(4, diceCup.Dice))
            {
                SmallStraight = 30;
            }
            else
            {
                SmallStraight = 0;
            }

            return SmallStraight;
        }
Example #16
0
        public int? RecordLargeStraight(IDiceCup diceCup)
        {
            if (LargeStraight != null) return null;

            if (_straightValidator.IsValid(5, diceCup.Dice))
            {
                LargeStraight = 40;
            }
            else
            {
                LargeStraight = 0;
            }

            return LargeStraight;
        }
Example #17
0
        public int? RecordFourOfAKind(IDiceCup diceCup)
        {
            if (FourOfAKind != null) return null;

            if (_diceOfAKindValidator.IsValid(4, diceCup.Dice))
            {
                FourOfAKind = diceCup.Dice.Select(x => x.Value).Sum();
            }
            else
            {
                FourOfAKind = 0;
            }

            return FourOfAKind;
        }
 public DiceSetSaverConsoleDisplay(IDiceCup diceCup)
 {
     _diceCup = diceCup;
 }
Example #19
0
 private void RecordAllLowerSection(IDiceCup diceCup)
 {
     _scoreSheet.RecordThreeOfAKind(diceCup);
     _scoreSheet.RecordFourOfAKind(diceCup);
     _scoreSheet.RecordFullHouse(diceCup);
     _scoreSheet.RecordSmallStraight(diceCup);
     _scoreSheet.RecordLargeStraight(diceCup);
     _scoreSheet.RecordYahtzee(diceCup);
     _scoreSheet.RecordYahtzee(diceCup);
     _scoreSheet.RecordChance(diceCup);
 }
Example #20
0
 private int SumDiceOfValue(IDiceCup diceCup, int value)
 {
     return(diceCup.Dice.Where(x => x.Value == value).Sum(x => x.Value));
 }
Example #21
0
        public int?RecordUpperSection(UpperSectionItem upperSection, IDiceCup diceCup)
        {
            int?sum = null;

            switch (upperSection)
            {
            case UpperSectionItem.Ones:
                if (Ones != null)
                {
                    return(null);
                }
                sum  = SumDiceOfValue(diceCup, 1);
                Ones = sum;
                break;

            case UpperSectionItem.Twos:
                if (Twos != null)
                {
                    return(null);
                }
                sum  = SumDiceOfValue(diceCup, 2);
                Twos = sum;
                break;

            case UpperSectionItem.Threes:
                if (Threes != null)
                {
                    return(null);
                }
                sum    = SumDiceOfValue(diceCup, 3);
                Threes = sum;
                break;

            case UpperSectionItem.Fours:
                if (Fours != null)
                {
                    return(null);
                }
                sum   = SumDiceOfValue(diceCup, 4);
                Fours = sum;
                break;

            case UpperSectionItem.Fives:
                if (Fives != null)
                {
                    return(null);
                }
                sum   = SumDiceOfValue(diceCup, 5);
                Fives = sum;
                break;

            case UpperSectionItem.Sixes:
                if (Sixes != null)
                {
                    return(null);
                }
                sum   = SumDiceOfValue(diceCup, 6);
                Sixes = sum;
                break;
            }

            return(sum);
        }
 public DiceSetSaverConsoleDisplay(IDiceCup diceCup)
 {
     _diceCup = diceCup;
 }
Example #23
0
        public int? RecordFullHouse(IDiceCup diceCup)
        {
            if (FullHouse != null) return null;

            if (_fullHouseValidator.IsValid(diceCup.Dice))
            {
                FullHouse = 25;
            }
            else
            {
                FullHouse = 0;
            }

            return FullHouse;
        }
Example #24
0
 private void RecordAllUpperSection(IDiceCup diceCup)
 {
     _scoreSheet.RecordUpperSection(UpperSectionItem.Ones, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Twos, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Threes, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Fours, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Fives, diceCup);
     _scoreSheet.RecordUpperSection(UpperSectionItem.Sixes, diceCup);
 }
Example #25
0
        public int? RecordChance(IDiceCup diceCup)
        {
            if (Chance != null) return null;

            Chance = diceCup.Dice.Select(x => x.Value).Sum();
            return Chance;
        }