bool Player::move(int maxRow, int maxCol,GameBoard * gb) { int row, col; myMove(row,col,maxRow,maxCol); if((row>maxRow) || (col>maxCol)|| (row<0) || (col<0)) return false; //mark Board w/ valid values return gb->markBoard(row,col,myMark); }
void TicTacGameBoard::buttonClicked() { if ( st != HumansTurn ) // not ready return; int i = buttons->findRef( (TicTacButton*)sender() ); TicTacButton *b = buttons->at(i); // get piece that was pressed if ( b->type() == TicTacButton::Blank ) { // empty piece? btArray->at(i) = TicTacButton::Circle; emit myMove(i); st = ComputersTurn; updateButtons(); //if ( checkBoard( btArray ) == 0 ) // not a winning move? //computerMove(); int s = checkBoard( btArray ); if ( s ) { // any winners yet? st = s == TicTacButton::Circle ? HumanWon : ComputerWon; emit finished(); } } }