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

C++ playCard函数代码示例

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

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



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

示例1: main

int main(int argc, char* argv[])
{
  int coins;
  int who;
  struct gameState* s = newGame();
  int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
    		sea_hag, tribute, smithy};
  
  initializeGame(2, k, 3, s);
  coins = s->coins;
  who = s->whoseTurn;
  s->hand[who][6] = steward;
  s->handCount[who]++;

  assert(playCard(6, 1, 0, 0, s) == 0);
  assert(s->handCount[who] == 7);
   
  s = newGame();
  initializeGame(2, k, 3, s);
  coins = s->coins;
  who = s->whoseTurn;
  s->hand[who][6] = steward;
  s->handCount[who]++;
  assert(playCard(6, 0, 0, 1, s) == 0);
  assert(s->handCount[who] == 3);
  
  printf("stewardEffect Passed. \n");
}
开发者ID:cs362sp15,项目名称:projects,代码行数:28,代码来源:cardtest4.c


示例2: strategyCard

unsigned int Scopa::strategyPlay(std::function<Card()> strategyCard, std::function<CardGroup(std::vector<CardGroup>)> strategyCapture) {
    Card cardToPlay = strategyCard();
    std::vector<CardGroup> captures = possibleCaptures(cardToPlay.value);
    if( captures.size() == 0 ) { return playCard(currentTurn, cardToPlay, CardGroup()); }
    else if( captures.size() == 1 ) { return playCard(currentTurn, cardToPlay, captures.front()); }
    else { return playCard(currentTurn, cardToPlay, strategyCapture(captures)); }
}
开发者ID:cherosene,项目名称:learning_algorithms,代码行数:7,代码来源:Scopa.cpp


示例3: main

