本文整理汇总了C++中remodelCard函数的典型用法代码示例。如果您正苦于以下问题:C++ remodelCard函数的具体用法?C++ remodelCard怎么用?C++ remodelCard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remodelCard函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv){
struct gameState g;
int i;
srand(time(NULL));
int cardPlays;
int seed = 0;
int handPos = 0;
int randomChoice1, randomChoice2 = 0;
int handCountPre = 0;
int randomPlayer;
int cardCost1,cardCost2;
int validate = 0;
int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
sea_hag, tribute, smithy};
cardPlays = 100;
for(i = 0; i < cardPlays; i ++){
seed = (rand() % 65535);
initializeGame(4,k,seed,&g);
randomPlayer = (rand() % 4);
randomChoice2 = 0;
handPos = (rand() % 5);
handCountPre = 0;
do{
randomChoice1 = (rand() % 5);
} while(randomChoice1 == handPos);
randomChoice2 = gold;//(rand() % 26) + 1;
cardCost1 = getCost(g.hand[randomPlayer][randomChoice1]);
cardCost2 = getCost(gold);
handCountPre = g.handCount[randomPlayer];
validate = remodelCard(&g, handPos, randomPlayer, randomChoice1, randomChoice2);
if(validate ==0){
printf("hand count before %d\n", handCountPre);
printf("cost of choice1 = %d\n",cardCost1);
printf("cost of choice2 = %d\n",cardCost2);
printf("hand count after %d\n", g.handCount[randomPlayer]);
//assert(cardCost2 <= (cardCost1+2));
}
}
printf("all test passed");
return 0;
}
示例2: cardEffect
int 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{
/* MUTANT (rep_op) */ 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);
}
}
}
//.........这里部分代码省略.........
示例3: cardEffect
int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus)
{
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;
}
switch( card )
{
case adventurer:
return adventurerCard(&drawntreasure, state, &cardDrawn, ¤tPlayer, temphand, &z);
case council_room:
return council_roomCard(¤tPlayer, state, &handPos);
case feast:
return feastCard(state, temphand, ¤tPlayer, &choice1);
case gardens:
return -1;
case mine:
return mineCard(state, ¤tPlayer, &choice1, &choice2, &handPos);
case remodel:
return remodelCard(state, ¤tPlayer, &choice1, &choice2, &handPos);
case smithy:
return smithyCard(state, ¤tPlayer, &handPos);
case village:
return villageCard(state, ¤tPlayer, &handPos);
case baron:
return baronCard(state, ¤tPlayer, &choice1);
case great_hall:
return great_hallCard(state, ¤tPlayer, &handPos);
case minion:
return minionCard(state, ¤tPlayer, &handPos, &choice1, &choice2);
case steward:
return stewardCard(state, ¤tPlayer, &handPos, &choice1, &choice2, &choice3);
case tribute:
return tributeCard(state, ¤tPlayer, &handPos, &nextPlayer, tributeRevealedCards);
case ambassador:
return ambassadorCard(state, ¤tPlayer, &handPos, &choice1, &choice2);
case cutpurse:
return cutpurseCard(state, ¤tPlayer, &handPos);
case embargo:
return embargoCard(state, ¤tPlayer, &handPos, &choice1);
case outpost:
return outpostCard(state, ¤tPlayer, &handPos);
case salvager:
return salvagerCard(state, ¤tPlayer, &handPos, &choice1);
case sea_hag:
return sea_hagCard(state, ¤tPlayer);
case treasure_map:
return treasure_mapCard(state, ¤tPlayer, &handPos);
}
return -1;
}