Beispiel #1
0
 public void SetGameSettings(string o_playerXInput, string o_playerOInput, eBoardSizeOptions o_BoardSizeInput, eTypeOfGame o_GameTypeInput)
 {
     m_Player1Name = o_playerXInput;
     m_Player2Name = o_playerOInput;
     m_BoardSize   = o_BoardSizeInput;
     m_GameType    = o_GameTypeInput;
 }
Beispiel #2
0
 public static void initializeSessionData(InitialGameSetting gameSettings)
 {
     m_BoardSize = gameSettings.GetBoardSize();
     s_GameType  = gameSettings.GetGameType();
 }
Beispiel #3
0
 public static void initializeSessionData(InitialGameSetting gameSettings)
 {
     m_BoardSize = gameSettings.boardSize;
     gameType    = gameSettings.gameType;
 }
Beispiel #4
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);
        }