Esempio n. 1
0
/// \brief
/// Adds a card node to the correct suit list depening on card pointer given as input parameter
/// (eg. clubs card adds a node to the clubs list).
///
/// \param cardToAdd Card* - used to determine which suit list the card node should be added to.
void Hand::addCard(Card* cardToAdd) {

    // Create node with card pointer as its data variable
    node = new cardNode;
    node->data = cardToAdd;

    cardNode* header;

    switch(cardToAdd->getSuit()) {
        case CLUBS:
            insertCard(c_header, node);
            header = c_header;
            break;
        case SPADES:
            insertCard(s_header, node);
            header = s_header;
            break;
        case HEARTS:
            insertCard(h_header, node);
            header = h_header;
            break;
        case DIAMONDS:
            insertCard(d_header, node);
            header = d_header;
            break;
    }

    // Calculating high card points and length points
    checkForHighCard(cardToAdd);
    if (suitSize(header) > 4) {
        handStrength++;
    }
}
Esempio n. 2
0
int main(void)
{
	char buf[5];
	int i;
	Card card[5];

	initSign();
	while(scanf("%s", buf) != EOF){
		ans = 0;
		printf("Hand: %s ", buf);
		insertCard(sign[buf[1]], sign[buf[0]], &hand[0]);
		for(i=1; i<5; i++){
			scanf("%s", buf);
			printf("%s ", buf);
			insertCard(sign[buf[1]], sign[buf[0]], &hand[i]);
		}
		printf("Deck: ");
		for(i=0; i<5; i++){
			scanf("%s", buf);
			printf("%s ", buf);
			insertCard(sign[buf[1]], sign[buf[0]], &deck[i]);
		}
		choose(0, card, 0);
		printf("Best hand: %s\n", name[ans]);
	}
	return 0;
}
Esempio n. 3
0
int main()
{
	int i;
	int seed = 1000;
	int numPlayers = 2;
	int player  = 0;
	int *deckZero,*deckOne;
	struct gameState preTest, postTest;
	int k[10] = {adventurer, council_room, feast, gardens, mine ,remodel, smithy, village, baron, great_hall};
	/* Test Specification Variables */
	int drawCountTestZero = 3;
	int drawCountTestOne = 0;

	initializeGame(numPlayers,k,seed,&postTest);
	printf("\n\nBeginning Test for Village...\n\n");
	memcpy(&preTest,&postTest,sizeof(struct gameState));
	insertCard(&postTest,player);
	playCard((postTest.handCount[player]-1),0,0,0,&postTest);
	testDraw(&preTest,&postTest,player);
	testHand(&preTest,&postTest,player);
	testDiscard(&preTest,&postTest,player);
	testSupply(&preTest,&postTest);
	testPlayed(&preTest,&postTest);
	testUtility(&preTest,&postTest);
	printf("\n\tTesting finished\n\n");
}
void PeopleGroupedView::rowsInserted(const QModelIndex& parent, int start, int end)
{
    Q_UNUSED(parent);
    qDebug() << "[PeopleGroupedView] Rows Inserted" << start << end;
    for (int i=start; i<=end; i++){
        insertCard(m_itemModel->index(i, 0, parent));      
    }
}
void PeopleGroupedView::dataChanged(const QModelIndex& topLeft,
                                    const QModelIndex& bottomRight)
{
    qDebug() << "[PeopleGroupedView] Data Changed" << topLeft.row() << bottomRight.row();

    int start = topLeft.row();
    int end = bottomRight.row();

    for (int i=start; i<=end; i++) {
        removeCard(i);
        insertCard(m_itemModel->index(i, 0));
    }
}
void PeopleGroupedView::setupModel()
{
    MWidgetView::setupModel();

    if (m_mainLayout){
        qDebug() << "MODEL CLEARED";
        clearLayout(m_mainLayout);
    }
    m_itemModel = m_controller->itemModel();

    m_mainLayout = new QGraphicsGridLayout(m_controller);
    m_mainLayout->setContentsMargins(0, 0, 0, 0);
    m_mainLayout->setSpacing(0);

    connect(m_itemModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
            this, SLOT(rowsInserted(QModelIndex,int,int)), Qt::UniqueConnection);
    connect(m_itemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
            this, SLOT(rowsRemoved(QModelIndex,int,int)), Qt::UniqueConnection);
    connect(m_itemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
            this, SLOT(dataChanged(QModelIndex,QModelIndex)), Qt::UniqueConnection);
    connect(m_itemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
            this, SLOT(rowsMoved(QModelIndex,int,int,QModelIndex,int)), Qt::UniqueConnection);
    connect(m_itemModel, SIGNAL(layoutChanged()),
            this, SLOT(layoutChanged()), Qt::UniqueConnection);
    connect(m_itemModel, SIGNAL(modelReset()),
            this, SLOT(modelReset()), Qt::UniqueConnection);

    QString alphabet(QObject::tr("a b c d e f g h i j k l m n o p q r s t u v w x y z", "Alphabet for contact index"));
    m_headings = alphabet.split(" ", QString::SkipEmptyParts);

    QString capitals(QObject::tr("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z","Alphabet for contact index"));
    m_displayHeadings = capitals.split(" ", QString::SkipEmptyParts);

    m_numSections = m_headings.count();
    qDebug() << "m_numSections : " << m_numSections;

    // initialize vector elements to zero
    m_sectionCounts.clear();
    m_sectionCounts.resize(m_numSections + 2);

    int rows = m_itemModel->rowCount();
    for (int i=0; i<rows; ++i){
        qDebug() << "PeopleGroupedView::setupModel() insertCard at" << i;
        insertCard(m_itemModel->index(i, 0));
    }
}