private void AddGame() { ConsoleUtility.WriteLineAsHeading("Add Game"); var game = new Game(); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("Was the game a stalemate?"); game.WasAStalemate = ConsoleUtility.ReadYesNoAnswer(); ConsoleUtility.WriteHyphenLine(); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("Avaiable Players"); ConsoleUtility.WriteHyphenLine("Avaiable Players"); foreach (Player player in Players) { ConsoleUtility.WriteLine($"{player.CurrentRank}. {player.FirstName}"); } ConsoleUtility.WriteHyphenLine(); int winnerNumber, loserNumber; if (game.WasAStalemate) { ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was player one?"); winnerNumber = ConsoleUtility.ReadInt(); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was player two?"); loserNumber = ConsoleUtility.ReadInt(); } else { ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was the winner?"); winnerNumber = ConsoleUtility.ReadInt(); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was the loser?"); loserNumber = ConsoleUtility.ReadInt(); } Player winner, loser; winner = Players.FirstOrDefault(player => player.CurrentRank == winnerNumber); loser = Players.FirstOrDefault(player => player.CurrentRank == loserNumber); while (winner == null || loser == null) { Clear(); ConsoleUtility.WriteHyphenLine(); ConsoleUtility.WriteLine("Unable to find one or both of the players for the numbers specified. If you do not see a player in the list please add one using the add player action"); ConsoleUtility.WriteLine("Try again?"); bool tryAgain = ConsoleUtility.ReadYesNoAnswer(); if (tryAgain) { if (game.WasAStalemate) { ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was player one?"); winnerNumber = ConsoleUtility.ReadInt(); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was player two?"); loserNumber = ConsoleUtility.ReadInt(); } else { ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was the winner?"); winnerNumber = ConsoleUtility.ReadInt(); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("In the above list, what number was the loser?"); loserNumber = ConsoleUtility.ReadInt(); } winner = Players.FirstOrDefault(player => player.CurrentRank == winnerNumber); loser = Players.FirstOrDefault(player => player.CurrentRank == loserNumber); } else { Clear(); return; } } game.Winner = winner; game.Loser = loser; Games.Add(game); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("Updating ratings based on added game..."); UpdatePlayerRatingsCore(); ConsoleUtility.WriteLine("Complete"); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("Updating collection of games in spreadsheet..."); ChessScoreboardAPI.UpdateGamesInSpreadsheet(Games); ConsoleUtility.WriteLine("Complete"); ConsoleUtility.WriteLine(); ConsoleUtility.WriteLine("Updating collection of players in spreadsheet..."); ChessScoreboardAPI.UpdateRatingsInSpreadsheet(Players); ConsoleUtility.WriteLine("Complete"); Clear(); }