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); }
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); }
public int?RecordChance(IDiceCup diceCup) { if (Chance != null) { return(null); } Chance = diceCup.Dice.Select(x => x.Value).Sum(); return(Chance); }
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()); }
public int?RecordSmallStraight(IDiceCup diceCup) { if (SmallStraight != null) { return(null); } if (_straightValidator.IsValid(4, diceCup.Dice)) { SmallStraight = 30; } else { SmallStraight = 0; } return(SmallStraight); }
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 int?RecordLargeStraight(IDiceCup diceCup) { if (LargeStraight != null) { return(null); } if (_straightValidator.IsValid(5, diceCup.Dice)) { LargeStraight = 40; } else { LargeStraight = 0; } return(LargeStraight); }
public int?RecordFullHouse(IDiceCup diceCup) { if (FullHouse != null) { return(null); } if (_fullHouseValidator.IsValid(diceCup.Dice)) { FullHouse = 25; } else { FullHouse = 0; } return(FullHouse); }
private int SumDiceOfValue(IDiceCup diceCup, int value) { return diceCup.Dice.Where(x => x.Value == value).Sum(x => x.Value); }
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; }
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 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; }
public int? RecordSmallStraight(IDiceCup diceCup) { if (SmallStraight != null) return null; if (_straightValidator.IsValid(4, diceCup.Dice)) { SmallStraight = 30; } else { SmallStraight = 0; } return SmallStraight; }
public int? RecordLargeStraight(IDiceCup diceCup) { if (LargeStraight != null) return null; if (_straightValidator.IsValid(5, diceCup.Dice)) { LargeStraight = 40; } else { LargeStraight = 0; } return LargeStraight; }
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; }
private int SumDiceOfValue(IDiceCup diceCup, int value) { return(diceCup.Dice.Where(x => x.Value == value).Sum(x => x.Value)); }
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 int? RecordFullHouse(IDiceCup diceCup) { if (FullHouse != null) return null; if (_fullHouseValidator.IsValid(diceCup.Dice)) { FullHouse = 25; } else { FullHouse = 0; } return FullHouse; }
public int? RecordChance(IDiceCup diceCup) { if (Chance != null) return null; Chance = diceCup.Dice.Select(x => x.Value).Sum(); return Chance; }