Exemplo n.º 1
0
int main() {
        int n, i, p;
        struct gameState Game;

        printf ("--------------------------------\n");
        printf ("Testing cardEffect() with Smithy card\n");
        printf ("UNIT TESTS\n");

        SelectStream(3);
        PutSeed(3);

        for (n = 0; n < 2000; n++) {
                SelectStream(3);
                for (i = 0; i < sizeof(struct gameState); i++) {
                        ((char*)&Game)[i] = floor(Random() * 256);
                }

                p = floor(Random() * MAX_PLAYERS);
                Game.whoseTurn = p;
                Game.deckCount[p] = floor(Random() * MAX_DECK);
                Game.discardCount[p] = floor(Random() * MAX_DECK);
                Game.handCount[p] = floor(Random() * MAX_HAND);
                Game.playedCardCount = floor(Random() * MAX_DECK);

                testSmithy(p, &Game);
        }

        printf("ALL TESTS OK\n\n");
        return 0;
}
Exemplo n.º 2
0
int main (int argc, char** argv) {
    struct gameState G;
    int cardsInPlay[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
	   sea_hag, baron, smithy};
   
    setupTest(&G, 5, cardsInPlay); //game state and handcount
    testSmithy(&G, cardsInPlay);
    
    return 0;
}
Exemplo n.º 3
0
int main()
{
	int p = 0;
	struct gameState G;
	int handPos;
	int i, j, k, m, n, q;
	
	for (i = 0; i < sizeof(struct gameState); i++) { //from the lessons, random gameState
		((char*)&G)[i] = floor(Random() * 256);
	}
	
	SelectStream(2);
	PutSeed(3);
	printf("Testing playCardSmithy() cardtest1.\n");
	
	G.whoseTurn = p;
	for(k = 0; k < 500; k++)
	{
		//fill in random cards
		G.handCount[p] = floor(Random() * MAX_HAND)+1;//need at least one smithy in our hand
		G.deckCount[p] = floor(Random() * MAX_DECK);
		G.discardCount[p] = floor(Random() * MAX_DECK);
		G.playedCardCount = floor(Random() * MAX_DECK);
		//printf("handCount: %d, deckCount: %d, discardCount: %d.\n", G.handCount[p], G.deckCount[p], G.discardCount[p]);
		
		for(m = 0; m < G.handCount[p]; m++)
		{
			G.hand[p][m] = floor(Random() * treasure_map) + 1;
		}
		
		for(j = 0; j < G.discardCount[p]; j++)
		{
			G.discard[p][j] = floor(Random() * treasure_map) + 1;
		}

		for(n = 0; n < G.deckCount[p]; n++)
		{
			G.deck[p][n] = floor(Random() * treasure_map) + 1;
		}
		for(q = 0; q < G.playedCardCount; q++)
		{
			G.playedCards[q] = floor(Random() * treasure_map) + 1;
		}
		
		//place smithy in a random pos
		handPos = floor(Random() * G.handCount[p]);
		G.hand[p][handPos] = smithy;
		
		testSmithy(&G, handPos);
	}
	
	printf("playCardSmithy TESTS FINISHED.\n\n");
	return 0;
}
Exemplo n.º 4
0
int main()
{
    //s1 will hold state after initialization, s2 will be state after draw card
    struct gameState *gs1 = malloc(sizeof(struct gameState));
    struct gameState *gs2 = malloc(sizeof(struct gameState));
    //Cards used in test instance of game
    int gameCards[10] = {smithy, adventurer, council_room, feast, gardens, mine, remodel,
        village, baron, great_hall};
    int numPlayers;
    int seed = 55;
    int p;
    int passed = 0;
    
    //Run tests for all game sizes and for each player in game
    printf("Testing for playSmithy beginning.\n");
    for (numPlayers = 2; numPlayers <= 4; numPlayers++)
    {
        printf("Testing a %d player game.\n", numPlayers);
        
        //Initialize game and test for success
        if (initializeGame(numPlayers, gameCards, seed, gs1) == -1)
        {
            printf("Game state failed to initialize. No testing completed.\n");
            return -1;
        }
        
        //Test for each player
        for (p = 0; p < numPlayers; p++)
        {
            printf("Testing for player %d playing smithy card.\n", p + 1);
            //A random card will be assigned to smith
            int card = rand() % 5;
            gs1->hand[p][card] = smithy;
            
            //Save state of game for comparison before and after playSmithy()
            memcpy(gs2, gs1, sizeof(struct gameState));
            playSmithy(p, card, gs1);
            //Test changes that occurred during playSmith()
            if (!testSmithy(gs2, gs1, p))
                passed = -1;
                
        }
    }
    if (passed != -1)
        printf("PASS all tests for playSmithy().\n");
    
    
    return 0;
}
Exemplo n.º 5
0
int main (){
	
	printf("Test 1:\n");
	int hand1[5] = {smithy,mine,village,tribute,gold};
	testSmithy(hand1, 0, 5, 0);
	
	printf("Test 2:\n");
	int hand2[5] = {mine,smithy,village,tribute,gold};
	testSmithy(hand2, 0, 5, 1);	

	printf("Test 3:\n");
	int hand3[5] = {mine,village,smithy,tribute,gold};
	testSmithy(hand3, 0, 5, 2);

	printf("Test 4:\n");
	int hand4[5] = {mine,village,tribute,smithy,gold};
	testSmithy(hand4, 0, 5, 3);

	printf("Test 5:\n");
	int hand5[5] = {mine,village,tribute,gold,smithy};
	testSmithy(hand5, 0, 5, 4);

	return 0;
}
Exemplo n.º 6
0
int main()
{
    testSmithy();
    return 0;
}
Exemplo n.º 7
0
int main()
{
	//set up variables used for testing
	int numPlayers,
		player,
		handPos,
		i;
	struct gameState pre, post;
	int numTests = 1000;
	int k[10] = {adventurer, council_room, feast, gardens, mine
		, remodel, smithy, village, baron, great_hall};
		
	int seed;
	
	//loop for amount of tests
	for(i = 0; i < numTests; i++)
	{
		printf("****TEST %i****\n", i+1);
		//randomize each of our test variables
		numPlayers = floor(Random() * (MAX_PLAYERS-2)) + 2; //at least 2 players
		player = floor(Random() * numPlayers);
		printf("Player playing adventurer: #%i\n", player);
		//initialize game
		memset(&post, 23, sizeof(struct gameState)); 
		seed = floor(Random() * MAX_DECK);
		int init = initializeGame(numPlayers, k, seed, &post);
		if(init != 0)
		{
			printf("Error initializing game.\n");
			return -1;
		}
		//random player test
		post.whoseTurn = player;
		
		//fill out player decks
		fillDecks(&post);
		
		//fill out player hands
		fillHands(&post);
		
		//sneak an smithy into a random handPos so we can play it
		handPos = floor(Random() * post.handCount[player]);
		post.hand[player][handPos] = smithy;
		
		//copy game
		// memset(&pre, 23, sizeof(struct gameState)); 
		memcpy(&pre, &post, sizeof(struct gameState));
		// printf("The hand count for player %i is %i\n", player, post.handCount[player]);
		// printf("The deck count for player %i is %i\n", player, post.deckCount[player]);
		
		//play smithy
		int playcardState = playCard(handPos, 0,0,0, &post);
		if(playcardState != 0)
		{
			printf("There was an error playing the card\n");
		}
		
		//imitate playing smithy
		testSmithy(&pre, handPos);
		
		//compare the game states
		compareStates(&pre, &post);
		
		printf("****FINISHED TEST %i****\n\n", i);
	}
	
	return 0;
}
Exemplo n.º 8
0
int main(int argc, char *argv[]) {
	srand(time(NULL));
	testSmithy();
	return 0;
}