Ejemplo n.º 1
0
//used to generate 5 cards hand
//to players
void setPlayersHands() {
    int l = 0;
    for(l = 0; l < 5; l++) {
        p1Cards[l] = pickCard();
        p2Cards[l] = pickCard();
    }
}
Ejemplo n.º 2
0
int testUpdateCoins(){
	int i = 0;
	int player = 0;
	int handCount = 0;
	int bonus = 0;


	// Create New Game
	struct gameState currentGame;

	// Game Settings 
	int numPlayers = 2;
	int maxCardPerHand = 5; // This is a normal handsize however I would make it more random
	int maxBonusPerHand = 10; // This is what a normal Bonus might be seen per hand
	int randomSeed = 44; // This Value doesnt really matter but could be useful
	int zeros[MAX_HAND];

	// Kingdom Cards
	int kingdomCards[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
           sea_hag, tribute, smithy};

    // Setup Random Number Generator
    SelectStream(2);
  	PutSeed(3);

  	for (i = 0; i < MAX_HAND; i++)
    {
        zeros[i] = 0;
    }

	// Begin Testing Update Coins Method

	if (DEBUG_TEST) printf("Testing updateCoins() Method\n");

	if (DEBUG_TEST) printf("Random Testing for Update Coin\n");
	for (player = 0; player < numPlayers; player++){
		for(handCount = 1; handCount <= maxCardPerHand; handCount++){
			for(bonus = 0; bonus <= maxBonusPerHand; bonus++){
				if(DEBUG_TEST) printf("Player %d, Cards in Hard %d, bonus %d\n",
						player, handCount, bonus); // Test Output
				//memset(&G, 23, sizeof(struct gameState)); // Clears Game State
				/* Setup New Game */
				initializeGame(numPlayers, kingdomCards, randomSeed, &currentGame);
				currentGame.handCount[player] = handCount;
				memcpy(currentGame.hand[player], zeros, sizeof(int) * handCount);

				if (DEBUG_TEST) printf("Coins %d\n", currentGame.coins);

				pickCard(1, handCount, &currentGame, bonus, player, 0);				
			}
		}
	}
	printf("\n Completed with NO Failures\n");
	return 0;
}
Ejemplo n.º 3
0
int pickCard(int currentCard, int handsize, struct gameState* currentGame, 
			int bonus, int player, int wallet){
	int localWallet = 0;
	int calc = 1;
	if(currentCard > handsize){
		return 0;
	}

	// Make Card Copper
	currentGame->hand[player][currentCard - 1] = copper;
	if(DEBUG_TEST)printf("Card %d, is COPPER\n", currentCard);
	localWallet = wallet + VAL_COPPER;
	calc = pickCard(currentCard+1, handsize, currentGame, bonus, player, localWallet);
	if (calc == 0){
		updateCoins(player,currentGame, bonus);
		if (DEBUG_TEST) printf("Game.Coins = %d, Expexted = %d\n", currentGame->coins, wallet + VAL_COPPER + bonus);
		assert(currentGame->coins == wallet + VAL_COPPER + bonus);
	}

	if(DEBUG_TEST)printf("Card %d, is SILVER\n", currentCard);
	currentGame->hand[player][currentCard - 1] = silver;
	localWallet = wallet + VAL_SILVER;
	calc = pickCard(currentCard+1, handsize, currentGame, bonus, player, localWallet);
	if (calc == 0){
		updateCoins(player,currentGame, bonus);
		if (DEBUG_TEST) printf("Game.Coins = %d, Expexted = %d\n", currentGame->coins, wallet + VAL_SILVER + bonus);
		assert(currentGame->coins == wallet + VAL_SILVER + bonus);
	}

	if(DEBUG_TEST) printf("Card %d, is GOLD\n", currentCard);
	currentGame->hand[player][currentCard - 1] = gold;
	localWallet = wallet + VAL_GOLD;
	calc = pickCard(currentCard+1, handsize, currentGame, bonus, player, localWallet);
	if (calc == 0){
		updateCoins(player,currentGame, bonus);
		if (DEBUG_TEST) printf("Game.Coins = %d, Expexted = %d\n", currentGame->coins, wallet + VAL_GOLD + bonus);
		assert(currentGame->coins == wallet + VAL_GOLD + bonus);
	}

	return 1;
	
}
Ejemplo n.º 4
0
//generates new middle cards
void generateMiddleCards() {
    generateCardPile();
    for(w = 0; w < 5; w++) {
        middle[w] = pickCard();
    }
}