Example #1
0
 private void prepareBoardToNewGame(int numberOfFirstPlayer, int widthBoard = 8, int heightBoard = 8)
 {
     engine = new ReversiEngine(numberOfFirstPlayer, widthBoard, heightBoard);
     listOfMovesPurple.Items.Clear();
     listOFMoveOrange.Items.Clear();
     contentBoard();
     Board.IsEnabled         = true;
     ColorOfPlayer.IsEnabled = true;
 }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();

            engine = new ReversiEngine(1);

            for (int i = 0; i < engine.WidthBoard; i++)
            {
                Board.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (int j = 0; j < engine.HeightBoard; j++)
            {
                Board.RowDefinitions.Add(new RowDefinition());
            }

            board = new Button[engine.WidthBoard, engine.HeightBoard];
            for (int i = 0; i < engine.WidthBoard; i++)
            {
                for (int j = 0; j < engine.HeightBoard; j++)
                {
                    Button button = new Button();
                    button.Margin = new Thickness(0);
                    Board.Children.Add(button);
                    Grid.SetColumn(button, i);
                    Grid.SetRow(button, j);
                    button.Tag = new coordinatesFields {
                        horizontal = i, vertical = j
                    };
                    button.Click += new RoutedEventHandler(clikFieldsBoard);
                    board[i, j]   = button;
                }
            }

            contentBoard();
        }