示例#1
0
CardStack CreatePlayDeck()
{
    CardStack newStack;
    int i, colors = 1, num = 0;
    
    switch (dwDifficulty)
    {
        case IDC_DIF_ONECOLOR:
            colors = 1;
            break;
        case IDC_DIF_TWOCOLORS:
            colors = 2;
            break;
        case IDC_DIF_FOURCOLORS:
            colors = 4;
            break;
    }
    for (i = 0; i < NUM_SPIDER_CARDS; i++)
    {
        num += NUM_CARD_COLORS / colors;
        Card newCard(num % NUM_STD_CARDS);
        newStack.Push(newCard);
    }
    return newStack;
}
示例#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");
}
示例#3
0
void BuildDeck(CardStack& cards)
{
	for (int index = 0; index < NUM_CARDS; index++)
	{
		//Num [2,14].
		cards.Push( rand() % 13 + 2);
	}
}
示例#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");
}
示例#5
0
bool CardRegion::OnLButtonUp(int x, int y)
{
    CardRegion *pDestStack = 0;
    HDC hdc;
    int dropstackid = CS_DROPZONE_NODROP;

    RECT dragrect;
    DropZone *dropzone;

    fMouseDragging = false;

    //first of all, see if any drop zones have been registered
    SetRect(&dragrect, x-mousexoffset, y-mouseyoffset, x-mousexoffset+nDragCardWidth, y-mouseyoffset+nDragCardHeight);

    dropzone = parentWnd.GetDropZoneFromRect(&dragrect);

    if(dropzone)
    {
        dropstackid = dropzone->DropCards(dragstack);

        if(dropstackid != CS_DROPZONE_NODROP)
            pDestStack = parentWnd.CardRegionFromId(dropstackid);
        else
            pDestStack = 0;
    }
    else
    {
        pDestStack = parentWnd.GetBestStack(x - mousexoffset, y - mouseyoffset, nDragCardWidth, nDragCardHeight);
    }

    // If have found a stack to drop onto
    //
    TRACE ( "can I drop card?\n" );
    if(pDestStack && pDestStack->CanDropCards(dragstack))
    {
        TRACE ( "yes, dropping card\n" );
        hdc = GetDC((HWND)parentWnd);
        //            UseNicePalette(hdc);
        ZoomCard(hdc, x - mousexoffset, y  - mouseyoffset, pDestStack);
        ReleaseDC((HWND)parentWnd, hdc);

        //
        //add the cards to the destination stack
        //
        CardStack temp = pDestStack->GetCardStack();
        temp.Push(dragstack);

        pDestStack->SetCardStack(temp);
//        pDestStack->Update();        //Update this stack's card count + size
//        pDestStack->UpdateFaceDir(temp);

        //    Call the remove callback on THIS stack, if one is specified
        //
        if(RemoveCallback)
            RemoveCallback(*this, iNumDragCards);

        //    Call the add callback, if one is specified
        //
        if(pDestStack->AddCallback)
            pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);//index, deststack->numcards);

        RedrawIfNotDim(pDestStack, true);
        TRACE ( "done dropping card\n" );
    }

    //
    //    Otherwise, let the cards snap back onto this stack
    //
    else
    {
        TRACE ( "no, putting card back\n" );
        hdc = GetDC((HWND)parentWnd);
        TRACE ( "calling ZoomCard()\n" );
        ZoomCard(hdc, x - mousexoffset, y - mouseyoffset, this);
        TRACE ( "cardstack += dragstack\n" );
        cardstack += dragstack;
        TRACE ( "calling ReleaseDC()\n" );
        ReleaseDC((HWND)parentWnd, hdc);

        TRACE ( "calling Update()\n" );
        Update();        //Update this stack's card count + size
        TRACE ( "done putting card back\n" );
    }

    ReleaseDragBitmaps();
    ReleaseCapture();

    TRACE ( "OnLButtonUp() done\n" );
    return true;
}