Exemple #1
0
        public override void round()
        {
            turn(player1);

            //if no one has won yet it's player2's turn

            if (newGame.AndTheWinnerIs() == null && newGame.FreeSpaces() == true)
            {
                turn(player2);
            }

            //player 1 won
            else
            {
                announceWinner();
            }
            return;
        }
Exemple #2
0
        private int currentPlayer; //either 1 or 2



        public void startGame()
        {
            turnStackProp = new Stack <TurnData>();
            string type = "";

            player1.type = Player.playerType.Human;
            //player1.colour = "Blue";
            //player2.colour = "DarkYellow";
            currentPlayer = 1;
            while (!(type.Equals("s") | type.Equals("m")))
            {
                Console.WriteLine("Press (s) for single player or (m) for multi-player ");
                type = Console.ReadLine();
                if (type == "s")
                {
                    player2.type = Player.playerType.Computer;
                    player2.name = "Roboto-san";
                    Console.WriteLine("Please enter your name:");
                    player1.name = Console.ReadLine();
                }

                else if (type.Equals("m"))
                {
                    player2.type = Player.playerType.Human;
                    Console.WriteLine("Player 1: Please enter your name:");
                    player1.name = Console.ReadLine();
                    Console.WriteLine("Player 2: Please enter your name:");
                    player2.name = Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Invalid character. Press s or m.");
                }
            }


            Console.WriteLine("Please choose the size of the board, starting with the length.\n Please enter an integer value:");
            Length = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Now enter the desired height of the board:");
            Height  = Convert.ToInt32(Console.ReadLine());
            newGame = new ConnectFourBoard(Length, Height);
            newGame.display();

            while (newGame.FreeSpaces() == true && newGame.AndTheWinnerIs() == null)
            {
                round();
            }

            //player2 won
            if (newGame.AndTheWinnerIs() == "player2")
            {
                announceWinner();
            }
            return;
        }