• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ buyCard函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中buyCard函数的典型用法代码示例。如果您正苦于以下问题:C++ buyCard函数的具体用法?C++ buyCard怎么用?C++ buyCard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了buyCard函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

//Testing initializeGame and default deal
int main() {
	struct gameState g, orig;

	int k[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,
			   outpost,baron,tribute};

	int r = 0;
	//3 player game this time
	initializeGame(3, k, 1, &orig);
	//Trevor's suggestion, saving game state for testing purposes
	memcpy(&g, &orig, sizeof(struct gameState));	
	
	//first hand of player 0 is {4 coppers, 1 estate}. 4 coins
	buyCard(gardens, &g); //player 0 buys a garden
	endTurn(&g);
	buyCard(curse, &g); //player 1 buys a curse
	endTurn(&g);
	//Not doing anything on player 3 turn
	endTurn(&g);
	
	r = scoreFor(3, &g);
	myAssert(r == -9999, "Player should not exist but did", __LINE__);
	r = scoreFor(0, &g);
	myAssert(r == 5, "Player should have a base 5 points", __LINE__);
	
	
	
	

	if(r == 0)
		printf("Tests completed successfully!\n");

	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_fryta,代码行数:35,代码来源:unittest4.c


示例2: main

int main(){

  struct gameState state;
  int s;
  int k[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

  initializeGame(2, k, 2, &state);

  state.numBuys = 0;

  s = buyCard(5, &state);

  assert(s == -1);

  state.numBuys = 5;

  state.coins = 0;

  s = buyCard(5, &state);

  assert(s == -1);

  state.coins = 100;

  s = buyCard(5, &state);

  assert(s == 0);

  printf("buyCard test passed\n");
  return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_jonesmck,代码行数:31,代码来源:unittest4.c


示例3: randBuy

int randBuy(struct gameState *game){
  int card;
  if (game->coins >= getCost(province))
    card = province;
  else
    card = floor(Random()*(treasure_map+1));

  if (game->coins == 0){
    game->numBuys = 0;
    return 0;
  }


  if (getCost(card) > game->coins || game->supplyCount[card] <= 0) {
    if (buyCard(card,game) == 0) {
      printf("Bad attempt to buy card was successfull: ");
      printCard(card);
      printf("\n\r");
      return -1;
    }
    else
      return 0;
  }


  printf("Card to buy: ");
  printCard(card);
  printf("\n\r");
  return buyCard(card,game);
}
开发者ID:lakshmankollipara,项目名称:Dominion-Testing,代码行数:30,代码来源:bot.c


示例4: buyCost5

void buyCost5(struct gameState *p, int * k){
	int i = 0;
	int counter = 0;
	int j = 0;
	for(;i<10;i++){
		if (k[i] == outpost || k[i] == minion || k[i] == duchy)
			counter++;
		else if(k[i] == council_room || k[i] == mine || k[i] == tribute)
			counter++;
	}
	int * costFive = malloc(sizeof(int)*counter);
	for(i =0; i<10;i++){
		if (k[i] == outpost || k[i] == minion || k[i] == duchy)
			costFive[j] = k[i];
		else if(k[i] == council_room || k[i] == mine || k[i] == tribute)
			costFive[j] = k[i];
	}
	if(counter != 0){
		int num = rand() % counter;
		buyCard(costFive[num],p);
		printf("%s bought\n",printCard(costFive[num]));
		}
	else{
		buyCard(silver,p);
		printf("%s bought\n",printCard(silver));
		}
}
开发者ID:cs362sp15,项目名称:projects,代码行数:27,代码来源:testdominion.c


示例5: buyCost4

void buyCost4(struct gameState *p, int * k){
	int i = 0;
	int counter = 0;
	int j = 0;
	for(;i<10;i++){
		if (k[i] == cutpurse || k[i] == baron || k[i] == feast)
			counter++;
		else if(k[i] == gardens || k[i] == remodel || k[i] == smithy)
			counter++;
		else if(k[i] == salvager || k[i] == sea_hag || k[i] == treasure_map)
			counter++;
	}
	int * costFour = malloc(sizeof(int)*counter);
	for(i =0; i<10;i++){
		if (k[i] == cutpurse || k[i] == baron || k[i] == feast){
			costFour[j] = k[i];
			j++;}
		else if(k[i] == gardens || k[i] == remodel || k[i] == smithy){
			costFour[j] = k[i];
			j++;}
		else if(k[i] == salvager || k[i] == sea_hag || k[i] == treasure_map){
			costFour[j] = k[i];
			j++;}
	}
	if(counter != 0){
		int num = rand() % counter;
		buyCard(costFour[num],p);
		printf("%s bought\n",printCard(costFour[num]));
		}
	else{
		buyCard(silver,p);
		printf("%s bought\n",printCard(silver));
		}
}
开发者ID:cs362sp15,项目名称:projects,代码行数:34,代码来源:testdominion.c


示例6: buy_card

void buy_card(struct gameState* p, int not_bought[10], int k[10])
{

    int money = 0, j;
    for(j = 0; j < numHandCards(p); j++)
    {
        if(handCard(j,p) == copper)
        {
            playCard(j, -1, -1, -1, p);
            money++;
        }    
        if(handCard(j,p) == silver)
        {
            playCard(j, -1, -1, -1, p);
            money += 2;
        }
        if(handCard(j,p) == gold)
        {
            playCard(j, -1, -1, -1, p);
            money += 3;
        }
    }
    
    if(money > 7)
    {
        buyCard(province, p);
        printf("%d Bought province\n", p->whoseTurn);
    }
    else if(money > 5)
    {
        for(j = 0; j < 10; j++)
        {
            if(!(bought(not_bought, p, k[j])))
            {
                buyCard(k[j], p);
                printf("%d Bought %s\n", p->whoseTurn, get_name(k[j]));
                j = 10;
            }
        }
    }
    else if(money > 5)
    {
        buyCard(gold, p);
        printf("%d Bought gold\n", p->whoseTurn);
    }
    else if(money > 2)
    {
        buyCard(silver, p);
        printf("%d Bought silver\n", p->whoseTurn);
    }
    else
    {
        buyCard(copper, p);
        printf("%d Bought copper\n", p->whoseTurn);
    }
}
开发者ID:cs362sp16,项目名称:cs362sp16_burnettn,代码行数:56,代码来源:testdominion.c


示例7: main

//testing buyCard()
int main() {
	int seed = 1;//the seed for initializeGame
    int numPlayer;
	int players, handCount, i, j, tempCount;
	int cardCount = 10;//the number of cards initially given to a player
	
    int cards[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState game;

	printf ("Testing buyCard():\n\n");
	
	for(numPlayer = 2; numPlayer <= 4; numPlayer++) {//checking for all possible number of players (2-4) {
		initializeGame(numPlayer, cards, seed, &game); // initialize a new game
		for (players = 0; players < numPlayer; players++)//drawing all cards for each player
		{   
			for (i = 0; i < cardCount; i++){//drawing entire deck
				drawCard(players, &game);//drawing a card	
			}
			
			game.numBuys = 1;
			game.whoseTurn = players;
			updateCoins(players, &game, 0);
			buyCard(smithy, &game);//note:smithy cost 4, less than coppers originally given
			
			if(fullDeckCount(players, smithy, &game) != 1) {//checking that the user can buy an affordable card
				printf("ERROR BUYING AFFORDABLE CARD: player: %i, buy: %i, expected cards after buy: %i, actual cards = %i\n\n", players, 1, 1, fullDeckCount(players, smithy, &game));
				printf("user has in hand %i\n", game.handCount[players]);
			}
			
			game.numBuys = 1;
			game.whoseTurn = players;
			buyCard(smithy, &game);//note:smithy cost 4, more than money left
			
			if(fullDeckCount(players, smithy, &game) != 1) {//checking that the user can't buy an unaffordable card
				printf("ERROR BUYING UNAFFORDABLE CARD: player: %i, buy: %i, expected cards after buy: %i, actual cards = %i\n\n", players, 2, 1, fullDeckCount(players, smithy, &game));
			}
			
			game.numBuys = 1;
			game.whoseTurn = players;
			
			tempCount = game.supplyCount[smithy];
			game.supplyCount[smithy] = 0;//removing smithy cards
			buyCard(smithy, &game);
			if(fullDeckCount(players, smithy, &game) != 1) {//checking that the user can't buy an absent
				printf("ERROR BUYING ABSENT CARD: player: %i, buy: %i, expected cards after buy: %i, actual cards = %i\n\n", players, 3, 1, fullDeckCount(players, smithy, &game));
			}
			
			game.supplyCount[smithy] = tempCount;//returning smithy cards
			
		}
	}
	return 0;
}
开发者ID:csDaniel,项目名称:cs362sp16,代码行数:54,代码来源:unittest4.c


示例8: main

int main() {
	
	int i, test1=0, scoreTrack=10;
	int currentPlayer, money;
	struct gameState G;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int r = initializeGame(2, k, 2, &G);
	assert (r ==0);
	
	///// ----------------------- game -----------------------
	while (!isGameOver(&G)) 
	{
		money=0;
		for (i = 0; i < numHandCards(&G); i++) 
		{
			if (handCard(i, &G) == copper)
				money++;
			else if (handCard(i, &G) == silver)
				money += 2;
			else if (handCard(i, &G) == gold)
				money += 3;
		}	
		
		if ((supplyCount(gold, &G)==0) && (supplyCount(silver, &G)==0))
		{
			if (money >= 8) 
			{
				buyCard(province, &G);
				scoreTrack=scoreTrack+6;
			}
		}
		else if (money >= 6) 
		{
			buyCard(gold, &G);
		}
		else if (money >= 3) 
		{ 
			buyCard(silver, &G);
		}
		endTurn(&G);
	}

	//------------------------------------------------------------------
	//total score
	test1= scoreFor(0, &G) + scoreFor(1, &G);
	//score we tracked
	printf("Score for: %i", scoreFor);
	printf("Score trac: %i", scoreTrack);
	//assert( test1== scoreTrack);
	//scoreFor is acting strange
	
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_kwakp,代码行数:53,代码来源:unittest3.c


示例9: play

void play(struct gameState *p,int pcard, int favCard, int *pnumcard, int who, int money){
	int i = 0;
	char cardname[32];

	
	cardNumToName(favCard, cardname);
	printf("your fav card is %s\n",cardname);
    if (pcard != -1) {
	cardNumToName(favCard, cardname);
    printf("%d: %s played from position %d\n",who, cardname, pcard); 
	playCard(pcard, 1, 1, 1, p); 
	printf("%s played.\n",cardname);
	money = 0;
	i=0;
	while(i<numHandCards(p)){
	  if (handCard(i, p) == copper){
	    playCard(i, -1, -1, -1, p);
	    money++;
	  }
	  else if (handCard(i, p) == silver){
	    playCard(i, -1, -1, -1, p);
	    money += 2;
	  }
	  else if (handCard(i, p) == gold){
	    playCard(i, -1, -1, -1, p);
	    money += 3;
	  }
	  i++;
	}
      }

      if (money >= 8) {
        printf("%d: bought province\n",who); 
        buyCard(province, p);
      }
      else if (money >= 6) {
        printf("%d: bought gold\n",who); 
        buyCard(gold, p);
      }
      else if ((money >= 4) && (*pnumcard < 2)) {
        printf("%d: bought %s\n",who, cardname); 
        buyCard(favCard, p);
        *pnumcard++;
      }
      else if (money >= 3) {
        printf("%d: bought silver\n",who); 
        buyCard(silver, p);
      }

      printf("%d: end turn\n",who);
      endTurn(p);
    }
开发者ID:CS362-Winter-2016,项目名称:cs362w16_chenj2,代码行数:52,代码来源:testdomfunc.c


示例10: testSmithyCard

int testSmithyCard () {
    //
    // Tests that fullDeckCount works properly
    
    //

    // Status of test
    // set to 0 if the test didn't crash,
    // set to -1 if the test fails to finish,
    int status = -1;

    // Create play variable
    int p = 0;

    // RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.
    int rand = 4;

    // Create cards variable 
    int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
	       sea_hag, tribute, smithy};

    // Create gamestate
    struct gameState G;

    status = initializeGame(2, k, rand, &G);

    myAssert (status == 0);

    int choices[3] = {0};
    int pos;
    buyCard(smithy, &G);
    buyCard(smithy, &G);
    int loops = 0, cardFound = 0;
    while(cardFound == 0 && loops < 5) {
        for (pos=0, loops++; pos<numHandCards(&G); pos++)
            if (handCard(pos, &G) == smithy)
                cardFound = 1;
        endTurn(&G);
    }
    status = cardEffect(smithy,
                        choices[0], choices[1], choices[2],
                        &G, pos, NULL);

    myAssert (status == 0);


    printf ("testSmithyCard passes.\n");

    status = 0;
    return status;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_voigte,代码行数:51,代码来源:cardtest3.c


示例11: main

//test baron
int main()
{
	int kCards[10] = {adventurer, gardens, embargo, village, minion, baron, cutpurse, sea_hag, tribute, smithy};
	struct gameState g, orig;
	int r;

	//for consistancy make randomSeed=1
	initializeGame(2, kCards, 1, &orig);

	//turn 1 of player 0 is {4 coppers, 1 estate}. 4 coins
	gainCard(baron, &orig, 2, 0);
	memcpy(&g, &orig, sizeof(struct gameState));

	//play baron normal, discard estate. get 4 coins
	r = supplyCount(estate, &g);
	playCard(5, 1, 0, 0, &g);
	myAssert(r == supplyCount(estate, &g), "Baron gained estate while discarding", __LINE__);
	myAssert(numHandCards(&g) == 4, "Did not properly discard", __LINE__);
	for(int i = 0; i < numHandCards(&g); ++i)
		myAssert(handCard(i, &g) == copper, "Did not properly discard", __LINE__);
	//have 8 coins total
	r = buyCard(gold, &g);
	myAssert(r == 0, "Did not have 6 coins to buy gold", __LINE__);
	r = buyCard(silver, &g);
	myAssert(r == -1, "Bought silver, had more than 8 coins", __LINE__);
	r = buyCard(estate, &g);
	myAssert(r == 0, "Did not have 8 coins or 2 buys for estate", __LINE__);
	r = buyCard(copper, &g);
	myAssert(r == -1, "Got more than +1 buy from baron", __LINE__);

	//play baron normal, dont discard estate so gain one
	memcpy(&g, &orig, sizeof(struct gameState));
	r = supplyCount(estate, &g);
	playCard(5, 0, 0, 0, &g);
	myAssert(r-1 == supplyCount(estate, &g), "Baron did not gain estate", __LINE__);
	myAssert(handCard(4, &g) == estate, "Baron discarded estate in hand while gaining", __LINE__);
	r = buyCard(duchy, &g);
	myAssert(r == -1, "Bought duchy, gained coins when gaining estate", __LINE__);

	//play baron, discard estate but have none so gain one
	discardCard(4, 0, &orig, 0);
	r = supplyCount(estate, &orig);
	playCard(4, 1, 0, 0, &orig);
	r = myAssert(r-1 == supplyCount(estate, &orig), "Did not gain with no estates in hand", __LINE__);

	//done
	if(r == 0)
		printf("Tests completed successfully!\n");

	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_hammockt,代码行数:52,代码来源:cardtest2.c


示例12: main

int main(){
    struct gameState game;
    int numplayers = 4;
    int i = 0;

    // initiate
    game.numPlayers = numplayers;

    // starting hand
    game.whoseTurn = 0;
    game.phase = 0;
    game.handCount[0] = 1;
    game.discardCount[0] = 0;
    game.deckCount[0] = 0;
    game.hand[0][0] = smithy;
    game.numBuys = 2;
    game.numActions = 1;
    game.coins = 0;
    for(i = 0; i <= treasure_map; i++)
        if (i != smithy)
						// all cards
            game.supplyCount[i] = 10;
        else // there are no smithy cards
            game.supplyCount[i] = 0;
		// will not be able to purchase
    myassert(buyCard(silver, &game) == -1);

    // gold to purchase with
    game.hand[0][0] = gold;
    game.coins = 3;
		// no smithys
    myassert(buyCard(smithy, &game) == -1);
    myassert(buyCard(village, &game) == 0);
		// discard contains 1
    myassert(game.discardCount[0] == 1);
		// subtract from supply
    myassert(game.supplyCount[village] == 9);
		// no more coins
    myassert(game.coins == 0);
		// subtract buy
    myassert(game.numBuys == 1);


    if (!failed){
        printf("buyCard() test passed successfully!\n");
    }else{
        printf("buyCard() test FAILED\n");
    }
    return 0;
}
开发者ID:Schultzy911,项目名称:cs362,代码行数:50,代码来源:unittest4.c


示例13: main

//test buyCard()
int main()
{
	int kCards[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	struct gameState orig, g;
	int r, count;

	//for consistancy make randomSeed=1
	initializeGame(2, kCards, 1, &orig);
	//keep copy of original state for testing purposes
	memcpy(&g, &orig, sizeof(struct gameState));

	//first hand of player 0 is {4 coppers, 1 estate}. 4 coins
	count = supplyCount(curse, &g);
	r = buyCard(-1, &g);
	myAssert(r == -1, "Bought a non-existant card", __LINE__);
	r = buyCard(council_room, &g);
	myAssert(r == -1, "Bought council room which is not in supply", __LINE__);
	r = buyCard(gold, &g);
	myAssert(r == -1, "Gold costs 6 coins, bought with 4", __LINE__);
	r = buyCard(embargo, &g);
	myAssert(r == 0, "Could not buy an embargo with 4 coins", __LINE__);
	r = buyCard(copper, &g);
	myAssert(r == -1, "Bought more than one card on first turn", __LINE__);
	myAssert(count == supplyCount(curse, &g), "curse gained before embargo played", __LINE__);

	//player 0 gets embargo in hand buy turn 4 in handPos 3
	//advance to turn 4 for player 0
	for(int i = 0; i < 6; ++i)
		endTurn(&g);
	myAssert(handCard(3, &g) == embargo, "Did not properly gain bought embargo", __LINE__);
	playCard(3, copper, 0, 0, &g); //put an embargo on coppers
	endTurn(&g);
	//hand of player 1 turn 4 is {4 coppers, 1 estate}. 4 coins
	count = supplyCount(curse, &g);
	r = buyCard(copper, &g);
	myAssert(r == 0, "Try Buying a copper with a curse on it", __LINE__);
	myAssert(count-1 == supplyCount(curse, &g), "Improper amount of curses removed from supply", __LINE__);
	//advance to turn 5 where curse should appear in handPos 0
	for(int i = 0; i < 2; ++i)
		endTurn(&g);
	r = handCard(0, &g);
	myAssert(r == curse, "Player 1 did not recieve curse", __LINE__);

	//restart game
	buyCard(smithy, &orig);
	//smithy will show up in turn 4 in handPos 3
	//turn 4 player 0 hand is {4 coppers, 1 smithy}
	for(int i = 0; i < 6; ++i)
		endTurn(&orig);
	buyCard(silver, &orig);
	r = playCard(3, 0, 0, 0, &orig);
	r = myAssert(r == -1, "buyCard could not advance the phase", __LINE__);

	//done
	if(r == 0)
		printf("Tests completed successfully!\n");

	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_hammockt,代码行数:60,代码来源:unittest1.c


示例14: tryBuyCard

void tryBuyCard(struct gameState *state){
		int cardToBuy = 0;
		char name[100];
		do{	
			cardToBuy = rand() % (treasure_map);
		}while(state->supplyCount[cardToBuy] < 0);

		//try to buy a silver if player has 3 coins
		//and random choice is to buy a curse or copper
		if(state->coins == 3 && (cardToBuy = 0 || cardToBuy == 4)){
			if(state->supplyCount[silver] > 0){
				cardToBuy = silver;
			 }
		}
		//if the player has enough to buy a province, and 1 buy they will
		if(state->coins >= 8 && state->numBuys == 1){
			if(state->supplyCount[province] > 0){
				cardToBuy = province;
			}
		}
		
		//they try to buy a card so long as it isn't a curse
		if(cardToBuy != 0){
			cardNumToName(cardToBuy,name);
			printf("card to buy %s\n",name);
			printf("card costs %d\n",getCost(cardToBuy));
			buyCard(cardToBuy, state);
		}

		//Game info after the play 
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_suderman,代码行数:31,代码来源:testdominion.c


示例15: main

int main (int argc, char** argv) {

	struct gameState G;
	int playerNum;
  
	srand(time(NULL));
	playerNum = rand() % MAX_PLAYERS;//random player num index
	
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
						sea_hag, tribute, smithy};
		   
	printf ("\nStarting Unit Test 3: buyCard() ...\n");
	
	G.whoseTurn = playerNum;
	G.supplyCount[estate] = 9;
	G.numBuys = 1;
	G.coins = 1000;
	
	int r = initializeGame(4, k, 142, &G);//initialized for a 4 player game
	
	int cardBought = buyCard(estate,  &G);
	
	assert (cardBought == 0);
	
	printf("Passed\n");
	
	assert (r == 0);
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_quenzerc,代码行数:29,代码来源:unittest3.c


示例16: main

//Testing endGame
int main() {
	struct gameState g, orig;
	
	int k[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,
			   outpost,baron,tribute};
	int p[3]; //should be set in dominion.c
	int r = 0;
	int i;
	int count;
	//3 player game this time
	initializeGame(3, k, 1, &orig);
	//Trevor's suggestion, saving game state for testing purposes
	memcpy(&g, &orig, sizeof(struct gameState));	
	
	//buy an estate to gain victory points and "win"
	buyCard(estate, &g);
	//get to player 2's turn and end
	//Loop until end
	for(i = 0; i < 2; ++i){
		endTurn(&g);
	}
	getWinners(p, &g);
	myAssert(p[1] == 0 && p[2] == 0, "Player 1 and 2 should have lost but did not", __LINE__);
	myAssert(p[3] == -9999, "Player 4 should not exist but did", __LINE__);
	myAssert(p[0] == 1, "Player 0 did not win", __LINE__);
	
	
	
	

	if(r == 0)
		printf("Tests completed successfully!\n");

	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_fryta,代码行数:36,代码来源:unittest3.c


示例17: main

}

int main(int argc, char** argv){
   struct gameState *G;
      int numplayers, money, handpos, rseed, rcard, choice1, choice2, choice3, coinflip, i, numtests,r;
      int *k;
      int players[4];
      numtests=1;
      for(i=0; i<numtests; i++){
	 G=newGame();
	    rseed=atoi(argv[1]);
	    k = malloc(sizeof(int)*10);
	    numplayers=rand()%3+2;
	    chooseKingdomCards(k);
	    initializeGame(numplayers, k, rseed, G);

	    printf("FOR SEED %d\n", rseed);
	    if(isGameOver(G)){
	       printf("game creation error\n");
	       printf("test %d failed\n",i);
	    }
	    else{
	       while(!isGameOver(G)){
                printf("player %d turn start\n", whoseTurn(G));
		  handpos=-1;
		     coinflip=rand()%10;
		  rcard=chooseHandCard(G, k, &handpos);
		     choice1=rand()%2;
		     choice2=0;
		     if(choice1==0){
			choice2=1;
		     }
		  choice3=rand()%2;
		     if(rcard!=-1 || rcard==curse){
			r=playCard(handpos, choice1,choice2,choice3,G);
			printf("player %d played ", whoseTurn(G));
			printCard(rcard, r);
		     }
		  money=countMoney(G);
		     printf("money: %d\n", money);
		     rcard=randomBuyCard(G, money, k);
		     if(coinflip!=9){			//small chance to not buy anything
			r=buyCard(rcard, G);
			printf("player %d bought ", whoseTurn(G));
			printCard(rcard, r);
		     }
		     printf("player %d hand\n", whoseTurn(G));
		     printhand(G);
		     printf("player %d score: %d\n", whoseTurn(G), scoreFor(whoseTurn(G),G));
		     printf("player %d turn ending\n", whoseTurn(G));
		     endTurn(G);
		     if(isGameOver(G)){
			printf("game over player %d won\n", getWinners(players, G));
		     }
	       }
	       free(k);
	       free(G);
	       printf("test %d passed\n", i);
	    }
      }
开发者ID:cs362sp15,项目名称:projects,代码行数:60,代码来源:onlyminiontestdominion.c


示例18: main

//test council room
int main()
{
	int kCards[10] = {adventurer, gardens, embargo, village, minion, council_room, cutpurse, sea_hag, tribute, smithy};
	struct gameState g;
	int r;

	//for consistancy make randomSeed=1
	initializeGame(4, kCards, 1, &g);

	//turn 1 of player 0 is {4 coppers, 1 estate}. 4 coins
	gainCard(council_room, &g, 2, 0);
	r = playCard(5, 0, 0, 0, &g);
	myAssert(r == 0, "councilRoom failed", __LINE__);
	for(int i = 0; i < numHandCards(&g); ++i)
		myAssert(handCard(i, &g) != council_room, "Did not discard council room", __LINE__);
	for(int i = 0; i < 2; ++i)
	{
		r = buyCard(copper, &g);
		myAssert(r == 0, "Does not have 2 buy's. Should have got extra buy from council room", __LINE__);
	}
	myAssert(numHandCards(&g) == 9, "Player 0 does not have 9 cards", __LINE__);
	for(int i = 0; i < 3; ++i)
	{
		endTurn(&g);
		r = myAssert(numHandCards(&g) == 6, "Other players did not draw an extra card", __LINE__);
	}

	//done
	if(r == 0)
		printf("Tests completed successfully!\n");

	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_hammockt,代码行数:34,代码来源:cardtest4.c


示例19: main

//testing for playCard test: #1
int main(){

    struct gameState g;

    int k[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,outpost,baron,tribute};

	initializeGame(2, k, 5, &g);
    int buyCards = buyCard(copper, &g);

    if(buyCards == 0){
        printf("Buy Successfully\n");
    }else{
        printf("Fail to buy\n");
    }
    int previousBuys = g.numBuys;
    int previousCoins = g.coins;

    if(g.numBuys == (previousBuys - 1)){
        printf("Buy Successfully\n");
    }else{
        printf("Fail to buy");
    }
    if(g.coins == (previousCoins - (getCost(copper)))){
        printf("Buy Successfully\n");
    }else{
        printf("Not enough coins to buy\n");
    }

	printf("Test Successfully \n");
    return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_yeja,代码行数:32,代码来源:unittest1.c


示例20: main

int main (int argc, char** argv) {
  struct gameState G;
  
  // Setting up the game state
  G.numPlayers = 1;
  G.numBuys = 1;
  G.whoseTurn = 0;
  G.supplyCount[smithy] = 1;
  G.coins = 10;
  G.discardCount[0] = 0;

  // Calling buyCard (our function to test)
  int result = -99;
  result = buyCard(smithy, &G);

  // Checking the results
  assert(result == 0);
  assert(G.numBuys == 0);

  printf("UNIT TEST 1: BUYCARD-------------\n");
  printf("Value (expected): Actual\n");
  printf("result (0): %i\n", result);
  printf("numBuys (0): %i\n", G.numBuys);
  printf("discardCount (1): %i\n", G.discardCount[0]);
  printf("discard[0] (13): %i\n", G.discard[0][0]);
  printf("coins (6): %i\n", G.coins);



  return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_martys,代码行数:31,代码来源:unittest1.c



注:本文中的buyCard函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ buzzvm_stack_at函数代码示例发布时间:2022-05-30
下一篇:
C++ buttons函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap