当前位置: 首页>>代码示例>>C++>>正文


C++ cardEffect函数代码示例

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


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

示例1: main

int main(int argc, int argv[])
{
	struct gameState G;
  	struct gameState *p=&G;

  	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
	       sea_hag, tribute, smithy};
  
  	printf ("Testing council_room card.\n");
  
  	int r = initializeGame(2, k, 5, p);
  	massert (r == 0,"initializeGame failed\n");

  	int player = whoseTurn(p);
  	int handPos = 0;
  	int coin_bonus=0;

  	G.handCount[player]=4;
  	G.hand[player][0]=council_room;
  	G.hand[player][1]=village;
  	G.hand[player][2]=minion;
  	G.hand[player][3]=mine;

  	G.numBuys=0;

  	int card = handCard(handPos,p);
  	massert(card>=adventurer&&card<=treasure_map,"invalid card\n");
  	massert(card==council_room,"incorrect card\n");

  	int test=cardEffect(card,-1,-1,-1,p,handPos,&coin_bonus);
  	massert(test==0,"cardEffect failed\n");
  	massert(G.handCount[player]==7,"incorrect had count\n");
  	massert(G.numBuys==1,"numBuys incorrect value\n");
  	massert(G.hand[player][0]!=council_room,"council_room is not discarded\n");

  	if(passed==0)
  		printf("---Test Passed!\n");

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

示例2: playCard

