Пример #1
0
 public void makeMove(Cell moveToMake)
 {
     moveToMake.setValue(main_GD.getCharacterToPlace());
     moveToMake.getButton().Text    = main_GD.getCharacterToPlace().ToString();
     moveToMake.getButton().Enabled = false;
     main_GD.setCellGameBoard(moveToMake, moveToMake.getRow(), moveToMake.getCol());
     main_GD.performMoveActionsOnBoard();
 }
Пример #2
0
        public void playerMove(Button button)
        {
            string name;
            char   delim = '_';
            int    posDelim;
            int    col;
            int    row;
            //used to store the information about the cell (button) that I pressed.
            Cell cell             = new Cell();
            char characterToPlace = GD.getCharacterToPlace();

            //parse the name
            //find the row
            //find the column
            //write if statements for row
            //write code below once.

            name     = button.Name;
            posDelim = name.IndexOf(delim);
            row      = Int32.Parse(name.Substring(posDelim + 1, 1));
            name     = name.Substring(posDelim + 2);
            posDelim = name.IndexOf(delim);
            col      = Int32.Parse(name.Substring(posDelim + 1));
            cell     = GD.getGameBoardCell(row, col);

            //Make the move
            cell.setValue(characterToPlace);
            cell.getButton().Text = characterToPlace.ToString();
            GD.setCellGameBoard(cell, row, col);

            //disable the button that the user pressed
            cell.getButton().Enabled = false;

            //make the move on the board array and determine what to do after the specified move.
            GD.performMoveActionsOnBoard();

            if (GD.getGameOver() == true)
            {
                disableAllButtons();
                //display who won
                displayWinner();
            }
        }