Example #1
0
        /// <summary>
        /// Formats and groups invalid options with corresponding parameters
        /// </summary>
        /// <param name="errors">The list of errors</param>
        /// <returns>A formatted list of errors</returns>
        private static List <string> FormatArgErrors(List <string> errors)
        {
            List <string> formattedList = new List <string>();
            int           counter       = 0;
            string        currentItem;
            string        previousItem = errors[0];
            string        listEntry    = "";

            for (int i = counter; i < errors.Count; i++)
            {
                currentItem = errors[i];
                bool currentIsOption  = ArgumentChecker.IsOption(currentItem);
                bool previousIsOption = ArgumentChecker.IsOption(previousItem);

                if (currentIsOption)
                {
                    if (i != 0)
                    {
                        if (!previousIsOption)
                        {
                            listEntry += " ]";
                            formattedList.Add(listEntry);
                        }
                    }
                    listEntry = currentItem;
                }
                else
                {
                    if (i == 0)
                    {
                        listEntry += $"[ {currentItem}";
                    }
                    else if (previousIsOption)
                    {
                        listEntry += $": [ {currentItem}";
                    }
                    else
                    {
                        listEntry += $", {currentItem}";
                    }
                }
                previousItem = currentItem;
            }
            if (!ArgumentChecker.IsOption(previousItem))
            {
                listEntry += " ]";
                formattedList.Add(listEntry);
            }
            else
            {
                formattedList.Add(listEntry);
            }

            return(formattedList);
        }
Example #2
0
        static void Main(string[] args)
        {
            Settings gameSettings;

            // Generate the settings and an instance of the game with those settings
            gameSettings = ArgumentChecker.GenerateGameSettings(args);
            Game game = new Game(gameSettings);

            // Play the game
            game.PrintSettings();
            game.CycleThroughGame();
            game.RenderFinalGrid();
        }