void GameTotalAllocationWidget::BoardDrawingArea_BoardClicked( const Coordinate &a_coord, const Piece &a_piece, const Player &a_player) { if (a_player.NumberOfPiecesAvailable() == e_numberOfPieces) { if ( ( (!a_player.GetStartingCoordinate().Initialised()) && (!rules::IsPieceDeployableInStartingPoint( m_theTotalAllocationGame.GetBoard(), a_piece.GetCurrentConfiguration(), a_coord, a_coord)) ) || ( (a_player.GetStartingCoordinate().Initialised()) && (!rules::IsPieceDeployableInStartingPoint( m_theTotalAllocationGame.GetBoard(), a_piece.GetCurrentConfiguration(), a_coord, a_player.GetStartingCoordinate())) ) ) { #ifdef DEBUG_PRINT std::cout << "Starting coordinate deployment failure: Cheeky you! Don't try to deploy a piece where it's not allowed to" << std::endl; #endif return; } } else { if (!rules::IsPieceDeployableCompute( m_theTotalAllocationGame.GetBoard(), a_piece.GetCurrentConfiguration(), a_coord, a_player)) { #ifdef DEBUG_PRINT std::cout << "Deployment failure: Cheeky you! Don't try to deploy a piece where it's not allowed to" << std::endl; #endif return; } } // put down current piece before anything else m_theTotalAllocationGame.PutDownPiece(a_piece, a_coord); // invalidate the board drawing area to show the new moves // activating the latest piece deployed glowing effect m_boardDrawingArea.Invalidate(a_piece, a_coord, a_player); // update score m_statusBar.SetScoreStatus(1, a_player); // remove the actual piece being edited from the edit piece drawing area // and force the edit piece drawing area to be redraw m_editPieceTable.SetPiece(e_noPiece); // update the list of available pieces too m_pickPiecesDrawingArea.Invalidate(); // there's a few things that have to be done if this player can't put // down any more pieces if (rules::CanPlayerGo(m_theTotalAllocationGame.GetBoard(), a_player) == false) { GameFinished(); } }
void GameChallengeWidget::BoardDrawingArea_BoardClicked( const Coordinate &a_coord, const Piece &a_piece, const Player &a_player) { if (a_player.GetStartingCoordinate().Initialised() && m_theChallengeGame.GetBoard().IsCoordEmpty(a_player.GetStartingCoordinate())) { // check if the piece can be deployed on the starting coordinate // or in any of the available nucleation points // // use IsPieceDeployableInCoord instead of IsPieceDeployableInStartingPoint // so it supports blockem challenges if ( !rules::IsPieceDeployableInCoord( m_theChallengeGame.GetBoard(), a_piece.GetCurrentConfiguration(), a_coord, a_player.GetStartingCoordinate(), a_player) && !rules::IsPieceDeployableCompute( m_theChallengeGame.GetBoard(), a_piece.GetCurrentConfiguration(), a_coord, a_player) ) { #ifdef DEBUG_PRINT std::cout << "Cheeky you! Don't try to deploy a piece where it's not allowed to" << std::endl; #endif return; } } else if (!rules::IsPieceDeployableCompute( m_theChallengeGame.GetBoard(), a_piece.GetCurrentConfiguration(), a_coord, a_player)) { #ifdef DEBUG_PRINT std::cout << "Cheeky you! Don't try to deploy a piece where it's not allowed to" << std::endl; #endif return; } // put down current piece before anything else m_theChallengeGame.PutDownPiece(a_piece, a_coord); // invalidate the board drawing area to show the new moves // activating the latest piece deployed glowing effect m_boardDrawingArea.Invalidate(a_piece, a_coord, a_player); // update score m_statusBar.SetScoreStatus(1, a_player); // remove the actual piece being edited from the edit piece drawing area // and force the edit piece drawing area to be redraw m_editPieceTable.SetPiece(e_noPiece); // update the list of available pieces too m_pickPiecesDrawingArea.Invalidate(); // there's a few things that have to be done if this player can't put // down any more pieces if (rules::CanPlayerGo(m_theChallengeGame.GetBoard(), a_player) == false) { GameFinished(); } }