Exemplo n.º 1
0
 public MemoryGameForm(SettingsForm i_Settings)
 {
     r_MemoryGame  = new MemoryGameLogic(i_Settings.Settings);
     r_PictureCard = new Dictionary <Button, Card>();
     InitializeComponent();
     initializeForm();
     this.ShowDialog();
 }
Exemplo n.º 2
0
        // interacts with the player and require from the player a legal input of a cell to reveal
        // handle illegal input such as, out of bound of the board, a cell that is already exposed
        internal static Tuple <int, int> PlayerTurn(string i_NameOfPlayer, MemoryGameLogic i_Game, ref bool io_WantsToQuit)
        {
            string answerToCheck = Console.ReadLine();

            io_WantsToQuit = answerToCheck.Equals("Q");
            bool isValidInput = i_Game.IsValidInputCell(answerToCheck);
            bool isValidRange = isValidInput && i_Game.IsValidRangeForCell(answerToCheck);
            bool isValidCell  = isValidRange && i_Game.IsValidCell(answerToCheck);

            while (!io_WantsToQuit && (!isValidInput || !isValidRange || !isValidCell))
            {
                if (io_WantsToQuit)
                {
                    break;
                }
                else
                {
                    if (!isValidInput)
                    {
                        Console.WriteLine("Invalid input, please try again");
                    }
                    else if (!isValidRange)
                    {
                        Console.WriteLine("Invalid range input, please try again");
                    }
                    else if (!isValidCell)
                    {
                        Console.WriteLine("The cell you choose is already exposed, please try another one");
                    }

                    answerToCheck  = Console.ReadLine();
                    io_WantsToQuit = answerToCheck.Equals("Q");
                    isValidInput   = i_Game.IsValidInputCell(answerToCheck);
                    isValidRange   = isValidInput && i_Game.IsValidRangeForCell(answerToCheck);
                    isValidCell    = isValidRange && i_Game.IsValidCell(answerToCheck);
                }
            }
            // default value won't be used if io_WantToQuit = true
            Tuple <int, int> retPair = new Tuple <int, int>(0, 0);

            if (!io_WantsToQuit)
            {
                retPair = new Tuple <int, int>(answerToCheck[1] - k_FirstRowIndex, answerToCheck[0] - k_FirstColumnIndex);
            }

            return(retPair);
        }