void CollectionModel::initCards() { QSqlQuery query = DBManager::instance()->prepare( "SELECT octgnId, count FROM collection;", DBManager::userDB); DBManager::instance()->execute(query); QStringList ids; while (query.next()) { QString id = query.value(0).toString(); _count.insert(id, query.value(1).toInt()); ids.append(id); } insertCards(0, loadCards(ids)); }
void DeckCardModel::initCards() { QSqlQuery query = DBManager::instance()->prepare( "SELECT octgnId, count FROM deckCards WHERE deckId = ?;", DBManager::userDB); query.bindValue(0, _deckId); DBManager::instance()->execute(query); QStringList ids; while (query.next()) { QString id = query.value(0).toString(); _count.insert(id, query.value(1).toInt()); ids.append(id); } insertCards(0, loadCards(ids)); }
int main() { printf("\n***Begin Testing fullDeckCount***\n"); //initializing game int numPlayers = 2; int seed = 555; struct gameState Gstate, testGState; int k[10] = {adventurer, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy, council_room}; initializeGame(numPlayers, k, seed, &Gstate); //precondition, current player, card test value and game state are passed to the function // postcondition, the function returns a value equal to the total cards held by player in deck, hand and discard //copying gameState int startingCards = 0; int cardsAdded = 0; int targetAdded = 0; int targetCard; memcpy(&testGState, &Gstate, sizeof(struct gameState)); targetCard = minion; cardsAdded = 0; targetAdded = 0; targetAdded = loadCards(targetCard, 5, 0, &testGState); cardsAdded += targetAdded; runTest(whoseTurn(&testGState), targetCard, &testGState, (startingCards + cardsAdded)); memcpy(&testGState, &Gstate, sizeof(struct gameState)); targetCard = sea_hag; cardsAdded = 0; targetAdded = 0; targetAdded = loadCards(targetCard, 1, 1, &testGState); cardsAdded += targetAdded; runTest(whoseTurn(&testGState), targetCard, &testGState, (startingCards + cardsAdded)); memcpy(&testGState, &Gstate, sizeof(struct gameState)); targetCard = smithy; cardsAdded = 0; targetAdded = 0; targetAdded = loadCards(targetCard, 10, 2, &testGState); cardsAdded += targetAdded; loadCards(tribute, 55, 2, &testGState); runTest(whoseTurn(&testGState), targetCard, &testGState, (startingCards + cardsAdded)); memcpy(&testGState, &Gstate, sizeof(struct gameState)); targetCard = village; cardsAdded = 0; targetAdded = 0; targetAdded = loadCards(targetCard, 0, 2, &testGState); cardsAdded += targetAdded; loadCards(embargo, 7, 3, &testGState); runTest(whoseTurn(&testGState), targetCard, &testGState, (startingCards + cardsAdded)); return 0; }