Esempio n. 1
0
void DealCards(CardStack& cards, int players[], ofstream& outFile)
{
	outFile << "  SCORE: ";
	for (int index = 0; index < NUM_PLAYERS; index++)
	{
		players[index] += cards.Top();
		cards.Pop();
		outFile << "\t" << players[index];
	}
	outFile << endl;
}
Esempio n. 2
0
//
//    Double-click on the deck
//    Move 3 cards to the face-up pile
//
void CARDLIBPROC DeckClickProc(CardRegion &stackobj, int iNumClicked)
{
    TRACE("ENTER DeckClickProc()\n");
    CardStack cardstack = stackobj.GetCardStack();
    CardStack pile      = pPile->GetCardStack();

    fGameStarted = true;

    //reset the face-up pile to represent 3 cards
    if(dwOptions & OPTION_THREE_CARDS)
        pPile->SetOffsets(CS_DEFXOFF, 1);

    if(cardstack.NumCards() == 0)
    {
        pile.Clear();

        activepile.Reverse();
        cardstack.Push(activepile);
        activepile.Clear();
    }
    else
    {
        int numcards = min((dwOptions & OPTION_THREE_CARDS) ? 3 : 1, cardstack.NumCards());

        //make a "visible" copy of these cards
        CardStack temp;
        temp = cardstack.Pop(numcards);
        temp.Reverse();

        if(dwOptions & OPTION_THREE_CARDS)
            pile.Clear();

        pile.Push(temp);

        //remove the top 3 from deck
        activepile.Push(temp);
    }

    activepile.Print();

    pDeck->SetCardStack(cardstack);
    pPile->SetCardStack(pile);

    SolWnd.Redraw();
    TRACE("EXIT DeckClickProc()\n");
}
Esempio n. 3
0
//
//    What happens when a card is removed from face-up pile?
//
void CARDLIBPROC PileRemoveProc(CardRegion &stackobj, int iItems)
{
    TRACE("ENTER PileRemoveProc()\n");
    //modify our "virtual" pile by removing the same card
    //that was removed from the physical card stack
    activepile.Pop(iItems);

    //if there is just 1 card left, then modify the
    //stack to contain ALL the face-up cards..the effect
    //will be, the next time a card is dragged, all the
    //previous card-triplets will be available underneath
    if(stackobj.NumCards() == 1)
    {
        stackobj.SetOffsets(0,0);
        stackobj.SetCardStack(activepile);
    }
    TRACE("EXIT PileRemoveProc()\n");
}
Esempio n. 4
0
void NewGame(void)
{
    TRACE("ENTER NewGame()\n");
    int i, j;

    SolWnd.EmptyStacks();

    //create a new card-stack
    CardStack deck;
    deck.NewDeck();
    deck.Shuffle();
    activepile.Clear();

    //deal to each row stack..
    for(i = 0; i < NUM_ROW_STACKS; i++)
    {
        CardStack temp;
        temp.Clear();

        pRowStack[i]->SetFaceDirection(CS_FACE_DOWNUP, i);

        for(j = 0; j <= i; j++)
        {
            temp.Push(deck.Pop());
        }

        pRowStack[i]->SetCardStack(temp);
    }

    //put the other cards onto the deck
    pDeck->SetCardStack(deck);
    pDeck->Update();

    // For the 1-card-mode, all cards need to be completely overlapped
    if(!(dwOptions & OPTION_THREE_CARDS))
        pPile->SetOffsets(0, 0);

    SolWnd.Redraw();

    fGameStarted = false;
    TRACE("EXIT NewGame()\n");
}
Esempio n. 5
0
/* Click on the deck */
void CARDLIBPROC DeckClickProc(CardRegion &stackobj, int NumDragCards)
{
    CardStack temp, fakeDeck = pDeck->GetCardStack();
    fGameStarted = true;

    if (fakeDeck.NumCards() != 0 && deck.NumCards() != 0)
    {
        int i, facedown, faceup;
        /* Add one card to every stack */
        for (i = 0; i < NUM_STACKS; i++)
        {
            temp = pStack[i]->GetCardStack();
            temp.Push(deck.Pop());

            /* Check if we accidentally finished a row */
            pStack[i]->GetFaceDirection(&facedown);
            faceup = temp.NumCards() - facedown;
            if (faceup >= NUM_ONECOLOR_CARDS)
            {
                /* Check stack finished, remove cards if so */
                if (stackLookingGood(temp, NUM_ONECOLOR_CARDS - 1))
                {
                    int j;
                    for (j = 0; j < NUM_ONECOLOR_CARDS; j++)
                    {
                        temp.RemoveCard(0);
                    }
                    cardsFinished += NUM_ONECOLOR_CARDS;
                    pStack[i]->SetCardStack(temp);
                    /* Turn now topmost card */
                    TurnStackCard(*pStack[i]);
                }
            }
            pStack[i]->SetCardStack(temp);
        }
        /* Remove one card from the fake ones */
        pDeck->SetCardStack(fakeDeck.Pop(fakeDeck.NumCards() - 1));
    }
    pDeck->Update();
    SpiderWnd.Redraw();
}
Esempio n. 6
0
void NewGame(void)
{
    int i, j;
    /* First four stack with five, all other with 4 */
    int covCards = 5; 
    CardStack fakeDeck, temp;

    SpiderWnd.EmptyStacks();

    /* Create a new card-deck, fake deck */
    deck = CreatePlayDeck();
    deck.Shuffle();
    fakeDeck.NewDeck();
    fakeDeck.Shuffle();
    
    /* Reset progress value */
    cardsFinished = 0;

    /* Deal to each stack */
    for (i = 0; i < NUM_STACKS; i++)
    {
        temp.Clear();       
        if (i == NUM_SMALLER_STACKS)
        {
            covCards--;
        }
        for (j = 0; j <= covCards; j++)
        {
            temp.Push(deck.Pop(1));
        }
        pStack[i]->SetFaceDirection(CS_FACE_DOWNUP, covCards);
        pStack[i]->SetCardStack(temp);
    }
    /* Deal five fake cards to the deck */
    pDeck->SetCardStack(fakeDeck.Pop(5));  

    SpiderWnd.Redraw();
    fGameStarted = false;
}