### Need help creating a card game similar to Rock Paper Scissors but with different objectives

Hello,
I seek assistance in creating this game it is similar to RPS(Rock,Paper,Scissors) but with different objectives.
==============================
Card | Beats | Loses To
==============================
Peasants >| Serf >| King
King >| Peasants >| Serf
Serf >| KIng >| Serf
==============================
the player and the Ai are given 5 cards. 4 of which are Peasants. The remaining one is either a King or a Serf, depending on which side the player is playing.

A player can only be on one of the 2 sides in each round. The game starts with determining which side a player is on. The round ends whenever the king or Serf card is played. The objective of the game depends on which side you are on.

If you are on the King side, your goal is to hide your King within the Peasants and play it when you feel the opponent will play the Peasants card.

If you are on the Serf side, your goal is to kill the King. If you fail to predict the opponentâ€™s hand, the Serf will be killed by the Peasants. This denies the opportunity of the Serf side from winning, hence you lose.

this is what I have started

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677`` ``````#include #include #include #include using namespace std; void deckBuilder(vector& deck, int &round) { vector kingNums = { 1, 2, 3, 7, 8, 9 }; vector serfNums = { 4, 5, 6, 10, 11, 12 }; int i; for (i = 0; i < deck.size(); i++) { kingNums[i]; serfNums[i]; } if (kingNums[i] == round) { deck.push_back("Emperor Card"); deck.push_back("Citizen Card"); deck.push_back("Citizen Card"); deck.push_back("Citizen Card"); deck.push_back("Citizen Card\n"); } else if (serfNums[i] == round) { deck.push_back("Slave Card"); deck.push_back("Citizen Card"); deck.push_back("Citizen Card"); deck.push_back("Citizen Card"); deck.push_back("Citizen Card\n"); } } void printDeck(const vector deck) { for (int i = 0; i < deck.size(); i++) { cout << " -"<< deck[i] << "\n"; } } void playRound(int &round, int \$mmleft, int moneyEarned) { vector deck; cout << "Round: " << round << "\n"; deckBuilder(deck, round); printDeck(deck); } int main() { srand(unsigned int(time(NULL))); int round = 1; int mmLeft = 30; int moneyEarned = 0; while (round < 13) { playRound(round, mmLeft, moneyEarned); round++; } cout << "\n\n"; return 0; } }``````

my issue is that for some reason the deckBuilder function is NOT doing what wanted it to do.

OUTPUT:
 ``123456789101112131415161718192021222324`` ``````Round: 1 Round: 2 -Emperor Card -Citizen Card -Citizen Card -Citizen Card -Citizen Card Round: 3 Round: 4 Round: 5 -Slave Card -Citizen Card -Citizen Card -Citizen Card -Citizen Card Round: 6 Round: 7 Round: 8 Round: 9 Round: 10 Round: 11 Round: 12``````

i wanted that in a specific round (max round = 12) it should push.back either the King deck or the Serf deck in this in round order(King=1,2,3,7,8,9 Serf=4,5,6,10,11,12) but it doesn't do that, Can you help me out.
Last edited on

Edit... that will go out of bounds... der.. give me a second

 ``123456`` ``````int i; for (i = 0; i <6; i++) { if(kingNums[i]==round || serfNums[i]==round) break; } if (kingNums[i] == round){//do whatever ``````

That should work.
Last edited on
the line 13 loop does not do anything at all. What did you want it to do? The if statements after depend on i but are not in the loop.

that aside,
is this what you want (not code, is logic):

bool iskinground[] {1,1,1,0,0,0,1,1,1,0,0,0};
for(int i = 0; i < 12; i++)
{
if(iskinground[i]) ... pushback king deck
else pushback serf deck
}
Last edited on
Thanks Markyrocks, I see where I went wrong.
and
jonnin Thanks for the bool tip, never came to my mind that way.

I think Botched it up, didn't think this through.
I was supposed to print out the deck for one round and let the player pick from it then the function to delete a chosen card from the vector/deck then print it out the updated deck/vector....

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293`` ``````#include #include #include #include using namespace std; void deckBuilder(vector& deck, int &round) { vector kingNums = { 1, 2, 3, 7, 8, 9 }; vector serfNums = { 4, 5, 6, 10, 11, 12 }; int i; for (i = 0; i < 6; i++) { if (kingNums[i] == round || serfNums[i] == round) break; } cout << "Round: " << round << "\n========================"; if (kingNums[i] == round) { cout << "\nKing Deck:\n"; deck.push_back("King Card"); deck.push_back("Peasant Card"); deck.push_back("Peasant Card"); deck.push_back("Peasant Card"); deck.push_back("Peasant Card\n"); } } void printDeck(const vector& deck) { for (int i = 0; i < deck.size(); i++) { cout << " -" << deck[i] << "\n"; } } void cardDelete(vector& deck, string playerPicked) { int indecated = -1; for (int i = 0; i < deck.size(); i++) { if (playerPicked == deck[i]) { indecated = i; break; } } if (indecated > 0) { deck.erase(deck.begin() + indecated); } } void playerPlay(vector &deck) { string search; cout << "What card would like to play: "; cin >> search; cardDelete(deck, search); } void playRound(int &round, int \$mmleft, int moneyEarned) { vector deck; deckBuilder(deck, round); printDeck(deck); playerPlay(deck); printDeck(deck); system("pause"); } int main() { srand(unsigned int(time(NULL))); int round = 1; while (round < 13) { playRound(round); round++; } cout << "\n\n"; return 0; }``````
Topic archived. No new replies allowed.