int main() {
  printf("Running unit test for card \"steward\"...\n");

  struct gameState G;
  struct gameState *p = &G;

  int seed = 123456789;
  int coinsBefore;
  int numHandCardsBefore;
  int k[10] = {steward, gardens, embargo, village, minion, mine, cutpurse, 
    sea_hag, tribute, smithy};
  
  initializeGame(2, k, seed, p);
  p->hand[0][0] = steward;
  coinsBefore = p->coins;
  assertTrue(playCard(0, 0, 0, 0, p) == 0, "playCard(0, 0, 0, 0, p) == 0");
  assertTrue(p->coins == coinsBefore + 2, "p->coins == coinsBefore + 2");  //BUG: coin values not updating

  initializeGame(2, k, seed, p);
  p->hand[0][0] = steward;
  numHandCardsBefore = numHandCards(p);
  assertTrue(playCard(0, 1, 0, 0, p) == 0, "playCard(0, 1, 0, 0, p) == 0");
  assertTrue(numHandCards(p) == numHandCardsBefore + 2 - 1, "numHandCards(p) == numHandCardsBefore + 2 - 1");

  initializeGame(2, k, seed, p);
  p->hand[0][0] = steward;
  numHandCardsBefore = numHandCards(p);
  assertTrue(playCard(0, 2, 0, 0, p) == 0, "playCard(0, 2, 0, 0, p) == 0");
  assertTrue(numHandCards(p) == numHandCardsBefore - 3 , "numHandCards(p) == numHandCardsBefore - 3");

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


示例4: main

int main(){
  struct gameState g;
  int k[10] = {steward, smithy, adventurer, gardens, embargo, cutpurse, mine,
               outpost, baron, tribute};

  int choice2 = 0;
  int choice3 = 0;
  int handPos = 0;

  initializeGame(2, k, 5, &g);
  g.hand[0][0] = steward;
  g.whoseTurn = 0;  

  int num = numHandCards(&g);
  playCard(handPos, 1, choice2, choice3, &g);
  int numa = numHandCards(&g);
  
  // Steward adds two cards to the hand if choice1 == 1
  assertTF(numa = num + 2, "Add 2 card to hand\n");

  int coins = g.coins;
  // Steward adds two coins if choice1 == 2
  printf("coins b: %d\n", g.coins);
  playCard(handPos, 2, choice2, choice3, &g);
  assertTF(g.coins == coins + 2, "Add 2 coins\n");
  printf("coins a: %d\n", g.coins);

  num = numHandCards(&g);
  // Steward trashes two cards if choice1 == 3
  playCard(handPos, 3, choice2, choice3, &g); 
  numa = numHandCards(&g);
  assertTF(numa == num - 3, "Trash 2 cards\n");

  checkasserts();
}
开发者ID:cs362sp16,项目名称:cs362sp16_stallcui,代码行数:35,代码来源:cardtest3.c


示例5: 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


示例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: 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


示例8: 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


示例9: main

//test council room card
int main(){
	printf("Start to test minion card.\n");
	struct gameState state;
	int numCard0, numCard1, numCard2, numCard3, numAct0;
	int kindom[10] = {1,2,3,4,5,6,7,8,9,10};
	initializeGame(4, kindom, 2, &state);
	//player0 get2 2 cards in hand
	state.handCount[0] = 2;
	state.handCount[1] = 2;
	state.handCount[2] = 5;
	//the first card is minion
	state.hand[0][0] = minion;
	//player 0's turn
	state.whoseTurn = 0;
	//card number for 3 players
	numCard0 = state.handCount[0];
	numCard1 = state.handCount[1];
	numCard2 = state.handCount[2];
	numCard3 = state.handCount[3];
	//action of current player
	numAct0 = state.numActions;
	//printf("numCard1 is: %d\n", numCard1 );
	playCard(0, 0, 1, 0, &state);
	//draw 4 card and discard 1 card
	//printf("numCard1 is now: %d\n", state.handCount[1]);
	printf("Testing handCount for player1 choice2 .\n");
	assert (state.handCount[0] == 4);
	printf("Passed.\n");
	printf("Testing handCount for other players, choice2.\n");
	assert (state.handCount[1] == numCard1);
	assert (state.handCount[2] == 4);
	printf("Passed.\n");
	printf ("Testing the number of action.\n");
	assert (numAct0 == state.numActions);
	printf ("Passed.\n");
	printf("Testing coins, choice1.\n");
	state.handCount[0] = 1;
	state.coins = 0;	
	state.hand[0][0] = minion;
	state.whoseTurn = 0;
	playCard(0, 1, 0, 0, &state);
	printf("coins=");
	assert (state.coins == 2);
	printf("Bug found in line 910 of dominion.c.\n");
	//assert (state.numBuys == numBuy + 1);
	printf("Passed.\n");
	printf("Card minion is working.\n");
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_jiajun,代码行数:49,代码来源:cardtest4.c


示例10: main

int main (int argc, char** argv)
{
	struct gameState g;

	int players, seed, fails, deck, hand, check, test = 0;

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

	printf ("Starting tests.\n");
  
	while(test<MAX_TESTS)
	{
		if(!argc)
			seed = rand();
		else
			seed = 42;
		players = rand() % 4;
		initializeGame(players, k, seed, &g);
		deck = rand() % MAX_DECK;
		hand = rand() % MAX_HAND;
		g.whoseTurn = players;
		g.deckCount[players] = deck;
		g.handCount[players] = hand;
		
		addCardToHand(players, smithy, &g);
		check = g.handCount[players];
		playCard(hand, 0, 0, 0, &g);
		if(check+2!=g.handCount[players])
			fails++;

		test++;
	}
	printf ("Test finished with %d fails out of %d tests.\n",fails,test);
	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_andrewsm,代码行数:35,代码来源:randomtestcard1.c


示例11: main

int main()
{
	printf("CARD TEST THREE -- RUNNING\n");
	
	struct gameState g;
    int r, prevcoins;
    int k[10] = {village, smithy, cutpurse, minion, council_room, sea_hag,treasure_map, ambassador, tribute, salvager};
    initializeGame(2, k, 5, &g);
	prevcoins = g.coins;
	printf("# coins before minion = %d\n", prevcoins);
	//give player 0 a minion
	gainCard(minion, &g, 2, 0);
	r = g.hand[0][5];
	cassert(r == minion, "card 5 in hand is minion");

	testfun("playCard with card = minion, +2 coins");
	r = playCard(5, 1, 0, 0, &g); //choice 1; +2 coins
	cassert(r == 0, "minion played");

	r = g.numActions;
	cassert(r == 1, "# actions = 1"); //assert # actions is 1

	printf("# coins after minion = %d\n", g.coins);
	r = g.coins;
	cassert(r != prevcoins, "# coins changed"); //assert # coins is 2 more

	printf("CARD TEST THREE -- FINISHED\n\n");

	return 0;
}
开发者ID:cs362sp16,项目名称:cs362sp16_stallcui,代码行数:30,代码来源:stallcuicardtest3.c


示例12: main

int main() {

  printf("Testing card: feast...\n");

  // Setup

  struct gameState G;
  int k[10] = {village, smithy, feast, mine, outpost, adventurer, baron, cutpurse, tribute, embargo};

  initializeGame(2, k, 10, &G);

  G.whoseTurn = 1;
  G.hand[1][0] = feast;
  int handCount = G.handCount[1];
  int deckCount = G.deckCount[1];
  int discardCount = G.discardCount[1];

  // Do something

  // playCard(int handPos, int choice1, int choice2, int choice3, struct gameState *state)
  playCard(0, village, 0, 0, &G);

  // Did something, now check it
  my_assert(G.handCount[1] == handCount, "Wrong number of cards in hand");
  my_assert(G.deckCount[1] == deckCount, "Wrong number of cards in deck");
  my_assert(G.discardCount[1] == discardCount + 1, "Wrong number of cards in discard");
  my_assert(G.discard[1][0] == village, "Village card not in discard");
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_christev,代码行数:28,代码来源:cardtest3.c


示例13: main

int main(int argc, char *argv[]){
	
	struct gameState g;
	int seed, test_max, num_playaz, player, deck_size, hand_size, output, turn, i;
	int k[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,outpost,baron,tribute};
	
	if(argc = 3){
		seed = atoi(argv[1]);
		test_max = atoi(argv[2]);
		output = atoi(argv[3]);	
	}
		
	for(i = 0; i < test_max; i++){		
		num_playaz = rand() %3 + 2;
		
		initializeGame(num_playaz, k, seed, &g);
	
		//randomly test players
		player = rand() % num_playaz;
		deck_size = rand() % MAX_DECK;
		hand_size = rand() % MAX_HAND;
		
		g.whoseTurn = player;
		g.deckCount[player] = deck_size;
		g.handCount[player] = hand_size;
		
		addCardToHand(player, smithy, &g);
		playCard(hand_size, 0, 0, 0, &g);
		
		printf("Smithy Test #%d: Players [%d] Player [%d] Deck Count [%d] Hand Count [%d + 1]\n", i, num_playaz, player, deck_size, hand_size);	
	}
}
开发者ID:cs362sp16,项目名称:cs362sp16_longmane,代码行数:32,代码来源:randomcardtest2.c


示例14: main

int main(){
	
	printf("\nCardtest4: great_hall\n");
	struct gameState G;
	
	int k[10] = {duchy, council_room, great_hall, province, baron, adventurer, smithy, minion, village, steward};
	int hcBefore, hcAfter, actions_before, actions_after;
	
	initializeGame(2, k, 3, &G);

	G.hand[0][0] = great_hall;
	
	hcBefore = G.handCount[0];
	actions_before = G.numActions;

	playCard(1, -1, -1, -1, &G);

	hcAfter = G.handCount[0];
	actions_after = G.numActions;

	my_assert(hcAfter == hcBefore, "Handcounts."); //play 1 draw 1;
	my_assert(actions_after == actions_before, "Actions."); //action +1 -1 

	printf("End Caretest4.\n");
	
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_guox,代码行数:27,代码来源:cardtest4.c


示例15: main

int main (int argc, char** argv) {
  struct gameState G;
  
  // Setting up the game state
  G.numPlayers = 1;
  G.whoseTurn = 0;
  G.numBuys = 1;
  G.numActions = 1;
  G.coins = 0;
  G.supplyCount[duchy] = 2;
  // Player 0 stuff
  G.handCount[0] = 3;
  G.hand[0][0] = steward;
  G.hand[0][1] = estate;
  G.hand[0][2] = estate;
  G.deckCount[0] = 2;
  G.deck[0][0] = duchy;
  G.deck[0][1] = duchy;
  G.discardCount[0] = 0;

  // Calling playCard with steward
  int result;
  result = playCard(0, 2, 1, 2, &G);

  // Checking the results
  printf("CARD TEST 4: STEWARD-------------\n");
  printf("Value (expected): Actual\n");
  printf("result (0): %i\n", result);
  printf("handCount[0] (2): %i\n", G.handCount[0]);
  printf("numActions (0): %i\n", G.numActions);
  printf("coins (2): %i\n", G.coins);
  printf("discardCount (3): %i\n", G.discardCount[0]);

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


示例16: main

int main (int argc, char *argv[]){
    int card = 13;
    enum CARD mycard = outpost;     
    int choice1 = 0;
    int choice2 = 0; 
    int choice3 = 0;
    struct gameState * GameState = newGame();
    int handPos = 0;
    int * bonus = 0;
    int initialcardnum = GameState->deckCount[0];
    int initialactions = GameState-> numActions;
    int myturn = whoseTurn(GameState);
    int mydeckcount = GameState -> deckCount[myturn];
    int k[10] =  {adventurer, council_room, feast, gardens, mine,
            remodel, smithy, village, baron, great_hall};
    printf("\n\nCardTest4\n");
    initializeGame(2, k, 14242, GameState);

    GameState->hand[myturn][0] = steward; 
    choice1 = 1;
    playCard(GameState->hand[myturn][0] , 1 , 0 , 0 , GameState);
    if (mydeckcount + 2 != GameState -> deckCount[myturn]){
        printf("FAILURE: Steward did not incrase cards by 2");
    }
        return 0;
}
开发者ID:cs362sp15,项目名称:projects,代码行数:26,代码来源:cardtest4.c


示例17: main

int main (int argc, char** argv)
{
  struct gameState state;

  state.whoseTurn = 0;
  state.numActions = 1;
  state.handCount[0] = 1;
  state.hand[0][0] = great_hall;
  state.deckCount[0] = 1;
  state.deck[0][0] = province;
  state.discardCount[0] = 0;

  printf("Playing Great hall card.\n");
  playCard( 0, 0, 0, 0, &state);
  printf("Checking hand count... ");
  myassert(state.handCount[0] == 1);
  printf("Checking # of actions... ");
  myassert(state.numActions == 1);
  printf("Next two tests should fail because the Great Hall card has purposely been changed\n");
  printf("Checking deck size... ");
  myassert(state.deckCount[0] == 0);
  printf("Checking hand cards... ");
  myassert(state.hand[0][0] == province);

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


示例18: itemAt

/**
 * MouseEvent for clicking on a humanCard or on the Stack
 * @brief Playground::mousePressEvent
 * @param event
 */
void Playground::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
    if (event->button() == Qt::LeftButton) {
        QGraphicsItem* item = itemAt(event->buttonDownScenePos(event->button()), QTransform());
        if (item != NULL) {

            //Clicked on Stack
            if (item == stack.createImg()) {
                players.value(PlayerItem::direction::HUMAN)->unsetPlayableCards();
                players.value(PlayerItem::direction::HUMAN)->setUnactive();
                emit drawCard();
            }
            //Clicked on Human Card
            PlayerItem* human = players.value(PlayerItem::direction::HUMAN);
            for (int j = 0; j < human->getCards()->size(); ++j) {
                CardItem* c = human->getCards()->at(j);
                if (c->createImg() == item && c->getPlayable()) {
                    history.write("You play a Card", c->getCard().getSuit(), c->getCard().getValue());
                    Card::cardSuit chosenColor = Card::NONE;
                    if (c->getCard().getValue() == wishSuitCard) {
                        chosenColor = chooseColor();
                    }
                    soundMgr.playCard();
                    updateDepotCard(*c, depot);
                    soundMgr.drawCard();
                    human->removeCard(c->getCard());
                    human->unsetPlayableCards();
                    human->setUnactive();
                    emit playCard(depot.getCard(), chosenColor);
                }
            }
        }
    }
}
开发者ID:isn0gud,项目名称:qtMauMau,代码行数:39,代码来源:playground.cpp


示例19: main

int main (int argc, char** argv) {
	puts("Testing card gardens...");
	
	srand(time(NULL)); // Seed rand function
	/* Prepare arguments for initializeGame */
	int numPlayers = rand() % 3 + 2;
	int randomSeed = rand();
	int k[10] = {adventurer, gardens, embargo, village, minion,
		mine, cutpurse, sea_hag, tribute, smithy};
	struct gameState G;
	
	/* Run initializeGame function */
	initializeGame(numPlayers, k, randomSeed, &G);
	
	G.hand[0][0] = gardens;
	int handCountBefore = numHandCards(&G);
	
	int returnValue = playCard(0, 0, 0, 0, &G);
	assert(returnValue == 0);
	
	int handCountAfter = numHandCards(&G);
	// discard gardens
	assert(handCountAfter == (handCountBefore - 1));
	
	testStatus();
	
	return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_stolek,代码行数:28,代码来源:cardtest4.c


示例20: main

int main()
{
	int i;
	int seed = 1000;
	int numPlayers = 2;
	int player  = 0;
	int *deckZero,*deckOne;
	struct gameState preTest, postTest;
	int k[10] = {adventurer, council_room, feast, gardens, mine ,remodel, smithy, village, baron, great_hall};
	/* Test Specification Variables */
	int drawCountTestZero = 3;
	int drawCountTestOne = 0;

	initializeGame(numPlayers,k,seed,&postTest);
	printf("\n\nBeginning Test for Village...\n\n");
	memcpy(&preTest,&postTest,sizeof(struct gameState));
	insertCard(&postTest,player);
	playCard((postTest.handCount[player]-1),0,0,0,&postTest);
	testDraw(&preTest,&postTest,player);
	testHand(&preTest,&postTest,player);
	testDiscard(&preTest,&postTest,player);
	testSupply(&preTest,&postTest);
	testPlayed(&preTest,&postTest);
	testUtility(&preTest,&postTest);
	printf("\n\tTesting finished\n\n");
}
开发者ID:cr8zd,项目名称:cs362w16,代码行数:26,代码来源:cardtest4.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ playMovie函数代码示例发布时间:2022-05-30
下一篇:
C++ platform_set_drvdata函数代码示例发布时间: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