当前位置: 首页>>代码示例>>C++>>正文


C++ Piece::GetCurrentConfiguration方法代码示例

本文整理汇总了C++中Piece::GetCurrentConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C++ Piece::GetCurrentConfiguration方法的具体用法?C++ Piece::GetCurrentConfiguration怎么用?C++ Piece::GetCurrentConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piece的用法示例。


在下文中一共展示了Piece::GetCurrentConfiguration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BoardDrawingArea_BoardClicked

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();
    }
}
开发者ID:frechilla,项目名称:blockem,代码行数:67,代码来源:game_total_allocation_widget.cpp

示例2: BoardDrawingArea_BoardClicked

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();
    }
}
开发者ID:frechilla,项目名称:blockem,代码行数:69,代码来源:game_challenge_widget.cpp


注:本文中的Piece::GetCurrentConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。