Example #1
0
        public static bool userMove()
        {
            bool notover = true;
            int  colChoice;
            int  rowChoice;
            bool invalid = true;

            do
            {
                Console.Write($"\n\nEnter the column for the square you choose: ");
                colChoice = Validate.input2ColumnChoice();
                Console.Write($"Enter the row for the square you choose: ");
                rowChoice = Validate.input2RowChoice();
                if (GenerateBoard.userboard[rowChoice - 1, colChoice - 1] != " ")
                {
                    Messages.invalid(5);
                }
                else
                {
                    invalid = false;
                    if (GenerateBoard.mappedboard[rowChoice - 1, colChoice - 1] == -1)
                    {
                        GenerateBoard.userboard[rowChoice - 1, colChoice - 1] = "*";
                        notover = false;
                        Program.losses++;
                        animations.boom();
                        Messages.showScore();
                        Messages.gameover();
                    }
                    else
                    {
                        GenerateBoard.userboard[rowChoice - 1, colChoice - 1] = GenerateBoard.mappedboard[rowChoice - 1, colChoice - 1].ToString();
                        if (GenerateBoard.userboard[rowChoice - 1, colChoice - 1] == "0")
                        {
                            GenerateBoard.userboard[rowChoice - 1, colChoice - 1] = "X";
                            checkNoMinds(rowChoice - 1, colChoice - 1);
                        }
                        for (int i = 0; i < need2check.Count; i++)
                        {
                            checkNoMinds(need2check[i].xCoor, need2check[i].yCoor);
                        }
                        need2check.Clear();
                    }
                }
            } while (invalid);
            GenerateBoard.showboard();
            return(notover);
        }
Example #2
0
        static void Main(string[] args)
        {
            bool playAgain = true;
            bool notover   = true;

            animations.gameName();   //for quicker testing disable this line
            do
            {
                GenerateBoard.CreateBoard();

                GenerateBoard.showboard();
                do
                {
                    notover = PlayerMove.userMove();
                    if (notover == true)
                    {
                        notover = PlayerMove.winner();
                    }
                } while (notover);
                playAgain = Continue.YN();
            } while (playAgain);
        }