Ejemplo n.º 1
0
/*
	Funciton Name:	perform_all_checks
	Parameters: 	A gameState structure and a number of players.
	Returns:		An integer representing whether the test was successful.
	Description:    This function performs all the checks defined in functions above.
*/
void perform_all_checks(struct gameState game_state, int number_of_players) {
	printf("Checking intializeGame for game with %d players.\n", number_of_players);
	
	assert(check_curse_cards(game_state) == 1);
	printf("\tCurse cards check passed.\n");

	assert(check_embargo_tokens(game_state) == 1);
	printf("\tEmbargo tokens check passed.\n");

	assert(check_first_turn_setup(game_state) == 1);
	printf("\tFirst turn setup passed.\n");

	assert(check_kingdom_cards(game_state) == 1);
	printf("\tKingdom cards check passed.\n");

	assert(check_number_of_players(game_state, number_of_players) == 1);
	printf("\tNumber of players check passed.\n");

	assert(check_other_players_setup(game_state) == 1);
	printf("\tOther players setup check passed.\n");

	assert(check_player_one_setup(game_state) == 1);
	printf("\tPlayer one setup check passed.\n");

	assert(check_treasure_cards(game_state) == 1);
	printf("\tTreasure cards setup check passed.\n");

	assert(check_victory_cards(game_state) == 1);
	printf("\tVictory cards setup check passed.\n");
}
int check_state(int numPlayers, int myKingdomCards[10], struct gameState myState)
{
    int num_errors = 0;
    if(myState.numPlayers != numPlayers)
    {
        printf("FAILURE: had %d numPlayers instead of %d.\n", myState.numPlayers, numPlayers);
        num_errors++;
    }

    num_errors += check_supply_count(numPlayers, myKingdomCards, myState);
    num_errors += check_embargo_tokens(myState.embargoTokens);

    if(myState.outpostPlayed != 0)
    {
        printf("FAILURE: outpostPlayed is %d instead of 0.\n", myState.outpostPlayed);
        num_errors++;
    }

    if(myState.outpostTurn != 0)
    {
        printf("FAILURE: outpostTurn is %d instead of 0.\n", myState.outpostTurn);
        num_errors++;
    }

    if(myState.whoseTurn != 0)
    {
        printf("FAILURE: whoseTurn is %d instead of 0.\n", myState.outpostTurn);
        num_errors++;
    }

    if(myState.phase != 0)
    {
        printf("FAILURE: phase is %d instead of 0.\n", myState.outpostTurn);
        num_errors++;
    }

    if(myState.numActions != 1)
    {
        printf("FAILURE: had %d numActions instead of %d.\n", myState.numActions, 1);
        num_errors++;
    }

    if(myState.numBuys != 1)
    {
        printf("FAILURE: had %d numBuys instead of %d.\n", myState.numBuys, 1);
        num_errors++;
    }

    num_errors += check_hand_deck(myState);

    for(int i = 0; i < numPlayers; i++)
    {
        if( myState.discardCount[i] != 0)
        {
            printf("FAILURE: player %d discardCount was %d instead of 0.\n", i, myState.discardCount[i]);
            num_errors++;
        }
    }

    if(myState.playedCardCount != 0)
    {
        printf("FAILURE: had %d numBuys instead of %d.\n", myState.numBuys, 0);
        num_errors++;
    }
    return num_errors;
}