Example #1
0
/* Adrian Hernandez */
void displayPokerHand(Hand hand){
    
    char *handName = hand.handName;
    char *handRank = handRankName(hand.rank);
    
    int handNameLength = strlen(handName);
    int handRankLength = strlen(handRank);
    
    printf("\n");
    printSpaces(DEFAULT_ALIGN + MAX_CARD_NAME - handNameLength);
    printf("%s\n", handName);
    
    printSpaces(DEFAULT_ALIGN + MAX_CARD_NAME - handRankLength);
    printf("%s\n\n", handRank);
    
    int i;
    for (i = 0; i < POKER_HAND ; i++) {
        
        /* alignment */
        printSpaces(DEFAULT_ALIGN);
        
        displayCard(*(hand.cards[i]));
        printf("\n");
    }
    printf("\n");
}
Example #2
0
int main()
{
    Cards cards;
    cards.printCards();
    std::cout << std::endl;
    cards.sort();
    cards.printCards();
    std::cout << std::endl;

    displayCard(cards.getCard(1, 4));
    std::cout << std::endl;
    displayCard(cards.getCard(1, 4));
    std::cout << std::endl;
    cards.printCards();
    std::cout << std::endl;
    return 0;
}
Example #3
0
int playConcentrationTurn(Card board [], int & currentPlayer)
{
    int num1 = 0, num2 = 0;
    
    cout << endl << endl << endl;
    drawBoardNum(num1, num1, board);
    cout << endl << endl << endl;
    
    cout << "------------- Player " << currentPlayer << " -------------" << endl << endl;
    cout << "Please enter a space to view card: ";
    cin >> num1;
    cout << "Please enter another space: ";
    cin >> num2;
    
    clearScreen();
    
    Card card1 = board[num1], card2 = board[num2];
    
    if(ifCardsMatch(card1, card2)){
        drawBoardNum(num1, num2, board);
        cout << "Good job! The ";
        displayCard(card1);
        cout << " matches the ";
        displayCard(card2);
        cout << "! Go again!" << endl;
        if(currentPlayer == 1) currentPlayer = 1;
        else currentPlayer = 2;
        
        board[num1 - 1].inDeck = false;
        board[num2 - 1].inDeck = false;
        cout << endl << endl;
        pressEnter();
    }
    else{
        drawBoardNum(num1, num2, board);
        cout << "Too bad! The ";
        displayCard(card1);
        cout << " does not match the ";
        displayCard(card2);
        if(currentPlayer == 1) currentPlayer = 2;
        else currentPlayer = 1;
        usleep(3000000);
    }
    return 0;
}
Example #4
0
void Deck::displayDeck()
{
	for(int i = 0; i < 52; i++)
	{
		Card j = deck[i];
		displayCard(j);
	}
	cout << endl;
}
Example #5
0
/* display hands. */
void displayHands(Hand hands[], Hand sortedHands[], int handSize, int nhands){

    
    int i, j;     /* loop variables */

    for (i = 0; i < nhands; i++) {
        
        Hand sorted = sortedHands[i];
        char *unsortedHandName = hands[i].handName;
        char *sortedHandName   = sorted.handName;
        
        /* align and print hands names */
        int handNameLen      = strlen(unsortedHandName);
        int sortedHandNamLen = strlen(sortedHandName);
        
        /* alignment */
        printSpaces(MAX_CARD_NAME + DEFAULT_ALIGN - handNameLen);
        printf("%s", unsortedHandName);
        
        /* alignment */
        printSpaces(MAX_CARD_NAME + DEFAULT_ALIGN - (sortedHandNamLen + 7));
        printf("%s sorted\n\n", sortedHandName);
        
        for (j = 0; j < handSize; j++) {
            
            /* alignment */
            printSpaces(DEFAULT_ALIGN);
            
            /* print original */
            displayCard(*(hands[i].cards[j]));
            
            /* alignment */
            printSpaces(DEFAULT_ALIGN);
            
            /* print sorted */
            displayCard(*(sorted.cards[j]));
            
            printf("\n");
            
        }
        printf("\n\n");
    }
}
Example #6
0
void displayHand(Player plyr)
{
   // cout << "-- " << plyr.name << "'s Hand --" << endl;
    
    for(int i = 0; i < plyr.handSize; i++)
    {        
        cout << "Card " << i+1 << ": ";
        displayCard(plyr.hand[i]);
        cout << endl;
    }
}
Example #7
0
/* Displays a deck of cards. */
void displayDeck(Card deck[], int size){
    
    int i;
    for (i = 0; i < size; i++) {
        
        /* alignment */
        printSpaces(DEFAULT_ALIGN);
        displayCard(deck[i]);
        
        if((i % DECK_COLUMNS) == (DECK_COLUMNS - 1)){
            /* start new row */
            printf("\n");
        }
    }
}
Example #8
0
void displayDeck(Card deck [])
{
    int j = 1;
    
    for(int i = 0; i < DECK_SIZE; i++)
    {
        if(deck[i].inDeck == true)
        {
            cout << "Card " << j << ": ";
            displayCard(deck[i]);
            cout << endl;
            j++;
        }
        else {}
    }
}
Example #9
0
void drawBoardNum(int num1, int num2, Card board [])
{
    int i = 0, cardLength = 0, count = 1, spaceMax = 20, cardFLAG = 0;
    Card tempCard = {SPADES, 1, false};
    
    for(; i < CONCEN_DECK_SIZE; i += 6)
    {
        for(int j = 0; j < CONCEN_ROW_SIZE; j ++)
        {
            if(count == num1 || count == num2){
                tempCard = board[count];
                cardLength = getCardLength(tempCard);
                cout << "        ";
                cardFLAG = 1;
            }
            
            while(cardLength < spaceMax)
            {
                cout << " ";
                cardLength ++;
            }
            
            if(board[count - 1].inDeck == false)
                cout << "  ";
            
            else if(count == num1 || count == num2){
                displayCard(tempCard);

            }
            else{
                if(count < 10) cout << "0";
                cout << count;
            }
            
            count ++;
            
            if(count == num1 || count == num2) cardLength = getCardLength(tempCard);
            else cardLength = 0;
        }
        cout << endl << endl << endl << endl << endl;
    }
}
Example #10
0
void drawBoard(Card board [])
{
    int i = 0, cardLength = 0;
    Card tempCard;
    
    for(; i < CONCEN_DECK_SIZE; i += 6)
    {
        for(int j = 0; j < CONCEN_ROW_SIZE; j ++)
        {
            tempCard = board[i + j];
            cardLength = getCardLength(tempCard);
            
            while(cardLength < 20)
            {
                cout << " ";
                cardLength ++;
            }
            
            displayCard(tempCard);
            cout << "   ";
        }
        cout << endl << endl << endl << endl << endl;
    }
}
void TerminalAbstractState::displayCardWithIndex(CardId id, std::size_t index)
{
	displayCard(id, true, index);
}