这篇教程C++ supplyCount函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中supplyCount函数的典型用法代码示例。如果您正苦于以下问题:C++ supplyCount函数的具体用法?C++ supplyCount怎么用?C++ supplyCount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了supplyCount函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cardEffectint cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){ int i; int j; int k; int x; int index; int currentPlayer = whoseTurn(state); int nextPlayer = currentPlayer + 1; int tributeRevealedCards[2] = {-1, -1}; int temphand[MAX_HAND];// moved above the if statement int drawntreasure=0; int cardDrawn; int z = 0;// this is the counter for the temp hand if (nextPlayer > (state->numPlayers - 1)){ nextPlayer = 0; } //uses switch to select card and perform actions switch( card ) { //adventurer now outside function case adventurer: return c_adventurer(drawntreasure, state, currentPlayer, cardDrawn, temphand, z, handPos); case council_room: return c_council_room(currentPlayer, state, handPos); case feast: //gain card with cost up to 5 //Backup hand for (i = 0; i <= state->handCount[currentPlayer]; i++){ temphand[i] = state->hand[currentPlayer][i];//Backup card state->hand[currentPlayer][i] = -1;//Set to nothing } //Backup hand //Update Coins for Buy updateCoins(currentPlayer, state, 5); x = 1;//Condition to loop on while( x == 1) {//Buy one card if (supplyCount(choice1, state) <= 0){ if (DEBUG) printf("None of that card left, sorry!/n"); if (DEBUG){ printf("Cards Left: %d/n", supplyCount(choice1, state)); } } else if (state->coins < getCost(choice1)){ printf("That card is too expensive!/n"); if (DEBUG){ printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } } else{ if (DEBUG){ printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } gainCard(choice1, state, 0, currentPlayer);//Gain the card x = 0;//No more buying cards if (DEBUG){ printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } } } //Reset Hand for (i = 0; i <= state->handCount[currentPlayer]; i++){ state->hand[currentPlayer][i] = temphand[i]; temphand[i] = -1; } //Reset Hand return 0; case gardens: return -1; case mine: j = state->hand[currentPlayer][choice1]; //store card we will trash if (state->hand[currentPlayer][choice1] < copper || state->hand[currentPlayer][choice1] > gold) { return -1; } if (choice2 > treasure_map || choice2 < curse) { return -1; } if ( (getCost(state->hand[currentPlayer][choice1]) + 3) > getCost(choice2) )//.........这里部分代码省略.........
开发者ID:CaptainKimothy,项目名称:cs362w16,代码行数:101,
示例2: cardEffectint cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){ int i; int j; int k; int x; int index; int currentPlayer = whoseTurn(state); int nextPlayer = currentPlayer + 1; int tributeRevealedCards[2] = {-1, -1}; int temphand[MAX_HAND];// moved above the if statement int drawntreasure=0; // int cardDrawn; int z = 0;// this is the counter for the temp hand if (nextPlayer > (state->numPlayers - 1)) { nextPlayer = 0; } //uses switch to select card and perform actions switch( card ) { case adventurer: return adventurerEffect(state, drawntreasure, z, temphand); case council_room: //+4 Cards for (i = 0; i < 4; i++) { drawCard(currentPlayer, state); } //+1 Buy state->numBuys++; //Each other player draws a card for (i = 0; i < state->numPlayers; i++) { if ( i != currentPlayer ) { drawCard(i, state); } } //put played card in played card pile discardCard(handPos, currentPlayer, state, 0); return 0; case feast: //gain card with cost up to 5 //Backup hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { temphand[i] = state->hand[currentPlayer][i];//Backup card state->hand[currentPlayer][i] = -1;//Set to nothing } //Backup hand //Update Coins for Buy updateCoins(currentPlayer, state, 5); x = 1;//Condition to loop on while( x == 1) {//Buy one card if (supplyCount(choice1, state) <= 0) { if (DEBUG) printf("None of that card left, sorry!/n"); if (DEBUG) { printf("Cards Left: %d/n", supplyCount(choice1, state)); } } else if (state->coins < getCost(choice1)) { printf("That card is too expensive!/n"); if (DEBUG) { printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } } else{ if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } gainCard(choice1, state, 0, currentPlayer);//Gain the card x = 0;//No more buying cards if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } } } //Reset Hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { state->hand[currentPlayer][i] = temphand[i]; temphand[i] = -1; } //Reset Hand//.........这里部分代码省略.........
开发者ID:TheTallPaul,项目名称:cs362sp16_melloc,代码行数:101,
示例3: cardEffectint cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){ int i; int j; int k; int index; int currentPlayer = whoseTurn(state); int nextPlayer = currentPlayer + 1; int tributeRevealedCards[2] = {-1, -1}; int drawntreasure=0; if (nextPlayer > (state->numPlayers - 1)){ nextPlayer = 0; } //uses switch to select card and perform actions switch( card ) { case adventurer: return adventurerCard (drawntreasure, state, currentPlayer); case council_room: return councilRoomCard (currentPlayer, state, handPos); case feast: return feastCard (currentPlayer, state, choice1); case gardens: return -1; case mine: return mineCard (currentPlayer, state, choice1, choice2, handPos); case remodel: return remodelCard (currentPlayer, state, choice1, choice2, handPos); case smithy: //+3 Cards for (i = 0; i < 3; i++) { drawCard(currentPlayer, state); } //discard card from hand discardCard(handPos, currentPlayer, state, 0); return 0; case village: //+1 Card drawCard(currentPlayer, state); //+2 Actions state->numActions = state->numActions + 2; //discard played card from hand discardCard(handPos, currentPlayer, state, 0); return 0; case baron: state->numBuys++;//Increase buys by 1! if (choice1 > 0){//Boolean true or going to discard an estate int p = 0;//Iterator for hand! int card_not_discarded = 1;//Flag for discard set! while(card_not_discarded){ if (state->hand[currentPlayer][p] == estate){//Found an estate card! state->coins += 4;//Add 4 coins to the amount of coins state->discard[currentPlayer][state->discardCount[currentPlayer]] = state->hand[currentPlayer][p]; state->discardCount[currentPlayer]++; for (;p < state->handCount[currentPlayer]; p++){ state->hand[currentPlayer][p] = state->hand[currentPlayer][p+1]; } state->hand[currentPlayer][state->handCount[currentPlayer]] = -1; state->handCount[currentPlayer]--; card_not_discarded = 0;//Exit the loop } else if (p > state->handCount[currentPlayer]){ if(DEBUG) { printf("No estate cards in your hand, invalid choice/n"); printf("Must gain an estate if there are any/n"); } if (supplyCount(estate, state) > 0){ gainCard(estate, state, 0, currentPlayer); state->supplyCount[estate]--;//Decrement estates if (supplyCount(estate, state) == 0){ isGameOver(state); } } card_not_discarded = 0;//Exit the loop } else{ p++;//Next card } } } else{ if (supplyCount(estate, state) > 0){ gainCard(estate, state, 0, currentPlayer);//Gain an estate state->supplyCount[estate]--;//Decrement Estates if (supplyCount(estate, state) == 0){ isGameOver(state); } } }//.........这里部分代码省略.........
开发者ID:cs362sp16,项目名称:cs362sp16_minnerp,代码行数:101,
示例4: cardEffectint cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){ int i; int j; int index; int currentPlayer = whoseTurn(state); int nextPlayer = currentPlayer + 1; int tributeRevealedCards[2] = { -1, -1 }; int temphand[MAX_HAND];// moved above the if statement int drawntreasure = 0; int cardDrawn; int z = 0;// this is the counter for the temp hand if (nextPlayer > (state->numPlayers - 1)) { nextPlayer = 0; } //uses switch to select card and perform actions switch (card) { case adventurer: playedCard(handPos, NULL, NULL, state); while (drawntreasure < 2) { if (drawCard(currentPlayer, state) == -1) break; cardDrawn = state->hand[currentPlayer][state->handCount[currentPlayer] - 1];//top card of hand is most recently drawn card. if (cardDrawn == copper || cardDrawn == silver || cardDrawn == gold) drawntreasure++; else { temphand[z] = cardDrawn; state->hand[currentPlayer][state->handCount[currentPlayer] - 1] = -1; state->handCount[currentPlayer]--; //this should just remove the top card (the most recently drawn one). z++; } } while (z > 0) { state->discard[currentPlayer][state->discardCount[currentPlayer]++] = temphand[z - 1]; // discard all cards in play that have been drawn z--; } endPlayed(state, 0); return 0; case council_room: return councilRoomEffect(currentPlayer, handPos, state); case feast: if (choice1 < curse || choice1 > treasure_map) return -1; if (supplyCount(choice1, state) <= 0) { if (DEBUG) printf("None of that card left, sorry!/n"); if (DEBUG) { printf("Cards Left: %d/n", supplyCount(choice1, state)); } return -1; } else if (5 < getCost(choice1)) { if (DEBUG) { printf("That card is too expensive!/n"); printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } return -1; } playedCard(handPos, NULL, NULL, state); if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } gainCard(choice1, state, 0, currentPlayer);//Gain the card if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } //trash feast endPlayed(state, 1); return 0; case gardens: return -1; case mine: if (choice1 >= state->handCount[currentPlayer] || choice1 < 0 || choice1 == handPos) return -1; j = state->hand[currentPlayer][choice1]; //store card we will trash if (state->hand[currentPlayer][choice1] < copper || state->hand[currentPlayer][choice1] > gold) { return -1; } if (choice2 > gold || choice2 < copper) {//.........这里部分代码省略.........
开发者ID:cs362sp16,项目名称:cs362sp16_berezam,代码行数:101,
示例5: cardEffectint cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){ int i = 0; int j = 0; int k; int x; int index; int currentPlayer = whoseTurn(state); int nextPlayer = currentPlayer + 1; int tributeRevealedCards[2] = {-1, -1}; int temphand[MAX_HAND];// moved above the if statement int drawntreasure=0; int cardDrawn; int z = 0;// this is the counter for the temp hand if (nextPlayer > (state->numPlayers - 1)){ nextPlayer = 0; } //uses switch to select card and perform actions switch( card ) { case adventurer: return adventurerCard(currentPlayer, handPos, state, drawntreasure, cardDrawn, temphand); //Edit **************************************** case council_room: council_room_func(card, state, handPos, bonus, currentPlayer); return 0; case feast: //Checking supply and cost requirements if(supplyCount(choice1, state) <= 0 || getCost(choice1) > 5) return -1; //gain card with cost up to 5 //Backup hand for (i = 0; i <= state->handCount[currentPlayer]; i++){ temphand[i] = state->hand[currentPlayer][i];//Backup card state->hand[currentPlayer][i] = -1;//Set to nothing } //Backup hand //Update Coins for Buy updateCoins(currentPlayer, state, 5); x = 1;//Condition to loop on while( x == 1) {//Buy one card if (supplyCount(choice1, state) <= 0){ if (DEBUG) printf("None of that card left, sorry!/n"); if (DEBUG){ printf("Cards Left: %d/n", supplyCount(choice1, state)); } } else if (state->coins < getCost(choice1)){ printf("That card is too expensive!/n"); return -1; } } if (DEBUG){ printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } else{ //Add new card to discard gainCard(choice1, state, 0, currentPlayer); //remove feast! discardCard(handPos, currentPlayer, state, 1); return 0; case gardens: return -1; //Edit 2 ********************************************************************************************************************* case mine: i = mine_func(card, i, j, choice1, choice2, state, handPos, bonus, currentPlayer); return i; //Edit 3 ********************************************************************************************************************* case remodel: i=remodel_func(card, i, j, choice1, choice2, state, handPos, bonus, currentPlayer); return i; case smithy: smithy_func(card, i, j, choice1, choice2, state, handPos, bonus, currentPlayer); return 0; //.........这里部分代码省略.........
开发者ID:cs362sp16,项目名称:cs362sp16_fryta,代码行数:101,
示例6: playcard_feastint playcard_feast(int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){ int i; int currentPlayer = whoseTurn(state); int x; int temphand[MAX_HAND];// moved above the if statement //gain card with cost up to 5 //Backup hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { temphand[i] = state->hand[currentPlayer][i];//Backup card state->hand[currentPlayer][i] = -1;//Set to nothing } //Backup hand //Update Coins for Buy updateCoins(currentPlayer, state, 5); x = 1;//Condition to loop on while( x == 1) { //Buy one card if (supplyCount(choice1, state) <= 0) { if (DEBUG) { printf("None of that card left, sorry!/n"); } if (DEBUG) { printf("Cards Left: %d/n", supplyCount(choice1, state)); } } else if (state->coins < getCost(choice1)) { printf("That card is too expensive!/n"); if (DEBUG) { printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } } else { if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } gainCard(choice1, state, 0, currentPlayer);//Gain the card x = 0;//No more buying cards if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } } } //Reset Hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { state->hand[currentPlayer][i] = temphand[i]; temphand[i] = -1; } //Reset Hand return 0;}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_morgaalb,代码行数:73,
示例7: feastCardint feastCard(int currentPlayer, int choice1, struct gameState* state, int handPos){ //Gain a card up to 5 cost //Backup hand int i; int x; int temphand[MAX_HAND]; for (i = 0; i <= state->handCount[currentPlayer]; i++){ //Backup card temphand[i] = state->hand[currentPlayer][i]; //Set to nothing state->hand[currentPlayer][i] = -1; } //Backup hand //Update coins for buy updateCoins(currentPlayer, state, 5); //Condition to loop on x = 1; //Buy 1 card while(x == 1) { if (supplyCount(choice1, state) <= 0){ if (DEBUG){ printf("No cards remaining!/n"); } if(DEBUG){ printf("Cards remaining: %d/n", supplyCount(choice1,state)); } } else if (state->coins < getCost (choice1)) { printf ("Not enough coins to purchase card!/n"); if (DEBUG){ printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } } else{ if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } //Gain the card gainCard(choice1, state, 0, currentPlayer); //No buys remaining x=0; if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer]); } } } //Reset hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { state->hand[currentPlayer][i] = temphand[i]; temphand[i] = -1; } return 0;}
开发者ID:cs362sp15,项目名称:projects,代码行数:64,
示例8: main//baronint main(int argc, char* args[]){ int kCards[10] = {adventurer, gardens, embargo, village, minion, baron, cutpurse, sea_hag, tribute, smithy}; struct gameState g, orig; int r; if(argc != 3) { printf("Usage: randomtestcard1 seed secondsToRun/n"); return -1; } int seed = atoi(args[1]); int secondsLeft = atoi(args[2]); srand(seed); initializeGame(2, kCards, seed, &orig); printf("Running randomtestcard1 for %d seconds/n", secondsLeft); clock_t start = clock(); while(1) { clock_t totalTime = (clock() - start) / CLOCKS_PER_SEC; if(totalTime >= secondsLeft) break; memcpy(&g, &orig, sizeof(struct gameState)); int numHand = rand() % 10; for(int i = 0; i < numHand; ++i) { int randCard = rand() % (treasure_map+1); g.hand[0][i] = randCard; } g.handCount[0] = numHand; gainCard(baron, &g, 2, 0); int numEstates = 0; for(int i = 0; i < numHandCards(&g); ++i) if(handCard(i, &g) == estate) numEstates++; int oldTotalCards = fullDeckCount(0, &g); int totalCoins = updateCoins(0, &g); int estateSupp = supplyCount(estate, &g); int randOption = rand() % 2; r = playCard(numHandCards(&g)-1, randOption, 0, 0, &g); int newCoins = updateCoins(0, &g); myAssert(r == 0, "Played card failed", __LINE__); myAssert(g.numBuys == 2, "Did not get a buy", __LINE__); int newEstates = 0; for(int i = 0; i < numHandCards(&g); ++i) if(handCard(i, &g) == estate) newEstates++; //move playedCards into discard endTurn(&g); //wants to discard and has estates if(randOption && numEstates) { myAssert(newEstates == numEstates-1, "Did not discard estate when had/wanted to", __LINE__); myAssert(newCoins == totalCoins+4, "Did not get 4 coins for discarding estate", __LINE__); r = myAssert(oldTotalCards == fullDeckCount(0, &g), "Lost cards", __LINE__); } //wants to discard but has no estates else if(randOption && !numEstates) { myAssert(estateSupp-1 == supplyCount(estate, &g), "Did not gain estate when had none to discard", __LINE__); myAssert(newCoins == totalCoins, "Coins are not the same after forced to gain an estate", __LINE__); r = myAssert(oldTotalCards+1 == fullDeckCount(0, &g), "Incorrect total card count", __LINE__); } //did not want to discard else { myAssert(estateSupp-1 == supplyCount(estate, &g), "Did not gain estate", __LINE__); myAssert(newCoins == totalCoins, "Coins are not the same after gaining estate", __LINE__); r = myAssert(oldTotalCards+1 == fullDeckCount(0, &g), "Incorrect total card count", __LINE__); } if(r != 0) break; } r = myAssert(1, "", __LINE__); if(r == 0) printf("Tests completed successfully/n"); return 0;}
开发者ID:cs362sp16,项目名称:cs362sp16_hammockt,代码行数:93,
示例9: mainint main() { int i, test1=0, scoreTrack=10; int currentPlayer, money; struct gameState G; int k[10] = {adventurer, gardens, embargo, village, minion, mine, sea_hag, great_hall, tribute, outpost}; 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) == outpost) { test1=numHandCards(&G); playCard(i, -1, -1, -1, &G); //assert(test1==numHandCards(&G)+2); }*/ if (handCard(i, &G) == copper) { playCard(i, -1, -1, -1, &G); money++; } else if (handCard(i, &G) == silver) { playCard(i, -1, -1, -1, &G); money += 2; } else if (handCard(i, &G) == gold) { playCard(i, -1, -1, -1, &G); 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 >= 5) { buyCard(outpost, &G); }*/ else if (money >= 3) { buyCard(silver, &G); } endTurn(&G); } }
开发者ID:CS362-Winter-2016,项目名称:cs362w16_kwakp,代码行数:65,
示例10: main//.........这里部分代码省略......... } /* Test other player's deck */ if (testGame.deckCount[i] == origGame.deckCount[i]) { passFlag = 1; for (int j = 0; j < testGame.deckCount[i]; j++) { if (testGame.deck[i][j] != origGame.deck[i][j]) { passFlag = 0; break; } } } else { passFlag = 0; } if (passFlag == 1) { printf(" PASS: Player %d deck is uneffected/n", i+1); passCount++; } else { printf(" FAIL: Player %d deck is effected/n", i+1); failCount++; } /* Test other player's discard */ if (testGame.discardCount[i] == origGame.discardCount[i]) { passFlag = 1; for (int j = 0; j < testGame.discardCount[i]; j++) { if (testGame.discard[i][j] != origGame.discard[i][j]) { passFlag = 0; break; } } } else { passFlag = 0; } if (passFlag == 1) { printf(" PASS: Player %d discard is uneffected/n", i + 1); passCount++; } else { printf(" FAIL: Player %d discard is effected/n", i + 1); failCount++; } } printf("/n--- Verify card supply has not been effected ---/n"); /* Action Cards */ passFlag = 1; for (int i = 0; i < 10; i++) { testValue = supplyCount(cards[i], &testGame); origValue = supplyCount(cards[i], &origGame); if (testValue != origValue) { passFlag = 0; break; } } if (passFlag == 1) { printf(" PASS: Action Card Supply is uneffected/n"); passCount++; } else { printf(" FAIL: Action Card Supply is effected/n"); failCount++; } /* Basic Cards */ passFlag = 1; for (int i = 0; i < 7; i++) { testValue = supplyCount(baseCards[i], &testGame); origValue = supplyCount(baseCards[i], &origGame); if (testValue != origValue) { passFlag = 0; break; } } if (passFlag == 1) { printf(" PASS: Basic Card Supply is uneffected/n"); passCount++; } else { printf(" FAIL: Basic Card Supply is effected/n"); failCount++; } } else { printf(" FAIL: cardEffect() method did not complete successfully/n"); failCount++; } /* Print overall results */ printf("/n--- Overall test results ---/n"); printf(" PASS: %d of %d/n", passCount, passCount + failCount); printf(" FAIL: %d of %d/n", failCount, passCount + failCount); return 0;}
开发者ID:csDaniel,项目名称:cs362sp16,代码行数:101,
示例11: Actions/*Feast: Trash this card. Gain a card costing up to 5 Coins.Additional Rules: The gained card goes into your Discard pile. It has to be a card from the Supply.You cannot use coins from Treasures or previous Actions (like the Market) to increase the cost of the card that you gain.If you use Throne Room on Feast, you will gain two cards, even though you can only trash Feast once.Gaining the card isn't contingent on trashing Feast; they're just two things that the card tries to make you do.This adds 5 coins to the player, but does not subtract them should the chosen card be too expensive.Also the code checks that the player has the coins needed but the rules do not alow usingadditional coins to increase the value of the gained card.*/int playFeast(int currentPlayer, struct gameState *state, int choice1){ int temphand[MAX_HAND]; int cardNotBought; int i; //Backup hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { temphand[i] = state->hand[currentPlayer][i];//Backup card state->hand[currentPlayer][i] = EMPTY_CARD;//Set to nothing } //Update Coins for Buy (adds 5 which is the incorect behavor) updateCoins(currentPlayer, state, FEAST_MAX_COST); cardNotBought = NOT_BOUGHT;//Condition to loop on while( cardNotBought == NOT_BOUGHT) {//Buy one card if (supplyCount(choice1, state) <= EMPTY_SUPPLY) { if (DEBUG) { printf("None of that card left, sorry!/n"); printf("Cards Left: %d/n", supplyCount(choice1, state)); } } else if (state->coins < getCost(choice1)) { printf("That card is too expensive!/n"); if (DEBUG) printf("Coins: %d < %d/n", state->coins, getCost(choice1)); } else { if (DEBUG) { printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer] ); } gainCard(choice1, state, TO_DISCARD, currentPlayer);//Gain the card cardNotBought = BOUGHT;//No more buying cards if (DEBUG){ printf("Deck Count: %d/n", state->handCount[currentPlayer] + state->deckCount[currentPlayer] + state->discardCount[currentPlayer] ); } }//printf("Card not bought feast choice 1: %d/n", choice1); } //Reset Hand for (i = 0; i <= state->handCount[currentPlayer]; i++) { state->hand[currentPlayer][i] = temphand[i]; temphand[i] = EMPTY_CARD; } return EFFECT_SUCCESS;}
开发者ID:JLBR,项目名称:School-Projects,代码行数:83,
注:本文中的supplyCount函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ supply_register_by_name函数代码示例 C++ superuser函数代码示例 |