public void CannotLockInScoreThatIsNotPartOfTheUpperSection() { var section = new UpperSection(x => 1, x => 2, x => 3, x => 4, x => 5, x => 6); section.Preview(new List <int>()); Assert.Throws <Exception>(() => section.Lock(ScoreCard.Items.ThreeOfAKind)); }
public void ReturnsBonusWhenUpperSectionSumIsEqualToSixtyThree() { var section = new UpperSection(x => 63, x => 2, x => 3, x => 4, x => 5, x => 6); section.Preview(new List <int>()); section.Lock(ScoreCard.Items.Ones); Assert.Equal(35, section.Bonus); }
public void ReturnsScoreIncludingBonus() { var section = new UpperSection(x => 1, x => 2, x => 3, x => 4, x => 5, x => 63); section.Preview(new List <int>()); section.Lock(ScoreCard.Items.Sixes); section.Preview(new List <int>()); Assert.Equal(63 + 35, section.Score); }
public void ReturnsScore() { var section = new UpperSection(x => 1, x => 2, x => 3, x => 4, x => 5, x => 6); section.Preview(new List <int>()); section.Lock(ScoreCard.Items.Sixes); section.Preview(new List <int>()); section.Lock(ScoreCard.Items.Fours); section.Preview(new List <int>()); Assert.Equal(10, section.Score); }
public void PreviewsTheScoreForSetOfDice() { var section = new UpperSection(x => 1, x => 2, x => 3, x => 4, x => 5, x => 6); section.Preview(new List <int>()); Assert.Equal(1, section.Ones); Assert.Equal(2, section.Twos); Assert.Equal(3, section.Threes); Assert.Equal(4, section.Fours); Assert.Equal(5, section.Fives); Assert.Equal(6, section.Sixes); }
public void LockInFivesScore() { var section = new UpperSection(x => 1, x => 2, x => 3, x => 4, x => 5, x => 6); section.Preview(new List <int>()); section.Lock(ScoreCard.Items.Fives); Assert.Equal(0, section.Ones); Assert.Equal(0, section.Twos); Assert.Equal(0, section.Threes); Assert.Equal(0, section.Fours); Assert.Equal(5, section.Fives); Assert.Equal(0, section.Sixes); }
public static int ScoreUpper(UpperSection section, Hand hand) { int score = 0; List <int> playerHand = hand.GetDiceList(); switch (section) { case UpperSection.threeofakind: score = ScoreThreeOfAKind(playerHand); break; case UpperSection.fourofakind: score = ScoreFourOfAKind(playerHand); break; case UpperSection.fullhouse: score = ScoreFullHouse(playerHand); break; case UpperSection.smallstraight: score = ScoreSmallStraight(playerHand); break; case UpperSection.largestraight: score = ScoreLargeStraight(playerHand); break; case UpperSection.yahtzee: score = ScoreYahtzee(playerHand); break; case UpperSection.chance: score = ScoreChance(playerHand); break; default: Console.WriteLine("Invalid scoring option"); break; } return(score); }
public static int ScoreHand(string section, Hand hand) { section = section.ToLower(); if (Enum.IsDefined(typeof(LowerSection), section)) { int diceValue = (int)Enum.Parse(typeof(LowerSection), section); return(ScoreLower(diceValue, hand)); } else if (Enum.IsDefined(typeof(UpperSection), section)) { UpperSection scoringSection = (UpperSection)Enum.Parse(typeof(UpperSection), section); return(ScoreUpper(scoringSection, hand)); } else { Console.WriteLine("INVALID SCORE CATEGORY"); return(0); } }
public static IDictionary <string, int> ScoreFullCard(Hand hand) { IDictionary <string, int> ScoreCard = new Dictionary <string, int>() { }; foreach (var val in LowerSection.GetValues(typeof(LowerSection))) { string section = val.ToString(); ScoreCard[section] = Score.ScoreHand(section, hand); } foreach (var val in UpperSection.GetValues(typeof(UpperSection))) { string section = val.ToString(); ScoreCard[section] = Score.ScoreHand(section, hand); } return(ScoreCard); }
public void ReturnsBonusOfZeroWhenUpperSectionSumIsUnderSixtyThree() { var section = new UpperSection(x => 1, x => 2, x => 3, x => 4, x => 5, x => 6); Assert.Equal(0, section.Bonus); }