Beispiel #1
0
// Redo the last move
void Game::Redo(wxDC& dc)
{
    if (m_moveIndex < m_redoIndex)
    {
        Card* card = m_moves[m_moveIndex].src->RemoveTopCard(dc);
        if (m_moves[m_moveIndex].src == m_pack)
        {
            m_pack->Redraw(dc);
            card->TurnCard(faceup);
        }
        m_moves[m_moveIndex].dest->AddCard(dc, card);
        DisplayScore(dc);
        m_moveIndex++;
    }
}
Beispiel #2
0
// Shuffle the m_pack and deal the cards
void Game::Deal()
{
    int i, j;
    Card* card;

    // Reset all the piles, the undo buffer and shuffle the m_pack
    m_moveIndex = 0;
    m_pack->ResetPile();
    for (i = 0; i < 5; i++)
    {
        m_pack->Shuffle();
    }
    m_discard->ResetPile();
    for (i = 0; i < 10; i++)
    {
        m_bases[i]->ResetPile();
    }
    for (i = 0; i <  8; i++)
    {
        m_foundations[i]->ResetPile();
    }

    // Deal the initial 40 cards onto the bases
    for (i = 0; i < 10; i++)
    {
        for (j = 1; j <= 4; j++)
        {
            card = m_pack->RemoveTopCard();
            card->TurnCard(faceup);
            m_bases[i]->AddCard(card);
        }
    }

    if (m_inPlay)
    {
        // player has started the game and then redealt
        // and so we must add the score for this game to the total score
        m_totalScore += m_currentScore;
    }
    m_currentScore = 0;
    m_inPlay = false;
}
Beispiel #3
0
// Left button is pressed - if cursor is over the m_pack then deal a card
// otherwise if it is over a card pick it up ready to be dragged - see MouseMove()
bool Game::LButtonDown(wxDC& dc, int x, int y)
{
    m_srcPile = WhichPile(x, y);
    if (m_srcPile == m_pack)
    {
        Card* card = m_pack->RemoveTopCard();
        if (card)
        {
            m_pack->Redraw(dc);
            card->TurnCard(faceup);
            m_discard->AddCard(dc, card);
            DoMove(dc, m_pack, m_discard);
        }
        m_srcPile = 0;
    }
    else if (m_srcPile)
    {
        m_srcPile->GetTopCardPos(m_xPos, m_yPos);
        m_xOffset = m_xPos - x;
        m_yOffset = m_yPos - y;

        // Copy the area under the card
        // Initialise the card bitmap to the background colour
        {
            wxMemoryDC memoryDC;
            memoryDC.SelectObject(*m_bmap);
            m_liftedCard = m_srcPile->RemoveTopCard(memoryDC, m_xPos, m_yPos);
        }

        // Draw the card in card bitmap ready for blitting onto
        // the screen
        {
            wxMemoryDC memoryDC;
            memoryDC.SelectObject(*m_bmapCard);
            m_liftedCard->Draw(memoryDC, 0, 0);
        }
    }
    return m_srcPile != 0;
}
Beispiel #4
0
// Shuffle the m_pack and deal the cards
void Game::Deal()
{
    int i, j;
    Card* card;

    // Reset all the piles, the undo buffer and shuffle the m_pack
    m_moveIndex = 0;
    m_pack->ResetPile();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for (i = 0; i < 5; i++)
    {
        m_pack->Shuffle();
    }
    m_discard->ResetPile();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for (i = 0; i < 10; i++)
    {
        m_bases[i]->ResetPile();
    }
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for (i = 0; i <  8; i++)
    {
        m_foundations[i]->ResetPile();
    }

    // Deal the initial 40 cards onto the bases
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for (i = 0; i < 10; i++)
    {
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
        for (j = 1; j <= 4; j++)
        {
            card = m_pack->RemoveTopCard();
            card->TurnCard(faceup);
            m_bases[i]->AddCard(card);
        }
    }

    if (m_inPlay)
    {
        // player has started the game and then redealt
        // and so we must add the score for this game to the total score
        m_totalScore += m_currentScore;
    }
    m_currentScore = 0;
    m_inPlay = false;
}