summaryrefslogtreecommitdiffstats
path: root/opponent.cpp
blob: 63dc73a896de8182ac13df6f362ab6b78b852adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * opponent.cpp
 *
 *
 */

#include "opponent.h"

Opponent::Opponent(void)
{
    whatHand[0] = 9;
    whatHand[1] = 9;
    whatHand[2] = 9;
}

void Opponent::dealOpponentCards(void)
{
    /* the cards will be dealt from end of the deck array using deckCurrIndex */
    int i, j;
    for (j = 0; j < numOfOpponents; j++)
        for (i = 0; i < 5; i++)
            opponentCards[j][i] = PopCardFromDeck();
}

void Opponent::printOpponentCards(void)
{
    int j;
    for (j = 0; j < numOfOpponents; j++)
    {
        cout << "Opponent " << j+1 << ": ";

        int i;
        for (i = 0; i < 5; i++)
            if (opponentCards[j][i])
                cout << i+1 << ") " << opponentCards[j][i]->getType() << " ";
        cout << endl;
    }
}

void Opponent::sortOpponentCards(void)
{
    int j;
    for (j = 0; j < numOfOpponents; j++)
        sortCards(opponentCards[j]);
}

Card **Opponent::getOpponentsCards(int whichOpponent)
{
    if (whichOpponent < 1 || whichOpponent > 3)
    {
        PRINT_COLOR(ANSI_COLOR_RED, "\ngetOpponentsCards(): opponent number out of bounds!\n");
        return NULL;
    }

    return opponentCards[whichOpponent-1];
}

void Opponent::setOpponentHand(int hand, int whichOpponent)
{
    whatHand[whichOpponent-1] = hand;
}

int Opponent::getOpponentHand(int whichOpponent)
{
    return whatHand[whichOpponent-1];
}