/* Cards dropped to a stack */ bool CARDLIBPROC StackDropProc(CardRegion &stackobj, CardStack &dragcards) { Card dragcard = dragcards[dragcards.NumCards() - 1]; int faceup, facedown; /* Only drop our cards on other stacks */ if (stackobj.Id() == from->Id()) { return false; } /* If stack is empty, everything can be dropped */ if (stackobj.NumCards() != 0) { const CardStack &mystack = stackobj.GetCardStack(); /* Can only drop if card is 1 less */ if (mystack[0].LoVal() != dragcard.LoVal() + 1) { return false; } /* Check if stack complete */ stackobj.GetFaceDirection(&facedown); faceup = stackobj.NumCards() - facedown; if (faceup + dragcards.NumCards() >= NUM_ONECOLOR_CARDS) { int i, max = NUM_ONECOLOR_CARDS - dragcards.NumCards() - 1; /* Dragged cards have been checked to be in order, check stack cards */ if (mystack[0].Suit() == dragcard.Suit() && stackLookingGood(mystack, max)) { CardStack s = stackobj.GetCardStack(); CardStack f; /* Remove from card stack */ for (i = 0; i < max + 1; i++) { s.RemoveCard(0); } /* Remove dragged cards */ dragcards = f; stackobj.SetCardStack(s); cardsFinished += NUM_ONECOLOR_CARDS; /* Flip top card of the dest stack */ TurnStackCard(stackobj); } } } /* Flip the top card of the source stack */ TurnStackCard(*from); fGameStarted = true; return true; }
// // 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"); }
// // Can only drop a card onto suit stack if it is same suit, and 1 higher // bool CARDLIBPROC SuitStackDropProc(CardRegion &stackobj, CardStack &dragcards) { TRACE("ENTER SuitStackDropProc()\n"); //only drop 1 card at a time if(dragcards.NumCards() != 1) { TRACE("EXIT SuitStackDropProc()\n"); return false; } bool b = CanDrop(stackobj, dragcards[0]); TRACE("EXIT SuitStackDropProc()\n"); return b; }
/* 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(); }
// // Row a row-stack, we can only drop cards // that are lower / different colour // bool CARDLIBPROC RowStackDropProc(CardRegion &stackobj, CardStack &dragcards) { TRACE("ENTER RowStackDropProc()\n"); Card dragcard = dragcards[dragcards.NumCards() - 1]; //if we are empty, can only drop a stack with a King at bottom if(stackobj.NumCards() == 0) { if(dragcard.LoVal() != 13) { TRACE("EXIT RowStackDropProc(false)\n"); return false; } } else { const CardStack &mystack = stackobj.GetCardStack(); //can only drop if card is 1 less if(mystack[0].LoVal() != dragcard.LoVal() + 1) { TRACE("EXIT RowStackDropProc(false)\n"); return false; } //can only drop if card is different colour if( (mystack[0].IsBlack() && !dragcard.IsRed()) || (!mystack[0].IsBlack() && dragcard.IsRed()) ) { TRACE("EXIT RowStackDropProc(false)\n"); return false; } } fGameStarted = true; TRACE("EXIT RowStackDropProc(true)\n"); return true; }