public void SetScoreSheet(IScoreSheet scoresheet) { _scoresheet = scoresheet; var index = 0; if (!_scoreIsSet) { foreach (var pair in Table.PlayerGraphicsDict) { var player = pair.Key; _leaderboardpanel[index].PlayerName = player.Name; var score = _table.ScrSheet.Total()[player]; _leaderboardpanel[index++].Score = "Final Score: " + score.ToString(); if (score > maxScore) { _finalScoreBanner.PlayerName = "Winner is " + player.Name; _finalScoreBanner.Score = "Score: " + score.ToString(); maxScore = score; } else if (score == maxScore) { _finalScoreBanner.PlayerName += ", " + player.Name; } } _scoreIsSet = true; } }
public void Display(IScoreSheet scoreSheet) { Dictionary <string, string> templateParameters = BuildTemplateParametersDictionary(scoreSheet); string output = Regex.Replace(_template, @"\{(.+?)\}", m => templateParameters[m.Groups[1].Value]); Console.WriteLine(output); }
private bool IsLowerSectionComplete(IScoreSheet scoreSheet) { if (scoreSheet.ThreeOfAKind == null || scoreSheet.FourOfAKind == null || scoreSheet.FullHouse == null || scoreSheet.SmallStraight == null || scoreSheet.LargeStraight == null || scoreSheet.Chance == null || scoreSheet.Yahtzee == null) { return(false); } return(true); }
private bool IsUpperSectionComplete(IScoreSheet scoreSheet) { if (scoreSheet.Ones == null || scoreSheet.Twos == null || scoreSheet.Threes == null || scoreSheet.Fours == null || scoreSheet.Fives == null || scoreSheet.Sixes == null) { return(false); } return(true); }
private bool IsLowerSectionComplete(IScoreSheet scoreSheet) { if (scoreSheet.ThreeOfAKind == null || scoreSheet.FourOfAKind == null || scoreSheet.FullHouse == null || scoreSheet.SmallStraight == null || scoreSheet.LargeStraight == null || scoreSheet.Chance == null || scoreSheet.Yahtzee == null) { return false; } return true; }
public Table(IPlayer host, Prompt prompt) { Players = new List <IPlayer> { host }; Dealer = host; Games = new List <IGame>(); ScrSheet = new Score(Players); this.prompt = prompt; GameIndex = 0; }
public void SetScoreSheet(IScoreSheet scoresheet) { _scoresheet = scoresheet; var index = 0; foreach (var pair in Table.PlayerGraphicsDict) { var player = pair.Key; _leaderboardpanel[index].PlayerName = player.Name; var score = scoresheet.Scores[player][_table.Games.Count - 1]; _leaderboardpanel[index++].Score = "Current Score: " + score.ToString(); } }
private Dictionary <string, string> BuildTemplateParametersDictionary(IScoreSheet scoreSheet) { var templateParameters = new Dictionary <string, string>(); templateParameters["ones"] = scoreSheet.Ones.ToString(); templateParameters["twos"] = scoreSheet.Twos.ToString(); templateParameters["threes"] = scoreSheet.Threes.ToString(); templateParameters["fours"] = scoreSheet.Fours.ToString(); templateParameters["fives"] = scoreSheet.Fives.ToString(); templateParameters["sixes"] = scoreSheet.Sixes.ToString(); templateParameters["upperSectionTotal"] = IsUpperSectionComplete(scoreSheet) ? scoreSheet.UpperSectionTotal.ToString() : string.Empty; templateParameters["bonus"] = IsUpperSectionComplete(scoreSheet) ? scoreSheet.UpperSectionBonus.ToString() : string.Empty; templateParameters["upperSectionTotalWithBonus"] = IsUpperSectionComplete(scoreSheet) ? scoreSheet.UpperSectionTotalWithBonus.ToString() : string.Empty; templateParameters["threeOfAKind"] = scoreSheet.ThreeOfAKind.ToString(); templateParameters["fourOfAKind"] = scoreSheet.FourOfAKind.ToString(); templateParameters["fullHouse"] = scoreSheet.FullHouse.ToString(); templateParameters["smallStraight"] = scoreSheet.SmallStraight.ToString(); templateParameters["largeStraight"] = scoreSheet.LargeStraight.ToString(); templateParameters["chance"] = scoreSheet.Chance.ToString(); templateParameters["yahtzee"] = scoreSheet.Yahtzee.ToString(); var yahtzeeBonus = new int[3]; yahtzeeBonus[0] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(0); yahtzeeBonus[1] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(1); yahtzeeBonus[2] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(2); templateParameters["yahtzeeBonus1"] = yahtzeeBonus[0] == 0 ? " " : "X"; templateParameters["yahtzeeBonus2"] = yahtzeeBonus[1] == 0 ? " " : "X"; templateParameters["yahtzeeBonus3"] = yahtzeeBonus[2] == 0 ? " " : "X"; templateParameters["lowerSectionTotal"] = IsLowerSectionComplete(scoreSheet) ? scoreSheet.LowerSectionTotal.ToString() : string.Empty; templateParameters["grandTotal"] = IsSheetComplete(scoreSheet) ? scoreSheet.GrandTotal.ToString() : string.Empty; return(templateParameters); }
private Dictionary<string, string> BuildTemplateParametersDictionary(IScoreSheet scoreSheet) { var templateParameters = new Dictionary<string, string>(); templateParameters["ones"] = scoreSheet.Ones.ToString(); templateParameters["twos"] = scoreSheet.Twos.ToString(); templateParameters["threes"] = scoreSheet.Threes.ToString(); templateParameters["fours"] = scoreSheet.Fours.ToString(); templateParameters["fives"] = scoreSheet.Fives.ToString(); templateParameters["sixes"] = scoreSheet.Sixes.ToString(); templateParameters["upperSectionTotal"] = IsUpperSectionComplete(scoreSheet) ? scoreSheet.UpperSectionTotal.ToString() : string.Empty; templateParameters["bonus"] = IsUpperSectionComplete(scoreSheet) ? scoreSheet.UpperSectionBonus.ToString() : string.Empty; templateParameters["upperSectionTotalWithBonus"] = IsUpperSectionComplete(scoreSheet) ? scoreSheet.UpperSectionTotalWithBonus.ToString() : string.Empty; templateParameters["threeOfAKind"] = scoreSheet.ThreeOfAKind.ToString(); templateParameters["fourOfAKind"] = scoreSheet.FourOfAKind.ToString(); templateParameters["fullHouse"] = scoreSheet.FullHouse.ToString(); templateParameters["smallStraight"] = scoreSheet.SmallStraight.ToString(); templateParameters["largeStraight"] = scoreSheet.LargeStraight.ToString(); templateParameters["chance"] = scoreSheet.Chance.ToString(); templateParameters["yahtzee"] = scoreSheet.Yahtzee.ToString(); var yahtzeeBonus = new int[3]; yahtzeeBonus[0] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(0); yahtzeeBonus[1] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(1); yahtzeeBonus[2] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(2); templateParameters["yahtzeeBonus1"] = yahtzeeBonus[0] == 0 ? " " : "X"; templateParameters["yahtzeeBonus2"] = yahtzeeBonus[1] == 0 ? " " : "X"; templateParameters["yahtzeeBonus3"] = yahtzeeBonus[2] == 0 ? " " : "X"; templateParameters["lowerSectionTotal"] = IsLowerSectionComplete(scoreSheet) ? scoreSheet.LowerSectionTotal.ToString() : string.Empty; templateParameters["grandTotal"] = IsSheetComplete(scoreSheet) ? scoreSheet.GrandTotal.ToString() : string.Empty; return templateParameters; }
private Dictionary<string, string> BuildTemplateParametersDictionary(IScoreSheet scoreSheet) { var templateParameters = new Dictionary<string, string>(); templateParameters["ones"] = scoreSheet.Ones.ToString(); templateParameters["twos"] = scoreSheet.Twos.ToString(); templateParameters["threes"] = scoreSheet.Threes.ToString(); templateParameters["fours"] = scoreSheet.Fours.ToString(); templateParameters["fives"] = scoreSheet.Fives.ToString(); templateParameters["sixes"] = scoreSheet.Sixes.ToString(); templateParameters["upperSectionTotal"] = String.Empty; // TODO: Write a method in IScoreSheet to return this value templateParameters["bonus"] = String.Empty; // TODO: Same as above templateParameters["upperSectionTotalWithBonus"] = String.Empty; // TODO: Same as above templateParameters["threeOfAKind"] = scoreSheet.ThreeOfAKind.ToString(); templateParameters["fourOfAKind"] = scoreSheet.FourOfAKind.ToString(); templateParameters["fullHouse"] = scoreSheet.FullHouse.ToString(); templateParameters["smallStraight"] = scoreSheet.SmallStraight.ToString(); templateParameters["largeStraight"] = scoreSheet.LargeStraight.ToString(); templateParameters["chance"] = scoreSheet.LargeStraight.ToString(); templateParameters["yahtzee"] = scoreSheet.Yahtzee.ToString(); var yahtzeeBonus = new int[3]; yahtzeeBonus[0] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(0); yahtzeeBonus[1] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(1); yahtzeeBonus[2] = scoreSheet.YahtzeeBonus.ElementAtOrDefault(2); templateParameters["yahtzeeBonus1"] = yahtzeeBonus[0] == 0 ? " " : yahtzeeBonus[0].ToString(); templateParameters["yahtzeeBonus2"] = yahtzeeBonus[1] == 0 ? " " : yahtzeeBonus[1].ToString(); templateParameters["yahtzeeBonus3"] = yahtzeeBonus[2] == 0 ? " " : yahtzeeBonus[2].ToString(); templateParameters["lowerSectionTotal"] = string.Empty; // TODO: Write a method in IScoreSheet to return this value templateParameters["grandTotal"] = string.Empty; // TODO: Write a method in IScoreSheet to return this value return templateParameters; }
private bool IsSheetComplete(IScoreSheet scoreSheet) { return(IsUpperSectionComplete(scoreSheet) && IsLowerSectionComplete(scoreSheet)); }
private bool IsUpperSectionComplete(IScoreSheet scoreSheet) { if (scoreSheet.Ones == null || scoreSheet.Twos == null || scoreSheet.Threes == null || scoreSheet.Fours == null || scoreSheet.Fives == null || scoreSheet.Sixes == null) { return false; } return true; }
private bool IsSheetComplete(IScoreSheet scoreSheet) { return IsUpperSectionComplete(scoreSheet) && IsLowerSectionComplete(scoreSheet); }
public void Display(IScoreSheet scoreSheet) { Dictionary<string, string> templateParameters = BuildTemplateParametersDictionary(scoreSheet); string output = Regex.Replace(_template, @"\{(.+?)\}", m => templateParameters[m.Groups[1].Value]); Console.WriteLine(output); }
public void SetScore(IScoreSheet score) { _score = score; }