Exemple #1
0
        private void ClearGames()
        {
            ConsoleUtility.WriteLineAsHeading("Clear Games");

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Clearing list of games...");
            Games = new List <Game>();
            ConsoleUtility.WriteLine("Complete");

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Reseting player ratings");
            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();
        }
        public void Start()
        {
            ConsoleUtility.PreventResize();
            ConsoleUtility.ConfigureConsoleWidths();

            //Loading data...
            ConsoleUtility.WriteHyphenLine();
            ConsoleUtility.WriteLine("Loading Chess Scoreboard spreadsheet data into memory...");
            ConsoleUtility.WriteLine();

            LoadData();

            ConsoleUtility.WriteLine("Loading Complete.");

            Console.Clear();

            //Welcome Message
            ConsoleUtility.WriteHyphenLine();
            ConsoleUtility.WriteLine("Welcome to the RSI Augusta Chess Board Interface!");
            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Enter the action 'Help' to view information about how to use this application");
            ConsoleUtility.WriteHyphenLine();

            do
            {
                ConsoleUtility.WriteLine("What would you like to do?");

                ProcessActionInput(ConsoleUtility.ReadLine());
            } while (RemainOpen);
        }
        private void UnrecognizedCommand(string action)
        {
            ConsoleUtility.WriteLineAsHeading($"Unrecognized Action '{action}'!");

            ConsoleUtility.WriteLine("If you are unsure of what actions are available, please use the 'Help' action");

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteHyphenLine();
        }
Exemple #4
0
        private void ViewPlayers()
        {
            ConsoleUtility.WriteLineAsHeading("View Players");

            foreach (Player player in Players)
            {
                ConsoleUtility.WriteLine($"{player.CurrentRank}. {player.FirstName} is ranked #{player.CurrentRank} with an ELO rating of {player.Rating}");
            }

            ConsoleUtility.WriteHyphenLine();
        }
Exemple #5
0
        private void RefreshData()
        {
            Clear();

            ConsoleUtility.WriteLine("Refreshing data to match the spreadsheet...");

            LoadData();

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Refresh Complete.");
            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteHyphenLine();
        }
Exemple #6
0
        private void Exit()
        {
            RemainOpen = false;

            Console.Clear();

            ConsoleUtility.WriteHyphenLine();
            ConsoleUtility.WriteLine("Goodbye!");
            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("If you have any feedback please share it with me at [email protected]");
            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("This window will now close in 5 seconds");
            ConsoleUtility.WriteHyphenLine();

            Thread.Sleep(5000);
        }
Exemple #7
0
        private void ViewGames()
        {
            ConsoleUtility.WriteLineAsHeading("View Games");

            foreach (Game game in Games)
            {
                if (game.WasAStalemate)
                {
                    ConsoleUtility.WriteLine($"-- Game #{game.Id} was between {game.Winner.FirstName} and {game.Loser.FirstName}. The outcome was a draw!");
                }
                else
                {
                    ConsoleUtility.WriteLine($"-- Game #{game.Id} was between {game.Winner.FirstName} and {game.Loser.FirstName}. The outcome was a win for {game.Winner.FirstName}!");
                }
            }

            ConsoleUtility.WriteHyphenLine();
        }
Exemple #8
0
        private void AddPlayer()
        {
            ConsoleUtility.WriteLineAsHeading("Add Player");

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("What is the name of the player you would like to add?");

            string playerName = ConsoleUtility.ReadLine();

            var player = new Player(Players.Max(p => p.CurrentRank) + 1, Constants.BaseRating, playerName);

            Players.Add(player);

            ChessScoreboardAPI.UpdatePlayersInSpreadsheet(Players);

            Clear();
            ViewPlayers();
        }
Exemple #9
0
        private void UpdatePlayerRatings()
        {
            ConsoleUtility.WriteLineAsHeading("Update Player Ratings");

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Updating Player Ratings...");

            UpdatePlayerRatingsCore();

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Updating the Spreadsheet with the new Player Ratings...");
            ChessScoreboardAPI.UpdateRatingsInSpreadsheet(Players);

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Update Complete");

            Clear();
            ViewPlayers();
        }
Exemple #10
0
        private void Help()
        {
            ConsoleUtility.WriteLineAsHeading("Help Information");

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Available Actions");
            ConsoleUtility.WriteHyphenLine("Available Actions");
            ConsoleUtility.WriteLine();

            foreach (UserAction userAction in UserActions)
            {
                string summary = $"-- Action: '{userAction.Name}' | Description: '{userAction.Description}'";
                ConsoleUtility.WriteHyphenLine(summary);
                ConsoleUtility.WriteLine(summary);

                if (userAction.Aliases.Any())
                {
                    ConsoleUtility.WriteLine($"-- \t Action Aliases: '{string.Join(", ", userAction.Aliases.ToArray())}'");
                }
            }

            ConsoleUtility.WriteHyphenLine();

            ConsoleUtility.WriteLine();
            ConsoleUtility.WriteLine("Available Answers to Yes/No Questions (Anything not on the list is treated as a no)");
            ConsoleUtility.WriteHyphenLine("Available Answers to Yes/No Questions (Anything not on the list is treated as a no)");

            foreach (string acceptableYesAnswer in ConsoleUtility.AcceptableYesAnswers)
            {
                ConsoleUtility.WriteLine($"-- {acceptableYesAnswer}");
            }

            ConsoleUtility.WriteLine();

            ConsoleUtility.WriteHyphenLine();
            ConsoleUtility.WriteLine("For more information, send me an email at [email protected]");
            ConsoleUtility.WriteHyphenLine();
        }
Exemple #11
0
        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();
        }
Exemple #12
0
 private void Clear()
 {
     Console.Clear();
     ConsoleUtility.WriteHyphenLine();
 }