Пример #1
0
 private void setup(out InitialGameSetting o_Settings)
 {
     o_Settings = new InitialGameSetting();
     o_Settings.SetGameSettings("Ori", "Amir", eBoardSizeOptions.SmallBoard, eTypeOfGame.singlePlayer);
 }
Пример #2
0
        public static void ReadGameInitialInputFromUser(out InitialGameSetting io_GameInitialValues)
        {
            string userInputValue;
            string tempPlayer1NameHolder = string.Empty;
            string tempPlayer2NameHolder = string.Empty;

            bool[]            inputValidityArray = new bool[k_NumberOfInputValues]; // holds true/false for each input value in this order: player1name, player2name, boardSize, gameType
            bool              gotAllInput        = false;
            eBoardSizeOptions chosenBoardSize    = eBoardSizeOptions.Undefined;
            eTypeOfGame       chosenGameType     = eTypeOfGame.Undefined;

            Console.WriteLine(s_StartMessage);
            while (!gotAllInput)
            {
                while (!inputValidityArray[k_PlayerXName])
                {
                    Console.WriteLine(s_UsernameMessage);
                    userInputValue = Console.ReadLine();
                    if (checkUsernameValidity(userInputValue))
                    {
                        inputValidityArray[k_PlayerXName] = true;
                        tempPlayer1NameHolder             = userInputValue;
                    }
                    else
                    {
                        Console.WriteLine(s_InvalidInputMessage);
                    }
                }

                Ex02.ConsoleUtils.Screen.Clear();
                while (!inputValidityArray[k_BoardSize])
                {
                    Console.WriteLine(s_ChooseBoardSizeMessage);
                    userInputValue = Console.ReadLine();
                    if (checkBoardSizeValidity(userInputValue))
                    {
                        inputValidityArray[k_BoardSize] = true;
                        chosenBoardSize = (eBoardSizeOptions)Enum.Parse(typeof(eBoardSizeOptions), userInputValue);
                    }
                    else
                    {
                        Console.WriteLine(s_InvalidInputMessage);
                    }
                }

                Ex02.ConsoleUtils.Screen.Clear();
                while (!inputValidityArray[k_GameType])
                {
                    Console.WriteLine(s_ChooseGameTypeMessge);
                    userInputValue = Console.ReadLine();
                    if (checkGameTypeValidity(userInputValue))
                    {
                        inputValidityArray[k_GameType] = true;
                        chosenGameType = (eTypeOfGame)Enum.Parse(typeof(eTypeOfGame), userInputValue);
                        Ex02.ConsoleUtils.Screen.Clear();
                        if (chosenGameType == eTypeOfGame.doublePlayer)
                        {
                            while (!inputValidityArray[k_PlayerOName])
                            {
                                Console.Write("{0}, ", ePlayerOptions.Player2.ToString());
                                Console.WriteLine(s_UsernameMessage);
                                userInputValue = Console.ReadLine();
                                if (checkUsernameValidity(userInputValue))
                                {
                                    inputValidityArray[k_PlayerOName] = true;
                                    tempPlayer2NameHolder             = userInputValue;
                                }
                                else
                                {
                                    Console.WriteLine(s_InvalidInputMessage);
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(s_InvalidInputMessage);
                    }
                }

                Ex02.ConsoleUtils.Screen.Clear();
                gotAllInput = true;
            }

            io_GameInitialValues = new InitialGameSetting();
            io_GameInitialValues.SetGameSettings(tempPlayer1NameHolder, tempPlayer2NameHolder, chosenBoardSize, chosenGameType);
        }