int playCard(int handPos, int choice1, int choice2, int choice3, struct gameState *state) 
{	
  int card;
  int coin_bonus = 0; 		//tracks coins gain from actions

  //check if it is the right phase
  if (state->phase != 0)
    {
      return -1;
    }
	
  //check if player has enough actions
  if ( state->numActions < 1 )
    {
      return -1;
    }
	
  //get card played
  card = handCard(handPos, state);
	
  //check if selected card is an action
  if ( card < adventurer || card > treasure_map )
    {
      return -1;
    }
	
  //play card
  if ( cardEffect(card, choice1, choice2, choice3, state, handPos, &coin_bonus) < 0 )
    {
      return -1;
    }
	
  //reduce number of actions
  state->numActions--;

  //update coins (Treasure cards may be added with card draws)
  updateCoins(state->whoseTurn, state, coin_bonus);
	
  return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_broderij,代码行数:40,代码来源:mutant100766_dominion.c

示例3: main

int main () {
  struct gameState G;
  int r;

  int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
	       sea_hag, tribute, smithy};
  printf("cardtest1:\n");
  r = initializeGame(2, k, 10, &G);
  assert (r == 0);
  //Set up 1 cards to be drawn by great_hall
  G.deck[0][0] = 100;
  G.deckCount[0] = 1;
  //Set up card to discard
  G.hand[0][0] = 50;
  G.handCount[0] = 1;
 
  r = cardEffect(great_hall, -1, -1, -1, &G, 0, NULL);
  if(r == -1) {
	  printf("\tFAILURE: cardEffect\n");
	  return 1;
  } else {
	  printf("\tPASS: cardEffect\n");
  }
  if(G.handCount[0] != 1) {
	  printf("\tFAILURE: handCount\n");
	  return 1;
  } else {
	  printf("\tPASS: handCount\n");
  }
  
  if(G.hand[0][0] != 100){
	  printf("\tFAILURE: hand\n");
	  return 1;
  } else {
	  printf("\tPASS: hand\n");
  }
   printf("SUCCESS.\n\n");
  return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_hamc,代码行数:39,代码来源:cardtest1.c

示例4: main

int main(int argc, char** argv)
{
   struct gameState gameInstance;
   int actions;
   int t;

   int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
			       sea_hag, steward, smithy};

   printf("Test: Village\n");

   initializeGame(2, k, 5, &gameInstance);
   actions = gameInstance.numActions;
   t = cardEffect(village, 0, 0, 0, &gameInstance, 0, NULL);

   myAssert(gameInstance.numActions == actions + 2);
   myAssert(t == 0);

   printf("\n\n\n\n");

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

示例5: main

int main(){
	int i;
	int j;
	int handPos;
	int randomCard;
	int handCount;
	int ret = 0;
	struct gameState *state = malloc(sizeof(struct gameState));
	time_t t;

	printf("Unit test 8 outpost card in dominion.c \n");
	srand((unsigned)time(&t));
	for(i = 0; i < MAX_PLAYERS; i++){
		state->outpostPlayed = 0;
		state->deckCount[i] = 0;
		state->handCount[i] = 0;
		handPos = 0;
		state->whoseTurn = i;
		handPos = rand()%(MAX_HAND) + 1; 
		for(j = 0; j < handPos; j++){
			randomCard = rand()%(treasure_map+1); 
			state->hand[i][j] = randomCard;
			state->handCount[i]++;
		}
		for(j = 0; j < (MAX_DECK-handPos); j++){
			state->deck[i][j] = randomCard;
			state->deckCount[i]++;
		}
		state->hand[i][handPos] = outpost; 
		state->handCount[i]++;
		handCount = state->handCount[i]-1;
		ret = cardEffect(outpost, 0, 0, 0, state, handPos, 0);
		assert(ret == 0);
		assert(state->outpostPlayed == 1);
		assert(handCount == state->handCount[i]);
	}
	printf("All tests passed! \n\n");
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_chenj2,代码行数:39,代码来源:cardtest4.c

示例6: main

int main (int argc, char** argv) {
	struct gameState x;
	int i;	
	
	int y[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, feast, smithy};

	printf ("gardens\n");

	initializeGame(2, y, 2, &x);

	i = cardEffect(gardens, 0, 0, 0, &x, 0, 0);

	assert(i == -1);

	assert(x.numActions == 1);
	
	assert(numHandCards(&x) == 5);

	assert(x.numBuys ==1); //nothing should change

	return (0);
}
开发者ID:cs362sp15,项目名称:projects,代码行数:22,代码来源:cardtest4.c

示例7: main

int main(){
	struct gameState g;
	int i, ret, bonus;
	bonus = 0;
	
	  int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
	       sea_hag, tribute,smithy};

	printf ("Starting game.\n");
	
	initializeGame(2, k, 5, &g);
		   
	//g.coins = 0;
	g.embargoTokens[smithy] = 0;
	g.hand[0][0] = embargo;
	
	printf("handcount is %d \n", g.handCount[0]);
	printf("coin is %d \n", g.coins);
	
	assert(g.handCount[0] == 5);
	assert(g.coins == 4);
	
	//cardEffect(card, choice1, choice2, choice3, state, handPos, &coin_bonus)
	//playCard(0,smithy,-1,-1, &g);
	cardEffect(embargo, smithy, -1, -1, &g, 0, &bonus);
	
	printf("handcount is %d \n", g.handCount[0]);
	printf("coin is %d \n", g.coins);
	printf("g.embargoTokens[smithy] is : %d \n", g.embargoTokens[smithy]);
	assert( g.embargoTokens[smithy] == 1);
	assert(g.coins == 6);
	
	//assert(g.handCount[0] == 8);
	//assert(g.numBuys == 2);
	
	//assert(g.handCount[0] == 9);
	printf ("embargo switch statement works \n");
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_chenj2,代码行数:39,代码来源:cardtest3.c

示例8: main

int main() {
    int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
		     sea_hag, tribute, smithy};
    int players, player, handCount, deckCount, seed, handPos, coinBonus;
    struct gameState state;
        
    srand(time(NULL));

	printf("Running Random Adventurer Test\n");

	for (int i = 0; i < MAX_TESTS; i++) {

		players = rand() % (MAX_PLAYERS - 2) + 2;
		seed = rand();
		coinBonus = 0;
		handPos = rand() % 4;
		player = i % (players);

		initializeGame(players, k, seed, &state); //initialize Gamestate

		// Initiate valid state variables
		state.deckCount[player] = rand() % MAX_DECK;   //Pick random deck size out of MAX DECK size
		state.discardCount[player] = rand() % MAX_DECK;
		state.handCount[player] = rand() % MAX_HAND;
        
        // Copy state variables
		handCount = state.handCount[player];
		deckCount = state.deckCount[player];
        
		cardEffect(adventurer, 1, 1, 1, &state, handPos, &coinBonus);
        int result = validateStateAfterAdventurerDraw(&state, player, handCount, deckCount);
		assert(result == 1);
	}

	printf("Tests Complete\n");

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

示例9: testDiscardFail

void testDiscardFail()
{
	int turn1 = G->whoseTurn;
	int turn2 = turn1 + 1;

	//Assign first hand draw (deck must be identifiable)
	G->hand[turn1][0] = copper;
	G->hand[turn1][1] = baron;
	G->hand[turn1][2] = copper;
	G->hand[turn1][3] = copper;
	G->hand[turn1][4] = copper;

	//Each Deck position should be different (identification)
	G->deck[turn1][0] = estate;
	G->deck[turn1][1] = silver;
	G->deck[turn1][2] = gold;
	G->deck[turn1][3] = village;
	G->deck[turn1][4] = minion;

	//Set 2nd player to keep deck identifiable
	G->deck[turn2][0] = estate;
	G->deck[turn2][1] = estate;
	G->deck[turn2][2] = copper;
	G->deck[turn2][3] = copper;
	G->deck[turn2][4] = copper;
	G->deck[turn2][5] = tribute;
	G->deck[turn2][6] = salvager;
	G->deck[turn2][7] = adventurer;
	G->deck[turn2][8] = baron;
	G->deck[turn2][9] = remodel;

	printf("\n*********Before card effect (With Failed Discard)***********\n");
	displayState(G);
	cardEffect(baron, 1, 0, 0, G, 0, 0);
	printf("\n*********After card effect(With Failed Discard)***********\n");
	displayState(G);
	return;
}
开发者ID:cs362sp15,项目名称:projects,代码行数:38,代码来源:cardtest3.c

示例10: main

int main(int argc, char *argv[]) {
        srand(atoi(argv[1]));
        struct gameState g;

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

        int numPlayers = rand() % MAX_PLAYERS;
        int seed = atoi(argv[1]);

        int numTests = 300;

        for(int i = 0; i < numTests; i++) {
                initializeGame(numPlayers, k, seed, &g);

                // g.deckCount[g.whoseTurn] = rand() % MAX_DECK;
                // g.discardCount[g.whoseTurn] = rand() % MAX_DECK;
                // g.handCount[g.whoseTurn] = rand() % MAX_HAND;

                int startingHand = numHandCards(&g);
                int startingDeck = g.deckCount[g.whoseTurn];

                myassert(!cardEffect(adventurer, 0, 0, 0, &g, 0, 0),
                         "Adventurer returned the wrong value.");

                myassert(numHandCards(&g) == startingHand + 2,
                         "Wrong number of treasure cards drawn by adventurer.");

                int endingDiscard = g.discardCount[g.whoseTurn];

                myassert(g.deckCount[g.whoseTurn] == startingDeck - endingDiscard - 2,
                         "Wrong number of treasure cards taken from deck by adventurer.");

                seed++;
        }

        checkasserts();
}
开发者ID:TheTallPaul,项目名称:cs362sp16_melloc,代码行数:38,代码来源:randomtestadventurer.c

示例11: playCard

int playCard(int handPos, int choice1, int choice2, int choice3, gameState *state) {
    // disallow improper phase or too few actions
    if (state->phase != 0 || state->numActions < 1)
        return -1;

    //get card played
    int card = handCard(handPos, state);

    //check if selected card is an action
    if (card < adventurer || card > treasure_map)
        return -1;

    //play card
    int coin_bonus = 0; 		//tracks coins gain from actions
    if (cardEffect(card, choice1, choice2, choice3, state, handPos, &coin_bonus) < 0)
        return -1;

    //update actions and coins (Treasure cards may be added with card draws)
    state->numActions--;
    updateCoins(state->whoseTurn, state, coin_bonus);

    return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_tolvstaa,代码行数:23,代码来源:dominion.c

示例12: main

int main () {
  struct gameState state;
  struct gameState *g = &state;
  int card_returnValue;
  int r;
  int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
	       sea_hag, tribute, smithy};
		   
    srand(time(NULL));
    r = rand();
	printf("-----\nCard Test 2: Gardens\n-----\n");
  // initialize game 
  int returnValue = initializeGame(2, k, r, g);
  // make sure initialization is completed
  assert (returnValue == 0);
  // check return value 
	card_returnValue = cardEffect(gardens, 0, 0, 0, g, 0, 0);
	assert(card_returnValue==-1);
	printf("Test passed\n");
	printf("Card Test 2: Gardens completed\n");

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

示例13: main

int main() {
    printf("%sTesting Smithy Card...%s\n", YELLOW, CLEAR);
    int i = 0;
    struct gameState state;
    int game;

    printf("%s\nSetting up game...%s\n", YELLOW, CLEAR);
    game = initializeGame(2, kingdomCards(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 5, &state);
    assertTrue(game == 0, "Game is initialized");
    
    printf("%s\nSetting card to smithy...%s\n", YELLOW, CLEAR);
    state.hand[0][0] = 13;
    assertTrue(state.hand[0][0] == 13, "Test card is smithy");

    printf("%s\nSaving initial hand count...%s\n", YELLOW, CLEAR);
    int currentHandNum = state.handCount[0];

    printf("%s\nCalling smithy card...%s\n", YELLOW, CLEAR);
    cardEffect(13, 0, 0, 0, &state, i, NULL);

    assertTrue(state.handCount[0] == currentHandNum+2, "+3 cards, discard 1");
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_stinek,代码行数:23,代码来源:cardtest2.c

示例14: main

int main(int argc, char *argv[]){
   struct gameState *state1 = malloc(sizeof(struct gameState)), 
	            *state2 = malloc(sizeof(struct gameState));
   int testseed, loops = 10000, i, handpos, bonus = 0, choice1, choice2, choice3;
   char str[100];

   if(argc > 1)
      testseed = atoi(argv[1]);
   else
      testseed = time(NULL);
   srand(testseed);

   if (argc > 2)
      loops = atoi(argv[2]);

   printf("Testing great hall %d times...\n", loops);
   
   for(i = 0; i < loops; i++){
//      printf("test %d\n", i + 1);
      if(initialize(state1, &handpos, &testseed))
	 printf("failed to initialize game states\n");
      else{
	 memcpy(state2, state1, sizeof(struct gameState));
	 memset(str, '\0', sizeof(char) * 100);
	 sprintf(str, "Great hall card failed (number of players = %d, handpos = %d, original deck count = %d",state1->numPlayers, handpos, state1->deckCount[state1->whoseTurn]);
//	 myassert(impliment(state1), "testing implimentation failed\n");
	 impliment(state1, handpos);
	 cardEffect(card, 0, 0, 0, state2, handpos, &bonus);
	 sprintf(str, "%s error number %d)\n",str, check(state1, state2));
	 myassert(check(state1, state2), str);
      }
   }

   (numFails()) ? printf("%d of %d tests FAILED\n", numFails(), loops) : printf("Test SUCCESSFUL\n");

   return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_pederson,代码行数:37,代码来源:randomtestcard2.c

示例15: testCardEffect_Smithy

//-------------------------------------------------------------------
//TEST
//-------------------------------------------------------------------
int testCardEffect_Smithy(int player, int testCard, int testCardPos, struct gameState *game) {
	int testChoice1 = -1, testChoice2 = -1, testChoice3 = -1, testBonus = 0; // Vars passed to cardEffect
	int prevValue = 0/*, success = 1*/, allPass = 1;
	int oriPlayer = 0;

	// Store Original Values
	oriPlayer = game->whoseTurn;

	/* After playing smithy player should have 3 new cards and smithy should be in their played cards pile */
	prevValue = game->handCount[player];
	cardEffect(testCard, testChoice1, testChoice2, testChoice3, game, testCardPos, &testBonus);
	//assert(game->handCount[player] == (prevValue + 2));		// 3 new cards - 1 smithy card = 2 card difference
	printf("Part 1...");
	if (allPass) {
		allPass = f_Assert((game->handCount[player] == (prevValue + 2)), "");
	}
	else {
		f_Assert((game->handCount[player] == (prevValue + 2)), "");
	}

	//assert(game->playedCards[game->playedCardCount - 1] == testCard);	// Smithy was the last card discarded
	printf("Part 2...");
	if (allPass) {
		allPass = f_Assert((game->playedCards[game->playedCardCount - 1] == testCard), "");
	}
	else {
		f_Assert((game->playedCards[game->playedCardCount - 1] == testCard), "");
	}

	// Restore original values
	game->whoseTurn = oriPlayer;

	// If all tests passed success = 1
	if (allPass) { printf("Unit test was successfully completed.\n"); }

	return allPass;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_merrittm,代码行数:40,代码来源:cardtest2.c


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