Beispiel #1
0
        public void GameLoop()
        {
            foreach (var player in players)
            {
                if (player.IsMovingNow)
                {
                    board.PrintOutBoard(players);
                    if (board.CheckWin())
                    {
                        break;
                    }

                    Console.WriteLine("\nCurrent move: " + player.Name);
                    Console.WriteLine("Chose row from 1 to 7 incluedietly, which drop the mark: ");
                    //Console.WriteLine("[q] Quit from game ");

                    try {
                        int selectRow = Convert.ToInt32(Console.ReadLine());


                        if (selectRow > 0 && selectRow <= 7)
                        {
                            // Console.WriteLine("Selected: " + selectRow);

                            if (board.DropTheMark(selectRow - 1, player.Mark(players)))
                            {
                                Player.NextPlater(players);
                            }
                            else
                            {
                                Console.WriteLine("This row is full!");
                            }
                        }
                    } catch (FormatException) {
                        //pass
                    } catch (IndexOutOfRangeException) {
                        //pass
                    }
                }
            }
        }